duetds / date-picker

Duet Date Picker is an open source version of Duet Design System’s accessible date picker. Try live example at https://duetds.github.io/date-picker/
https://www.duetds.com
MIT License
1.73k stars 68 forks source link

"Uncaught SyntaxError: Cannot use import statement outside a module" error while using parcel v2 #105

Open Berava opened 2 years ago

Berava commented 2 years ago

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:

Capture d’écran 2022-05-13 à 10 30 19
<script type="module" src="https://cdn.jsdelivr.net/npm/@duetds/date-picker@1.4.0/dist/duet/duet.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@duetds/date-picker@1.4.0/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 !