date-holidays-parser icon indicating copy to clipboard operation
date-holidays-parser copied to clipboard

Syntax error on non-CommonJS import

Open fujikky opened this issue 3 years ago • 3 comments

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

fujikky avatar Mar 01 '22 01:03 fujikky

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

ianonymousdev avatar Mar 07 '22 11:03 ianonymousdev

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",
  },
},

fujikky avatar Mar 07 '22 13:03 fujikky

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.

ianonymousdev avatar Mar 07 '22 23:03 ianonymousdev