Closed arthuro555 closed 3 years ago
As far as I understand you cannot use import
with Node addons in the first place, so that's not valid.
You need to use require()
, either with CJS or module.createRequire()
. Microbundle works just fine if you use require()
.
Ah, indeed, my mistake sorry for that. I thought import
used the same mechanic as require
for node modules. I'll close this as it is invalid to use imports that way indeed.
Hello 👋
I am making a native addon that requires some wrapper code in javascript. I thought I'd use microbundle to bundle this code, but I went into an issue. You see, to use the native module, one needs to import it. A common way to do so is using node imports, like this:
The problem is that microbundle does not catch onto the fact that it is a native module (
.node
file extension) and tries to parse it as normal JavaScript:Would it be possible to add such files as "external" automatically, so that they go through Node's require system instead of being bundled in?
EDIT: If you are looking at this issue wondering if you can still use native modules, to be clear, you can still use something like
bindings
orprocess.dlopen
to import it not using the module system. I opened this issue because it would be nice to be able to use that other subjectively cleaner way.