-
Notifications
You must be signed in to change notification settings - Fork 53
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
The ES module points to non-transpiled src/core.js file #48
Comments
I claim no responsibility for what webpack does :| But you can configure it to compile certain modules in node_modules. import shareThis from 'https://cdn.jsdelivr.net/npm/share-this/src/core.js'; and that would work perfectly fine. But I guess I'll look into what's rolling now for those package.json properties, and serve a single file compiled for ES6 in |
To clarify, it's not just webpack, any "standard" bundler implementation where we use
So from this point of view, the use of Also, the bug I have reported here is the problem node.js docs call "dual package hazard": https://nodejs.org/api/esm.html#esm_dual_package_hazard. So what I've suggested with option 2), removing the |
This module claims support for various older versions of browsers.
But there is an edge case where this is not true.
When used with
webpack
or similar tools, it's a common practice to useimport
. Even the docs suggest usingBut there's a catch. The module resolver prefers
module
overmain
inpackage.json
. This is true only for JS Modules (import
syntax).https://github.com/MaxArt2501/share-this/blob/v1.3.1/package.json#L13-L14
In the case of
share-this
, it means that theimport
syntax will take thesrc/core.js
. The usual webpack config will not compile anything fromnode_modules
folder for performance reasons.So when we put all of this together, the result is the raw
src/*
code landing in the vendor bundle, withconst
and everything. Internet Explorer says 👎 😄There are a few possible solutions:
dist/share-this.es.js
and change themodule
to point to it.module
and leave only themain
. Most current build pipelines will work with the old commonjs way. Not sure if this will hold true in the future.share-this/dist/share-this
or transpile it on their end. It's like this at the moment, so no work required. It's a solution, but a bad one.The text was updated successfully, but these errors were encountered: