Hi! This is a really cool project you have here and I'd love to use it.
However, when I install it, it crashes upon use.
When I try to require() it in CJS, I get:
> require('./vendordeps/jsonm')
Uncaught:
Error [ERR_REQUIRE_ESM]: require() of ES Module ~/projects/project/jsonm/dist/index.cjs.js not supported.
index.cjs.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 index.cjs.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 ~/projects/project/vendordeps/jsonm/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
When I try to import() it in ESM, I get:
> import('./vendordeps/jsonm')
Promise {
<pending>,
[Symbol(async_id_symbol)]: 113,
[Symbol(trigger_async_id_symbol)]: 5,
[Symbol(destroyed)]: { destroyed: false }
}
> Uncaught:
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '~/projects/project/vendordeps/jsonm' is not supported resolving ES modules imported from ~/projects/project/repl
Did you mean to import ../vendordeps/jsonm/dist/index.cjs.js?
After fiddling with module types and package.json a bit, it also indicates promisie has the same build issue.
This seems to occur on all versions.
My suggested fix would be removing "type": "module" from package.json in this package, @jsonstack/model and promisie. I can confirm through testing that this fixes the first issue.
After that, there's an error in the built CJS file.
Uncaught TypeError: Object prototype may only be an Object or null: undefined
at Function.create (<anonymous>)
at Object.inherits (~/projects/ai-stuff/vendordeps/jsonm/dist/index.cjs.js:47792:29)
at Object.<anonymous> (~/projects/ai-stuff/vendordeps/jsonm/dist/index.cjs.js:50626:8)
If I can help, please let me know.
Have a nice day!
Hi! This is a really cool project you have here and I'd love to use it.
However, when I install it, it crashes upon use.
When I try to
require()it in CJS, I get:When I try to
import()it in ESM, I get:After fiddling with module types and
package.jsona bit, it also indicatespromisiehas the same build issue.This seems to occur on all versions.
My suggested fix would be removing
"type": "module"frompackage.jsonin this package,@jsonstack/modelandpromisie. I can confirm through testing that this fixes the first issue.After that, there's an error in the built CJS file.
If I can help, please let me know.
Have a nice day!