Skip to content

setting global in vite.define breaks build #13941

Closed
nuxt/framework
#4958
@ennioVisco

Description

Environment


  • Operating System: Darwin
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.2
  • Package Manager: yarn@3.1.1
  • Builder: vite
  • User Config: ssr, runtimeConfig, typescript, css, buildModules, alias
  • Runtime Modules: -
  • Build Modules: @vueuse/nuxt@8.4.2, @intlify/nuxt3@0.1.10

Reproduction

Simply set these settings, and execute npx nuxi generate or nuxi build.

// nuxt.config.ts
export default defineConfig({
  // ...
  alias: {
    // ...
    './runtimeConfig': './runtimeConfig.browser',
  },
  vite: {
    // ...
    define: {
      "global": {},
    }
  }
});

Describe the bug

More precisely, it seems that the global variable conflicts with nuxt's middleware or something similar.
However, this error does not appear when running nuxi dev.

Additional context

This global parameter is the currently standard flag that is added to solve runtime issues with AWS Amplify.
See #2308 for the related discussion.

Logs

------------------------------
67:   nuxtApp._activeRoute = reactive(activeRoute);
68:   nuxtApp._middleware = nuxtApp._middleware || {
69:     global: [],
        ^
70:     named: {}
71:   };


 ERROR  Unexpected token (Note that you need plugins to import files that are not JavaScript)   

 ------------------------------

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions