-
Notifications
You must be signed in to change notification settings - Fork 5.6k
deno compile
binaries should not include @types/node
in the npm virtual filesystem
#19764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah, we need to get the npm packages from the module graph, then only include those and their descendant deps in the final output. Right now we include everything found in the npm snapshot, which could include extra dependencies found in the lockfile. |
I don't have any npm modules in my code, yet I'm still seeing I'm using Deno v2.1.7 |
It will include whatever is in the lockfile at the moment to make more stuff work, which is not ideal. Follow #27305 for one potential mitigation. |
Is |
@Antman261 maybe if you are using a |
Note that it's somewhat possible to exlude this when using a node_modules directory when using the |
@dsherret I was forwarded to this issue and tried that solution, the compiled binary is still the same size and the module graph shows My command: The only node API I use with my deno project is |
Huh, ok I had to run this absolutely terrible command (basically ensure the symlinks aren't included as well, which seems to cause it to include where they point to): > deno compile --exclude node_modules/.deno/@[email protected]/ --exclude node_modules/.deno/[email protected] --exclude node_modules/@types --exclude node_modules/.deno/node_modules/undici-types main.ts
Compile file:///V:/scratch/main.ts to scratch.exe
Embedded Files
scratch.exe
├── main.ts (313B)
└─┬ node_modules (43.81KB - 43.78KB unique)
├── .bin/* (0B)
├─┬ .deno (43.81KB - 43.78KB unique)
│ ├── .deno.lock (12B)
│ ├── .deno.lock.poll (13B - 1B unique)
│ ├── .setup-cache.bin (429B)
│ ├── [email protected]/* (43.36KB - 43.35KB unique)
│ └── node_modules (0B)
└── chalk --> node_modules/.deno/[email protected]/node_modules/chalk
Files: 47.07KB
Metadata: 1.42KB
Remote modules: 61B It's not pretty, but it works for the time being. You might try running with |
Ok, I figured out the problem I was having. I apparently needed to add the After doing that, the command worked fine. However, I'd ideally not like to make a temp node_modules dir and have this work with just an invocation of |
Uh oh!
There was an error while loading. Please reload this page.
Deno 1.34 added support for npm imports in
deno compile
d binaries by adding a virtual filesystem containing the contents of thenode_modules
folder that gets generated when walking through the modules at compile time. Thisnode_modules
folder should only include npm modules directly imported by Deno modules, as well as their recursive dependencies. However, this virtual filesystem also includes the@types/node
package, even though the compiled binary does not transpile Typescript, let alone typecheck it.This presumably happens because the virtual filesystem is built from the
node_modules
folder built when the module graph is walked through at compile time, which does do typechecking. However, including thenode_modules
folder directly into the vfs just results in unnecessary extra weight in the binary that could be saved with not too much trouble by pruning packages that aren't recursive dependencies of those imported by Deno code.The text was updated successfully, but these errors were encountered: