Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite entry-legacy.js is not ES5 compatible #340

Open
IlyaSemenov opened this issue May 9, 2022 · 2 comments
Open

Vite entry-legacy.js is not ES5 compatible #340

IlyaSemenov opened this issue May 9, 2022 · 2 comments

Comments

@IlyaSemenov
Copy link
Contributor

Environment

  • Operating System: Darwin
  • Node Version: v16.13.0
  • Nuxt Version: 2.16.0-27358576.777a4b7f
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: bridge, hooks, buildModules
  • Runtime Modules: -
  • Build Modules: @nuxt/[email protected]

Reproduction

Create empty project with this nuxt.config.js:

import { defineNuxtConfig } from '@nuxt/bridge'
import legacy from '@vitejs/plugin-legacy'

export default defineNuxtConfig({
  bridge: {
    vite: true,
  },
  hooks: {
    'vite:extendConfig': config => {
      config.plugins.forEach((plugin, i) => {
        if (Array.isArray(plugin) && plugin[0].name === 'vite:legacy-config') {
          config.plugins[i] = legacy({
            targets: ['ie 9'],
          })
        }
      })
    },
  },
})

Then run nuxi build.

.output/public/_nuxt/entry-legacy.c81f3a42.js will include code that does not run in IE 9:

var appConfig = window?.__NUXT__?.config.app || {}

Describe the bug

nuxi build generates ES5-incompatible javascript even if @vitejs/plugin-legacy is configured with IE 9 target. The plugin itself works fine, the problem is apparently that Nuxt-injected code is not processed with that plugin.

Additional context

No response

Logs

No response

@IlyaSemenov
Copy link
Contributor Author

See #341 as well.

@IlyaSemenov
Copy link
Contributor Author

In @nuxt/[email protected], the entry point syntax is ES5 compatible, however it won't work in legacy browsers due to:

globalThis.__publicAssetsURL = function(id) { return joinURL(publicBase, id || "") }

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant