cron-validate icon indicating copy to clipboard operation
cron-validate copied to clipboard

ReferenceError: exports is not defined in ES module scope

Open the-other-dev opened this issue 10 months ago • 5 comments

When upgrading from version 1.4.5 to 1.5.0 I get an error when trying to import the module.

I am using import cron from 'cron-validate' to import the module. My project is set up as a module ("type": "module" in the package.json) and my tsconfig.json sets the following things:

        "target": "ESNext",
        "lib": ["ES2019", "DOM"],
        "module": "ESNext",
        "moduleResolution": "node",
        "esModuleInterop": true,

The full error message is:

ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and './node_modules/cron-validate/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
 ❯ node_modules/cron-validate/lib/index.js:5:23

I assume it has something to do with the tsconfig.json in this repository declaring "module": "commonjs" (https://github.com/Airfooox/cron-validate/blob/master/tsconfig.json#L8) and declaring it a module in the package.json: https://github.com/Airfooox/cron-validate/blob/master/package.json#L38

The change to "type": "module" came with this commit: https://github.com/Airfooox/cron-validate/commit/532fedbb8656cf3cb672c551689daed57ca23266

In version 1.4.5 the import works without issues.

the-other-dev avatar Mar 14 '25 07:03 the-other-dev

Yes, that is the current expectation!, When you are switching the tab the state will gets changed to the default value of that selected value. It does not know what was selected previously!

sojinantony01 avatar Mar 04 '25 14:03 sojinantony01