jspm / project

Roadmap and management repo for the jspm project
161 stars 8 forks source link

[jspm.dev] How to let it choose `module` as source? #127

Closed hyrious closed 3 years ago

hyrious commented 3 years ago

Even vue3 is imported from the cjs version. Let's see its package.json:

  "main": "index.js",
  "module": "dist/vue.runtime.esm-bundler.js",  // <- why not this?
  "unpkg": "dist/vue.global.js",
  "jsdelivr": "dist/vue.global.js",

Maybe your resolver prefers unpkg over main, but it results in almost no esm being used. Unless the module puts an esm file in unpkg like million (package.json).

Also, exports does not work as expected too. Take a look at this package.json:

  "exports": {
    "node": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.js"
    },
    "default": "./dist/index.mjs" // <- should choose this file
  },
guybedford commented 3 years ago

Thank you so much for posting these @hyrious! Yes you are right there were some issues in the "module" resolution which should be fixed now, please let me know if you notice any more issues.

Originally we did not support the "module" field as that was defined later by Webpack, but I have since come around on it. The full CDN support for this field has been gradually rolling out this year. The other issue with your package was an unrelated bug actually, which I've also fixed.

It's only through posting issues that things improve, so thanks again!