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

Cannot use the package with Vike #806

Closed
vitalybaev opened this issue Apr 5, 2024 · 0 comments · Fixed by #821
Closed

Cannot use the package with Vike #806

vitalybaev opened this issue Apr 5, 2024 · 0 comments · Fixed by #821

Comments

@vitalybaev
Copy link
Contributor

When you try to import @reatom/core in Vike (formerly vite-ssr-plugin) project, I've got an error:

SyntaxError: Unexpected token 'export'
...
┌────────────────────────────────────────────────────────────────────────────────┐
│ The error seems to be a CJS/ESM issue, see https://vike.dev/broken-npm-package │
└────────────────────────────────────────────────────────────────────────────────┘

There is a workaround, described on https://vike.dev/broken-npm-package page, but IMO the Reatom should just work.

Playground

CodeSandbox

BANOnotIT added a commit that referenced this issue Apr 20, 2024
fix(async): bundler esm import
fix(core-v1): bundler esm import
fix(core): bundler esm import
fix(effects): bundler esm import
fix(eslint-plugin): bundler esm import
fix(form-web): bundler esm import
fix(form): bundler esm import
fix(framework): bundler esm import
fix(hooks): bundler esm import
fix(jsx): bundler esm import
fix(lens): bundler esm import
fix(logger): bundler esm import
fix(npm-cookie-baker): bundler esm import
fix(npm-history): bundler esm import
fix(npm-lit): bundler esm import
fix(npm-react): bundler esm import
fix(npm-solid-js): bundler esm import
fix(npm-svelte): bundler esm import
fix(npm-vue): bundler esm import
fix(persist-web-storage): bundler esm import
fix(persist): bundler esm import
fix(primitives): bundler esm import
fix(react-v1): bundler esm import
fix(testing): bundler esm import
fix(timer): bundler esm import
fix(undo): bundler esm import
fix(url): bundler esm import
fix(utils): bundler esm import
fix(web-fetch): bundler esm import
fix(web): bundler esm import

Reatom used to use package.json#module field to declare esm modules.
Turns out it was only in draft spec and never was standardized.
So instead of relying on non-standard behaviour we use .mjs which is
standard nodejs mechanizm.

Should fix #816 #806 #573
@BANOnotIT BANOnotIT linked a pull request Apr 20, 2024 that will close this issue
artalar pushed a commit that referenced this issue Jun 14, 2024
* test: add reproduction repo for module export

Repo is copied from #816 inside to test in future

* fix(all-settled): bundler esm import
fix(async): bundler esm import
fix(core-v1): bundler esm import
fix(core): bundler esm import
fix(effects): bundler esm import
fix(eslint-plugin): bundler esm import
fix(form-web): bundler esm import
fix(form): bundler esm import
fix(framework): bundler esm import
fix(hooks): bundler esm import
fix(jsx): bundler esm import
fix(lens): bundler esm import
fix(logger): bundler esm import
fix(npm-cookie-baker): bundler esm import
fix(npm-history): bundler esm import
fix(npm-lit): bundler esm import
fix(npm-react): bundler esm import
fix(npm-solid-js): bundler esm import
fix(npm-svelte): bundler esm import
fix(npm-vue): bundler esm import
fix(persist-web-storage): bundler esm import
fix(persist): bundler esm import
fix(primitives): bundler esm import
fix(react-v1): bundler esm import
fix(testing): bundler esm import
fix(timer): bundler esm import
fix(undo): bundler esm import
fix(url): bundler esm import
fix(utils): bundler esm import
fix(web-fetch): bundler esm import
fix(web): bundler esm import

Reatom used to use package.json#module field to declare esm modules.
Turns out it was only in draft spec and never was standardized.
So instead of relying on non-standard behaviour we use .mjs which is
standard nodejs mechanizm.

Should fix #816 #806 #573

* fix(new-package-template): use mjs in module export

* test: implement cjs and esm check test

* chore: install test files
artalar added a commit that referenced this issue Jun 22, 2024
pull request #821

test: add reproduction repo for module export

Repo is copied from #816 inside to test in future

fix(all-settled): bundler esm import
fix(async): bundler esm import
fix(core-v1): bundler esm import
fix(core): bundler esm import
fix(effects): bundler esm import
fix(eslint-plugin): bundler esm import
fix(form-web): bundler esm import
fix(form): bundler esm import
fix(framework): bundler esm import
fix(hooks): bundler esm import
fix(jsx): bundler esm import
fix(lens): bundler esm import
fix(logger): bundler esm import
fix(npm-cookie-baker): bundler esm import
fix(npm-history): bundler esm import
fix(npm-lit): bundler esm import
fix(npm-react): bundler esm import
fix(npm-solid-js): bundler esm import
fix(npm-svelte): bundler esm import
fix(npm-vue): bundler esm import
fix(persist-web-storage): bundler esm import
fix(persist): bundler esm import
fix(primitives): bundler esm import
fix(react-v1): bundler esm import
fix(testing): bundler esm import
fix(timer): bundler esm import
fix(undo): bundler esm import
fix(url): bundler esm import
fix(utils): bundler esm import
fix(web-fetch): bundler esm import
fix(web): bundler esm import

Reatom used to use package.json#module field to declare esm modules.
Turns out it was only in draft spec and never was standardized.
So instead of relying on non-standard behaviour we use .mjs which is
standard nodejs mechanizm.

Should fix #816 #806 #573

fix(new-package-template): use mjs in module export

test: implement cjs and esm check test

chore: install test files
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

Successfully merging a pull request may close this issue.

1 participant