vercel / ncc

Compile a Node.js project into a single file. Supports TypeScript, binary addons, dynamic requires.
https://npmjs.com/@vercel/ncc
MIT License
9.25k stars 287 forks source link

Is there any tree-shaking strategy? #1055

Open SandZn opened 1 year ago

SandZn commented 1 year ago

Hi, is there any tree-shaking strategy in ncc, like what bundlers do on front-end applications? I wonder how do you deal with the dynamic "require" while compiling. Thank you.

cerjs commented 1 year ago

Meet the same question. Ncc always ignore process.env.NODE_ENV == production, and build all.

BenJackGill commented 1 year ago

+1

Tree shaking would be fantastic.

gregg-cbs commented 1 month ago

I have noticed that if i import from a package like this: import {find as event_find} from "event";

The whole package gets bundled. All the methods that I am not using from the 'event' package are getting bundled too.