Skip to content

fix(ie compat): include polyfill for currentScript directly #3151

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

Closed
wants to merge 1 commit into from
Closed

fix(ie compat): include polyfill for currentScript directly #3151

wants to merge 1 commit into from

Conversation

ameinhardt
Copy link

it would be nice if vue-cli produces libs, that can be used in IE directly.

Signed-off-by: Axel Meinhardt <axel.meinhardt@gmx.com>
@ameinhardt
Copy link
Author

workaround to overwrite the existing file in vue.config.js:

config
      .plugin('fix-vue-cli-ie')
      .use(NormalModuleReplacementPlugin)
      .init(Plugin => new Plugin(/setPublicPath\.js/, __dirname + '/src/betterSetPublicPath.js'));

@haoqunjiang
Copy link
Member

I'm not sure if it's a good idea to add this polyfill for every library build as it's only useful for those who need IE support.

When using Vue CLI to build a library or Web Components, it is recommended to pass useBuiltIns: false to @vue/babel-preset-app to disable automatic polyfill injection. This ensures you don't include unnecessary polyfills in your code, as it should be the responsibility of the consuming app to include polyfills.

I'd rather make it opt-in.

@yyx990803
Copy link
Member

yyx990803 commented Jan 14, 2019

I think what we can do is:

  • detect whether user intends to support IE by analyzing browserslist in package.json
  • If need IE support, inject an env variable NEED_CURRENTSCRIPT_POLYFILL via webpack's define plugin and wrap the polyfill in a conditional block.
  • This ensures the polyfill is dropped if user doesn't need IE support
  • For the rare use case where user is producing multiple independent webpack bundles (thus duplicating the polyfill a lot), they can manually set NEED_CURRENTSCRIPT_POLYFILL to false in .env files and manage the polyfill themselves.

@haoqunjiang
Copy link
Member

Closed in favor of #3760

@haoqunjiang haoqunjiang closed this Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants