You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When bundling with rollup and exporting ESM code (rollupConfig.output.format == 'es'), the rollup-plugin-natives outputs .node dependencies as require: var cpufeatures = require("./cpufeatures.node"); which causes ReferenceError: require is not defined in ES module scope, you can use import instead at runtime.
Additionally, node ESM doesn't support ".node" imports natively (see nodejs/node#40541 )
Workaround I used is appending import { createRequire } from 'module'; const require = createRequire(import.meta.url); at the top of the bundle file.
Something similar could be implemented in the meantime until ESM actually supports native imports
The text was updated successfully, but these errors were encountered:
When bundling with rollup and exporting ESM code (
rollupConfig.output.format == 'es'
), the rollup-plugin-natives outputs .node dependencies as require:var cpufeatures = require("./cpufeatures.node");
which causesReferenceError: require is not defined in ES module scope, you can use import instead
at runtime.Additionally, node ESM doesn't support ".node" imports natively (see nodejs/node#40541 )
Workaround I used is appending
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
at the top of the bundle file.Something similar could be implemented in the meantime until ESM actually supports native imports
The text was updated successfully, but these errors were encountered: