-
Notifications
You must be signed in to change notification settings - Fork 91
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
Sentry reporting syntax error from IE11 (questions regarding bundling and package.json
fields)
#52
Comments
I have an update pending for the vuejs.org cookbook which aims to explain the main/module/browser fields, among other things. Just when I thought this was all figured out... With Vue 3 on the horizon, and with that an official end-of-life for all IE support in vue, it's frustrating that things like this ruin what would otherwise be a "simple" recipe/utility. Even Microsoft themselves don't recommend using IE for browsing the web anymore! It's not an uncommon occurrence that non-ES5 modules are published to npm - in fact, some pretty common packages are in that camp (D3 comes to mind). True, webpack must be instructed to transpile ES6 node modules, but at least that is opt-in. Transpiling the existing 'browser' build to ES5 means it's no longer a true esm build, and it passes the download cost to all users regardless - browsers that can handle ES6 are served older code, because that's all that what webpack picked up, even though the website owner might not even include IE in their target audience! Not to mention that ES5 builds are often quite a bit larger, so developers also pay a price in a larger download - not as much of a concern, but still true. In the interest of moving the web forward, perhaps the utility could generate a sample README that includes information about adding IE support? This places the decision of cost where it belongs - with those using the module in their sites, who know the target audience and whether it is even necessary. |
Hey @mgdodge, thanks for the response. We are indeed in an unusual Limbo right now.
If you configure Rollup with Side note about tree-shaking This template makes tree-shaking impossible due to the dynamic assignment of the Good points regarding shipping code that's transpiled for compatibility with the lowest-common denominator, but that's also in the spirit of the web I think. The Thanks for all the work on this repository btw, it's been a great source of guidance 👍 |
@saulhardman I am still not convinced that this utility should default to creating es5 code where it is not needed by everyone. As your initial report indicated, the Regarding tree shaking - I can make a small update to the 'single component' scaffolding that fixes the dynamic install function you pointed out, that is genuinely something that can be fixed. The problem does not exist when using the 'library' scaffolding. The change would probably land in the next major release, which will be landing shortly and gives the option of scaffolding Vue 2 and Vue 3 components. Speaking of which, Vue 3 components, as currently transpiled by rollup-plugin-vue@next, are not tree-shakeable at all. And it's a lot more than just the one function causing the problem. When I get a bug report written for it, I will link to it from here. |
As promised, the tree-shaking issue I have logged with rollup-plugin-vue for Vue 3 components. Also, I have published v4.0.0-beta.1 of this utility, which fixes the dynamic install function issue - please confirm if it works for you. When exporting more than one thing, even if you are exporting a single component plus a helper function, it might be considered a "library" at that point, FWIW. |
The decision has been made to deprecate |
Sentry is reporting an error that's being triggered in IE11 from a component bundled using this template. It's a syntax error and the offending code is below (note the arrow function in
createInjector
):The quick-fix for this is to configure
rollup-plugin-vue
to use ES5-compliant bundles for thenormalizer
andsyleInjector
:However, this led to me reviewing the logic behind how the bundles themselves are built and also which bundles are assigned to which fields in the
package.json
file.I noticed that the
"browser"
field inpackage.json
points to the*.esm.js
bundle. However, you're explicitly removing support for "legacy" browsers for that build.It's my understanding that tools such as Webpack will consume this
"browser"
bundle for browser-targeted bundles and will not transpile them unless explicitly instructed to do so (which is unlikely).To resolve this issue whilst keeping the build configuration as it is, you could tell people authoring components using this template to inform their users that they'll need to transpile the bundles as part of their own build process (if their browser support requires it).
The other option is to create 2 ESM builds:
dist/*.esm-modern.js
which is assigned to the"module"
field in package.json anddist/*.esm-legacy.js
which is assigned to"browser"
. The legacy bundle would includeie > 10
in its Browserslist config and the above fix regardingrollup-plugin-vue
.Again, if my understanding is correct, the
"module"
bundle is intended to be used (currently) by tools such as Snowpack to enable development builds that utilise ESM. That means that the*.esm-modern.js
bundle could also define its@babel/preset-env
targets
to be much more modern e.g.last 2 chrome versions, last 2 firefox versions
.Does that make sense? Am I right in my thinking?
The text was updated successfully, but these errors were encountered: