question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File polyfills-legacy should not be in strict mode (Plugin legacy)

See original GitHub issue

Describe the bug

For older browsers with IE 11 support generated file polyfills-legacy.[hash].js should not contain use strict directive, but it does.

It is required by polyfill regenerator-runtime/runtime which contains a comment: This module should not be running in strict mode, ... (https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736)

Because the built-in file contains use strict, it will result in an error.

Even if I have set

        rollupOptions: {
            output: {
                strict: false // no strict mode, ... but maybe Rollup is wrong, I am not sure
            }
        },

Reproduction

https://stackblitz.com/edit/vite-v5p4en

System Info

System:
    OS: Linux undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: Unknown - /bin/jsh
  Binaries:
    Node: 14.16.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /bin/yarn
    npm: 7.17.0 - /bin/npm
  npmPackages:
    @vitejs/plugin-legacy: ^1.6.4 => 1.6.4 
    vite: ^2.6.0 => 2.7.10

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
upccczcommented, Apr 22, 2022

sometimes you need to use generateBundle hook, such as dealing with polyfills-legacy.js

0reactions
sapphi-redcommented, May 23, 2022

I was not able to reproduce it with IE11.

Also regenerator-runtime/runtime states it works if CSP is not enabled. So if CSP is not set, I think it would work. https://github.com/facebook/regenerator/blob/055b4030219f7cc0af5999ef4431c991697d7ee5/packages/runtime/runtime.js#L739-L748

Read more comments on GitHub >

github_iconTop Results From Across the Web

@vitejs/plugin-legacy - npm
This plugin provides support for legacy browsers that do not support those features when building for production. By default, this plugin ...
Read more >
Vite.js Next Generation Frontend Tooling + Craft CMS
Vite.js is next generation frontend tooling that can replace webpack, Mix, Gulp, etc. for building frontend assets like JavaScript and CSS.
Read more >
hc-plugin-legacy - npm Package Health Analysis - Snyk
This plugin provides support for legacy browsers that do not support native ESM when building for production. By default, this plugin will:.
Read more >
What is TypeScript Strict Mode? - YouTube
Let's talk about TypeScript Strict Mode ! Should you use it? (Yes!)When should you use it? (As soon as you can !)
Read more >
Vitejs/plugin Legacy: Legacy Browser Support For Vite - Morioh
This plugin provides support for legacy browsers that do not support ... this option will exclude systemjs/dist/s.min.js inside polyfills-legacy chunk.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found