Closed Mikescops closed 2 months ago
pkg tries to do it's best to guess the files he needs but this is hard to do so I don't see many ways to improve this on pkg side. What you could do is to create a script to do the package and simply move away files before the pkg process and move them back after it finishes
Don't you think blocked glob patterns could be a nice way to handle this? That way when the analyzer encounters a file it checks it against the block list and ignore the files if it matches one of the patterns.
Yeah but I have no time to implement such feature right now. Want to submit a PR?
I would call it like ignore
and will be an array of glob like scripts and assets
I can give it a try when I have some times too yes, ignore
seems fair yep
Still have cases with packages using prebuildify packaging the binaries for all platforms instead of just the built platform, should I open another issue about that?
Actually this is due to https://github.com/yao-pkg/pkg/blob/main/prelude/bootstrap.js#L2235
Reason described in the comment above that line and I think there is no easy fix for that
See ref issue: https://github.com/vercel/pkg/issues/1075
What version of pkg are you using?
5.11.5
What version of Node.js are you using?
18.x
What operating system are you using?
macOS
What CPU architecture are you using?
M2
What Node versions, OSs and CPU architectures are you building for?
any
Describe the Bug
Hello,
I'm trying to optimize how my native modules are loaded into the virtual filesystem. I know I could use esbuild, but so far I've only came across hacky ways of bundling .node with it, because there are several ways of doing them between bindings, node-gyp, napi-rs...
The way pkg does it seems fair to me and is less likely to create side effects as it follows the same structure as the node_modules folder.
My issue is that for better-sqlite3, that is working well when packaged with pkg, I end up with all the build files (cpp and c) being added in the final VFS. (https://github.com/WiseLibs/better-sqlite3)
If I use the debug command to explore the VFS, this is what I see:
When looking at the debug logs I figured out that the files are being included because when pkg reads the
package.json
it sees this:Expected Behavior
The builds files (.c and .cpp) could be excluded from the final build.
I'm not sure what's the best solution here:
To Reproduce
Create a sample project that uses better-sqlite3 or use our open source project that uses it: https://github.com/Dashlane/dashlane-cli