Replies: 3 comments 4 replies
-
Try add type="module" to your script tag <script type="module" src="main.js"> |
Beta Was this translation helpful? Give feedback.
-
Hi, However, modern browsers do support ES6 modules. So if you really want to import a module into your browser, you can add an option to create one in your package.json: {
"name": "my-library",
"version": "1.0.0",
"source": "src/index.js",
"main": "dist/main.js",
+ "module": "dist/modern.main.js", // this will create an ES6 module in modern.main.js
"devDependencies": {
"parcel": "latest"
}
} And, as @windheart pointed out, import modern.main.js with |
Beta Was this translation helpful? Give feedback.
-
Was this issue resolved? I'm not able to import the exported functions from the bundled js file |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am trying to build a js library using ES6 and parcel. I am new to bundlers and I found parcel to be easiest to setup.
I followed this guide https://parceljs.org/getting-started/library/
but when I try to include main.js into HTML with normal script tag like this
I am getting error
main.js:5 Uncaught ReferenceError: module is not defined
at main.js:5
Also, main.js is not minified, it looks like this
What am I doing wrong?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions