Replies: 1 comment 2 replies
-
Ideally, you should publish your library as commonjs & esm. {
"name": "my-library",
"main": "dist-from-babel/index.js",
"module": "src/index.js"
} If your library doesn't use "real" ESM (so uses Flow/JSX/Typescript) you have to transpile it twice (to esm & cjs). |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I read through the README and have found several issues on here which touch on the issue but I'm still not getting a clear explanation. I'm pretty new to this also.
I have written a library in ES6 and I have an app which uses that library, and am using parcel to build the app.
_classCallCheck
_iterableToArray
_arrayWithHoles
etc... all show up multiple times in the bundle.I understand that parcel doesn't apply transformations to code imported from node_modules (unless you specify things somewhere?)
I understand that those functions show up because parcel essentially concatenates bundles from resources, and in this case those resources are files that were individually transpiled by babel, so each one of them has the polyfills it needs.
What I'm really not clear on is how to get around this:
_classCallCheck
will be added once for the library and once for the app)How do other projects deal with this? As you can see I'm a bit limited in my understanding of babel/node.
Thanks :-)
Beta Was this translation helpful? Give feedback.
All reactions