commenthol / date-holidays-parser

parser for worldwide holidays
ISC License
46 stars 22 forks source link

Syntax error on non-CommonJS import #45

Open fujikky opened 2 years ago

fujikky commented 2 years ago

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

v3.2.4 https://unpkg.com/date-holidays-parser@3.2.4/lib/vsop87Bearth.cjs

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

v3.3.0 https://unpkg.com/date-holidays-parser@3.3.0/lib/vsop87Bearth.cjs

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

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

image
ianonymousdev commented 2 years ago

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

fujikky commented 2 years ago

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 commented 2 years ago

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.