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

No legacy script tag in HTML #621

Open
IlyaSemenov opened this issue Nov 14, 2022 · 1 comment
Open

No legacy script tag in HTML #621

IlyaSemenov opened this issue Nov 14, 2022 · 1 comment

Comments

@IlyaSemenov
Copy link
Contributor

Environment

  • Operating System: Darwin
  • Node Version: v16.15.0
  • Nuxt Version: 2.16.0-27720022.54e852f
  • Nitro Version: 0.6.1
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: bridge, serverHandlers, devServerHandlers, typescript, buildModules
  • Runtime Modules: -
  • Build Modules: (), @nuxt/[email protected]

Reproduction

https://github.com/IlyaSemenov/nuxt-no-legacy-script-repro

git clone https://github.com/IlyaSemenov/nuxt-no-legacy-script-repro
yarn
yarn build
yarn start

Open http://localhost:3000. There will be no legacy scripts, only <script type="module">. The button will not work in legacy browsers that don't support script modules.

Describe the bug

The app built with the latest @nuxt/bridge doesn't work in legacy browsers such as Chrome 49 (the last Chrome that works on Windows XP). The actual app scripts are processed with @vitejs/plugin-legacy (and will work in Chrome 49 if loaded) but the HTML code only includes <script type="module"> code which is not supported by legacy browsers.

This is all kind of self-contradicting. <script type="module"> are supposed to load non-legacy scripts for modern browsers. Instead, the current bridge doesn't load modern scripts at all, but loads legacy scripts with modern <script> tag.

Additional context

No response

Logs

No response

@IlyaSemenov
Copy link
Contributor Author

IlyaSemenov commented Nov 14, 2022

I traced the problem to this code:

bridge/src/vite/manifest.ts

Lines 107 to 110 in fcf636d

const manifest = normalizeViteManifest({
[clientEntryName]: {
file: clientEntryName,
module: true,

For some reason bridge deliberately marks legacy chunks as module: true which is incorrect. Changing that to module: false (and a couple more patches per #340 (comment) and #341) makes the build work in Windows XP / Chrome 49.


EDIT: note that simply removing module: true will not work. normalizeViteManifest also injects module: true for whatever reason (see nuxt-contrib/vue-bundle-renderer#44) so it must be explicitly set to false.

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