-
Notifications
You must be signed in to change notification settings - Fork 54
Description
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 use import. Even the docs suggest using
// ES6
import shareThis from "share-this";But there's a catch. The module resolver prefers module over main in package.json. This is true only for JS Modules (import syntax).
https://github.com/MaxArt2501/share-this/blob/v1.3.1/package.json#L13-L14
"main": "dist/share-this.js",
"module": "src/core.js",
In the case of share-this, it means that the import syntax will take the src/core.js. The usual webpack config will not compile anything from node_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, with const and everything. Internet Explorer says π π
There are a few possible solutions:
- Ship a transpiled
dist/share-this.es.jsand change themoduleto point to it. - Remove the
moduleand leave only themain. Most current build pipelines will work with the old commonjs way. Not sure if this will hold true in the future. - Leave it to the consumers to figure it out, either import
share-this/dist/share-thisor transpile it on their end. It's like this at the moment, so no work required. It's a solution, but a bad one.