date-picker
date-picker copied to clipboard
"Uncaught SyntaxError: Cannot use import statement outside a module" error while using parcel v2
I would like to integrate Duet Date Picker to my project. I am using parcel v2 as a bundler.
Describe the bug I get this error regarding two scripts that I'm trying to load from my index.html file:
<script type="module" src="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/duet.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/duet.js"></script>
The problem only occurs when I'm using Parcel to bundle my code.
package.json file:
{
"name": "my-form",
"version": "1.0.0",
"source": [
"src/index.html"
],
"browserslist": "> 0.5%, last 2 versions, not dead",
"scripts": {
"dev": "parcel",
"build": "parcel build src/*.html",
"format": "prettier --ignore-path ./.gitignore --write \"./**/*.{html,json,js,ts,css}\"",
"format:check": "prettier --ignore-path ./.gitignore --check \"./**/*.{html,json,js,ts,css}\"",
"lint": "eslint --ignore-path ./.gitignore --fix \"./**/*.{js,ts}\"",
"lint:check": "eslint --ignore-path ./.gitignore --quiet \"./**/*.{js,ts}\""
},
"devDependencies": {
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"parcel": "^2.5.0",
"postcss-import": "^14.1.0",
"postcss-plugin": "^1.0.0",
"posthtml-include": "^1.7.3",
"prettier": "^2.6.2"
}
}
To Reproduce When I hit "npm run dev", I get the "Uncaught SyntaxError: Cannot use import statement outside a module" error and the scripts do not load.
Additional context I tried adding a "type": "module" as a top-level attribute to the package.json file but it still doesn't work.
Would really appreciate any help with this issue, thanks in advance !