lightship
lightship copied to clipboard
Does not generate valid cjs
The current version does not generate a valid CommonJS distribution. This is because the tsconfig file for the cjs does not override the defaults for the module
value:
// tsconfig.build-cjs.json
{
"compilerOptions": {
"noEmit": false,
"outDir": "dist/cjs"
},
"extends": "./tsconfig.json",
"include": [
"src"
]
}
this can be fixed by setting compilerOptions.module
to CommonJS
Same here
This will actually not work entirely. The reason is that when setting type: "module"
, also the generated CJS files need to have the .cjs
extension instead of .js
as it will generate as of now. Even if the file extension is adjusted, the dependency to serialize-error
(which is a pure ESM module only), will prevent this from working. I guess with the dependency to serialize-error
, generating a CJS distribution is pointless in the first place.
using version 9.0.3
of lightship I get this error:
Error [ERR_REQUIRE_ESM]: require() of ES Module /my-project/node_modules/lightship/dist/cjs/index.js from /my-project/plugins/lightship/index.js not supported. /my-project/node_modules/lightship/dist/cjs/index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename /my-project/node_modules/lightship/dist/cjs/index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /my-project/node_modules/lightship/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
Same Here
Our company is also affected by this and we'd highly appreciate seeing this fixed as soon as possible. Thanks in advance :)