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
I need to be able to bundle .node files (C++ Addons).
I'm fine if this is immediately closed because of #3733, but because adapter-node no longer uses esbuild I'm not sure if my comment on that issue is relevant.
Describe the proposed solution
My knowledge in rollup and esbuild are quite lacking, but here is an esbuild plugin that would theoretically solve the problem. Since adapter-node switched to rollup from esbuild this isn't exactly a solution, but I've included it for reference since I don't know what else to do.
Alternatives considered
I've gotten the C++ addon I'm using to work by putting it in dependencies so it gets skipped for bundling. Then you can simply run node build to run and it works just fine on my local machine. So theoretically, for deployment, one could produce the build (with C++ addons in dependencies so they aren't bundled) and then install the non-bundled dependencies wherever the build gets deployed.
The packages in question should go in dependencies — these will be ignored by esbuild. I'm not sure there's anything we need to do beyond that? Packages in dependencies (as opposed to devDependencies) are supposed to be installed wherever you run the deployment
I believe my error was in thinking C++ addons were somehow portable in a way they could be bundled in any node application to be deployed anywhere so I was searching for a way to make bundling work with them. But that's not the case since the addons are compiled for specific architecture which happens on installation with tools such as node-gyp. Due to my ignorance this is a best guess, anyway.
So to conclude - my "alternative" is the correct way of handling C++ addons and I just figured it out through roundabout trial and error 😆
Describe the problem
I need to be able to bundle
.node
files (C++ Addons).I'm fine if this is immediately closed because of #3733, but because adapter-node no longer uses esbuild I'm not sure if my comment on that issue is relevant.
Describe the proposed solution
My knowledge in rollup and esbuild are quite lacking, but here is an esbuild plugin that would theoretically solve the problem. Since adapter-node switched to rollup from esbuild this isn't exactly a solution, but I've included it for reference since I don't know what else to do.
Alternatives considered
I've gotten the C++ addon I'm using to work by putting it in
dependencies
so it gets skipped for bundling. Then you can simply runnode build
to run and it works just fine on my local machine. So theoretically, for deployment, one could produce the build (with C++ addons independencies
so they aren't bundled) and then install the non-bundleddependencies
wherever the build gets deployed.Importance
would make my life easier
Additional Information
Specifically I'm using Azure's MSAL Node extensions for account caching.
The
node-resolve
rollup plugin docs state the default for the extensions configuration includes.node
files. I don't know why.node
files don't work out of the box since adapter-node uses this plugin.Here is a reproduction repo. All I did was install
adapter-node
and@azure/msal-node-extensions
as well as using it insrc/routes/+page.server.js
.For the "Alternatives considered" here's what I did:
pnpm run build
and copy thebuild
directory out somewhere else on my local machinebuild
was copied to, also copypackage.json
(I deleted all thedevDependencies
but I doubt that's necessary)pnpm i
in the same directory to installdependencies
node build
to run the applicationHere's some example output:
The
false
coming through the console when I navigate tolocalhost:3000
is from this line and it isfalse
, as expected, since I ran this on a mac.The text was updated successfully, but these errors were encountered: