Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ESM explicitly in package.json #601

Closed
1 task done
snake-poison opened this issue Mar 1, 2022 · 2 comments
Closed
1 task done

Support ESM explicitly in package.json #601

snake-poison opened this issue Mar 1, 2022 · 2 comments

Comments

@snake-poison
Copy link

Confirmation

  • I can confirm this is a feature request for the Vue component instead of ECharts itself.

Details

Looks like the space and standards are moving towards ESM, it'd be cool if this library embraced that by switching to a package.json config that included these lines:

"type": "module",
  "exports": {
    ".": {
      "require": "./dist/index.cjs.js",
      "import": "./dist/index.esm.js",
      "types": "./dist/index.d.ts"
    }
  },

As it stands I'm running into issues using this library as a native module.

Additional context about this issue:

@snake-poison
Copy link
Author

snake-poison commented Mar 1, 2022

Meh, this is a bad suggestion as it would only support ESM. I'll come back with a PR to change the build to explicitly name esm modules .mjs and cjs files .cjs.

@sheremet-va
Copy link

There is actually an issue in Vitest concerning this: vitest-dev/vitest#1452 (basically, Vitest doesn't respect module field, because it's not part of Node resolution scheme, so it imports cjs entry - and even if it did, it would still fail, because Node considers your ESM entry a cjs file, more on that later).

Meh, this is a bad suggestion as it would only support ESM. I'll come back with a PR to change the build to explicitly name esm modules .mjs and cjs files .cjs.

I have a guide on how to support dual packaging (it also explains why exports in your issue description is wrong)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants