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

Import errors with vite project #98

Open
NiloCK opened this issue Apr 28, 2023 · 2 comments · Fixed by #99
Open

Import errors with vite project #98

NiloCK opened this issue Apr 28, 2023 · 2 comments · Fixed by #99
Assignees

Comments

@NiloCK
Copy link
Contributor

NiloCK commented Apr 28, 2023

Describe the bug
vite projects fail to consume js-big-decimal.

To Reproduce
Repro repo is here: https://github.com/NiloCK/vite-bigdecimal-import-reproduction

See the readme.

Expected behavior
In the repo, yarn dev should serve the sample app page, with the counter integer replaced by a bigDecimal.

Additional context
The vite site seems to be mistakenly importing content from the dist/node folder, instead of dist/web

There is some issue with:

  • vite's bundler
  • js-big-decimal's packaging / distribution pipeline
  • some combination of the two
@NiloCK
Copy link
Contributor Author

NiloCK commented Apr 28, 2023

Response from the related issue filed vitejs/vite: vitejs/vite#13031 (comment)

Quoting in full:

The bundled file is from dist/node/..., where it should be from dist/web/....

js-big-decimal doesn't declare exports/browser field and therefore Vite resolves the package with main field that points to dist/node/....

You can specify the actual file instead.

import "js-big-decimal/dist/web/js-big-decimal.js"

Although, It doesn't work because js-big-decimal doesn't support ESM.

Closing as it's working as intended.

@royNiladri
Copy link
Owner

@NiloCK Please validate and close this.

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.

2 participants