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.

Not compatible with `strict mode` in IE

See original GitHub issue

Not seeing a Contributing file or issue template so I’ll do my best to be thorough.

OS: Windows 10 Browser: IE 11 Error: SyntaxError: Multiple definitions of a property not allowed in strict mode

Stack Trace:

SyntaxError: Multiple definitions of a property not allowed in strict mode
   at ./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./node_modules/vue-svg-inline-loader/src/index.js?!./src/js/templates/component.vue?vue&type=template&id=1d640f16&scoped=true& (http://localhost:3000/components.min.js:71:1)
   at __webpack_require__ (http://localhost:3000/app.min.js?0e8ad4e4b2f26f53c17b:838:12)
   at fn (http://localhost:3000/app.min.js?0e8ad4e4b2f26f53c17b:130:13)
   at eval code (eval code:2:22)
   at ./src/js/templates/component.vue?vue&type=template&id=1d640f16&scoped=true& (http://localhost:3000/components.min.js:201:1)
   at __webpack_require__ (http://localhost:3000/app.min.js?0e8ad4e4b2f26f53c17b:838:12)
   at fn (http://localhost:3000/app.min.js?0e8ad4e4b2f26f53c17b:130:13)
   at eval code (eval code:2:22)
   at ./src/js/templates/component.vue (http://localhost:3000/components.min.js:177:1)
   at __webpack_require__ (http://localhost:3000/app.min.js?0e8"

Steps to replicate:

  1. Use svg-inline attribute on multiple tags in a single component or Webpack chunk file.
  2. Set output chunks to use strict mode. In my case, I’m using babel and core-js which inject use strict automatically.
  3. Open application with affected component in IE.

The affected component does not render, but others do. This issue is not present in any other browser, but occurs in IE anytime the plugin is used more than once per chunk in Webpack. When SVGs are embedded manually into components, the issue goes away. We need to support IE so I had to remove the plugin for now, but obviously embedding SVGs manually isn’t ideal so I’d appreciate if someone could look into this.

If I were to speculate this seems to create multiple instances (1 for each SVG) with the same identifier when compiled by Webpack, but I’m not 100% certain if I’m on the right track.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
funkybunchcommented, Feb 9, 2021

Thanks for the follow-up @oliverfindl, and sorry for the delay. We were able to resolve it on our end - all were issues with how Adobe Illustrator was exporting our SVGs. Some tweaks to the export settings got it all working properly.

If others run into this issue here is what we did to resolve it:

  1. We found SVGs exported from Adobe Illustrator included XML definitions and IDs that cause issues when you try to embed them through an automated embed process, like this plugin. Specifically we had several SVGs with id="Layer_1" because Illustrator injects it automatically by default. This can be changed in Illustrator if you don’t want to manually remove it every time you use a new SVG in your code. (File->Export->Export for Screens->[Set Format to SVG in lower right]->[Click cog/gear icon above format section]->SVG->Change Object IDs: Unique)
  2. Illustrator would also add a <style> tag to the SVG file which Webpack in particular doesn’t like. It can also inadvertently affect your other styles if there is any overlap in classes - so its best to avoid it altogether. You can also resolve this in Illustrator’s export settings. (File->Export->Export for Screens->[Set Format to SVG in lower right]->[Click cog/gear icon above format section]->SVG->Change Styling: Presentation Attributes)
  3. Lastly, files exported using Illustrator’s default settings include XML definitions. You’ll get an error if XML definitions or comments are present. By default, Illustrator exports both. You’ll need to enable minification to prevent Illustrator from injecting these. (File->Export->Export for Screens->[Set Format to SVG in lower right]->[Click cog/gear icon above format section]->SVG->Check the “Minify” checkbox)

Hope others find this useful.

0reactions
oliverfindlcommented, Feb 9, 2021

Thanks for your feedback!

One more hint, maybe it could be solved with properly configuring SVGO in loader options.

Anyway, thanks for your contribution to this project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cross Browser Compatibility of ECMAScript 5 Strict Mode in ...
ECMAScript 5 Strict Mode is Fully Supported on Internet Explorer 10. Checkout overall cross browser compatibility of ECMAScript 5 Strict ...
Read more >
Strict mode error only in IE11. Can I take off ... - Stack Overflow
This code works perfectly in all modern browsers i've tested. Only in IE11 is this breaking the entire site, stopping all subsequent lines...
Read more >
Strict mode - JavaScript - MDN Web Docs
JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode".
Read more >
ECMAScript 5 Strict Mode | Can I use... Support ... - CanIUse
1 Partial support in older Safari refers to strict mode still accepting a lot of JS that should be considered invalid.
Read more >
IE11 strict mode issues (inc. Mars Theme) - Get Help
Looking at the console with a production build, the debugger was throwing the error Accessing the 'caller' property of a function or arguments...
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