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

@vitejs/plugin-legacy doesn't work on ie11, the script isn't executed and it isn't transpiled. #6577

Closed
7 tasks done
ericmackrodt opened this issue Jan 21, 2022 · 6 comments · Fixed by #7596
Closed
7 tasks done
Labels
needs documentation Documentations are needed pending triage

Comments

@ericmackrodt
Copy link

Describe the bug

I am trying to run my application on IE 11, it's using react and typescript, but the transpiled scripts do not work at all.
The index.html page is loaded but it stays blank with and the script doesn't run.

I have setup a vanilla vite app to see if it was my React+Typescript setup and the problem also happens in the vanilla app, which I liked in the repo.

I also put an alert in the js to see if that would fire, but nothing happened, I also have no errors on the console.
Screen Shot 2022-01-21 at 11 04 07 am

The HTML file is loaded though:
Screen Shot 2022-01-21 at 11 03 51 am

The script file seems to have been downloaded even though it wasn't executed.
Screen Shot 2022-01-21 at 11 04 24 am

Also, I'm pretty sure IE11 wouldn't like import './style.css'; or the template string if the script was running.

I used the default vite.config.js from @vitejs/plugin-legacy for this:

import legacy from "@vitejs/plugin-legacy";

export default {
  plugins: [
    legacy({
      // for ie11
      targets: ["ie >= 11"],
      additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
    }),
  ],
};

Removing type="module" from the script tag seems to allow the script to run but I don't know if it's a good idea to do that because I'm not too sure if vite needs that for any reason.

Also, as suspected, even though the script runs, I get syntax errors due to the code not being transpiled to js that is compatible with IE 11.

I don't know what to do here, any help is appreciated.

Thanks in advance.

Reproduction

https://github.com/ericmackrodt/vitejs-vite-wgu8t4

System Info

System:
    OS: macOS 11.5.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 629.89 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v16.13.1/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Chrome Canary: 98.0.4743.0
    Firefox: 96.0.1
    Safari: 14.1.2
  npmPackages:
    @vitejs/plugin-legacy: ^1.6.4 => 1.6.4 
    vite: ^2.7.2 => 2.7.13

Used Package Manager

yarn

Logs

No response

Validations

@yoyo930021
Copy link
Contributor

Do you use yarn build and using files in the dist folder?
The @vite/plugin-legacy only affects build mode.

@jingshanchen
Copy link

Do you use yarn build and using files in the dist folder? The @vite/plugin-legacy only affects build mode.
How to do if we want to debugger some compatible bugs in dev Env?

@yoyo930021
Copy link
Contributor

Do you use yarn build and using files in the dist folder? The @vite/plugin-legacy only affects build mode.
How to do if we want to debugger some compatible bugs in dev Env?

yarn build
yarn preview

@jingshanchen
Copy link

so no Hmr mode ?

@yoyo930021
Copy link
Contributor

so no Hmr mode ?

Vite provides fast dev env in the modern browsers, but not in IE11.
The @vite/plugin-legacy provides a prod legacy build for users.

@Dan503
Copy link

Dan503 commented Mar 8, 2022

The @vite/plugin-legacy only affects build mode.

The documentation doesn't make this clear enough.

The very first line of the documentation should say this in bold letters:

@vite/plugin-legacy only affects build mode, not dev mode!

@sodatea sodatea added the needs documentation Documentations are needed label Mar 8, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs documentation Documentations are needed pending triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants