force-graph
force-graph copied to clipboard
bezier-js dep not commonjs compatible?
package versions
force-graph: "1.35.0"
bezier-js "3.0.2"
steps to reproduce
node ../../node_modules/force-graph/dist/force-graph.common.js
internal/modules/cjs/loader.js:1031
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/xyz/Development/lavamoat/node_modules/bezier-js/dist/bezier.js
require() of ES modules is not supported.
require() of /home/xyz/Development/lavamoat/node_modules/bezier-js/dist/bezier.js from /home/xyz/Development/lavamoat/node_modules/force-graph/dist/force-graph.common.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename bezier.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/xyz/Development/lavamoat/node_modules/bezier-js/package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1031:13)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/xyz/Development/lavamoat/node_modules/force-graph/dist/force-graph.common.js:13:16)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14) {
code: 'ERR_REQUIRE_ESM'
}
lavamoat/packages/tofu on perf-moar [$✘!+?] is 📦 v5.1.1 via ⬢ v12.19.0
⇡0% ➜ npx browserify ../../node_modules/force-graph/dist/force-graph.common.js
/home/xyz/Development/lavamoat/node_modules/bezier-js/dist/bezier.js:2236
export { Bezier };
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
introduced here https://github.com/vasturiano/force-graph/commit/3d9703c466c8f555c8bc5a6a710f2a9fd6ef6718
[email protected] works
@kumavis this is related to the recent version of bezier-js. If you are having issues importing that library, please mention a new issue in that repo.
I opened an issue with bezier-js
but also here because your commonjs distributable force-graph/dist/force-graph.common.js is now not commonjs compatible
@kumavis ok thanks for that. I've published a new version of this module that includes bezier-js latest patch, so it should be fixed. Let me know if you experience any further issues.
same issue with [email protected]
@vasturiano PR'd a potential solution for bezierjs https://github.com/Pomax/bezierjs/pull/138
Same problem here. I tried the versions 1.35.1, 1.35.2, 1.36.2 and 1.39.2.
Any workarounds for this?
Any workaround for this?