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

Syntax error on non-CommonJS import #45

Open
fujikky opened this issue Mar 1, 2022 · 3 comments
Open

Syntax error on non-CommonJS import #45

fujikky opened this issue Mar 1, 2022 · 3 comments

Comments

@fujikky
Copy link

fujikky commented Mar 1, 2022

As of v3.3.0, the import destination for astronomia in vsop87Bearth.cjs seems to have changed.

v3.2.4
https://unpkg.com/[email protected]/lib/vsop87Bearth.cjs

var _vsop87Bearth = require('astronomia/lib/data/vsop87Bearth.cjs');

v3.3.0
https://unpkg.com/[email protected]/lib/vsop87Bearth.cjs

var _vsop87Bearth = require('astronomia/data/vsop87Bearth');

This caused syntax errors in module systems that use CJS, such as Jest.
image

@ianonymousdev
Copy link

Hey, I believe I am also facing this issue but with NodeJs. Did you manage to solve this?

@fujikky
Copy link
Author

fujikky commented Mar 7, 2022

My Jest problem was solved by adding moduleNameMapper as a workaround.

jest.config.js:

moduleNameMapper: {
  "astronomia\\/data\\/vsop87Bearth": "astronomia/lib/data/vsop87Bearth.cjs",
},

If you are using webpack, you may be able to fix it by adding the same settings to resolve.alias in the config.

resolve: {
  alias: {
    "astronomia/data/vsop87Bearth": "astronomia/lib/data/vsop87Bearth.cjs",
  },
},

@ianonymousdev
Copy link

Thanks @fujikky. I am using Node with Next.js and not sure how to configure that to get rid of the problem. However, last night I upgraded Node version to 14.x and that seems to have fixed the problem.

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