FranckFreiburger / vue3-sfc-loader

Single File Component loader for Vue2 and Vue3. Load .vue files directly from your HTML. No node.js environment, no build step.
MIT License
1.03k stars 116 forks source link

IE11 error "SCRIPT5017" when load vue2-sfc-loader.js #75

Closed wallance-zhang closed 3 years ago

wallance-zhang commented 3 years ago

Hi Franck,

I build my own version(to support IE11) use the {"browserslist": "> 1%, last 2 versions, not ie <= 10"} and {"browserslist": "defaults"}, but in IE11 always encounter js error SCRIPT5017 point to the line "vue2-sfc-loader.js (9,360569)" this error point to the vue2-sfc-loader.js.map:
parse() { this.enterInitialScopes();

what can I do to fix this issue?

Thanks, Wallace

wallance-zhang commented 3 years ago

Hi guys,

I point the exact issue at @babel/parser->lib->index.js: const keywordRelationalOperator = /in(?:stanceof)?/y; IE doesn't recognize "/y", this express is packaged into vue2-sfc-loader.js.

FranckFreiburger commented 3 years ago

@babel/plugin-transform-sticky-regex (https://babeljs.io/docs/en/babel-plugin-transform-sticky-regex)

NOTE: This plugin is included in @babel/preset-env

AFAIU babel should transform this according to the browserlist. We should check if node_modules/** files are properly processed through babel-loader.

wallance-zhang commented 3 years ago

Hi Franck,

Thanks for your help, but the issue is always here. as you mention I add some babel plugin in webpack.config.js: presets: [ ...!noPresetEnv ? [ [ '@babel/preset-env', { useBuiltIns: 'entry', // https://babeljs.io/docs/en/babel-preset-env#usebuiltins corejs: { version: 3, proposals: true }, targets: { browsers: targetsBrowsers, }, } ] ] : [], ], plugins: [ "@babel/plugin-transform-duplicate-keys", "@babel/plugin-transform-sticky-regex" ], } @in web.config set the browserslit: "browserslist": "ie 11, not dead",

But the js error is not fixed, could you please test the vue3-sfc-loader.js under IE 11?

FranckFreiburger commented 3 years ago

unable to find a decent RegExp polyfill that handles sticky (y) flag (eg. RegExp("in(?:stanceof)?","y"))

FranckFreiburger commented 3 years ago

... and https://github.com/FranckFreiburger/vue3-sfc-loader/commit/9111483e48a5a63a29cd40c05390939f913abf71

FranckFreiburger commented 2 years ago

example: https://github.com/FranckFreiburger/vue3-sfc-loader/blob/main/docs/examples.md#ie11-example

wallance-zhang commented 2 years ago

Hi Franck, I appreciate your kindly feedback,thanks for your help. It works well under IE11 apply your example. :)