Continuation of few comments on #21.
Even that this is Node oriented, it still should understand module field. That's not against the intent of the project, the output is still node compatible because it is CJS. The module-first is only helping for smaller outputs of the ncc-ed package, because webpack does better tree shaking over ES Modules.
I tried. And it's definitely a thing. Consider the following.
Package foo and package bar. Both are written in ESM. Both have module field. We ncc the bar package (with --minify), which uses only a few things from the foo package. The output of the bar package, won't have the unused things from the foo package. If foo does not have the module field, the bar output includes everything from foo.
If not by default, at least support a flag option for this.
Reproduce: https://github.com/tunnckoCore/ncc-modules
Open the packages/bar/dist/index.js and you won't see the FOO_PKG because it isn't used in bar.
The only local change on node_modules on ncc is just removing the mainFields option. And still, the outputs are node compatible and CJS, so I don't see why not support this thing, by default with the Webpack's default resolving ['module', 'main']. Also, even if everything is written in CJS or package does not have module field Webpack will fallback to main anyway.
Continuation of few comments on #21.
Even that this is Node oriented, it still should understand
modulefield. That's not against the intent of the project, the output is still node compatible because it is CJS. The module-first is only helping for smaller outputs of thencc-ed package, because webpack does better tree shaking over ES Modules.I tried. And it's definitely a thing. Consider the following.
Package
fooand packagebar. Both are written in ESM. Both havemodulefield. Wenccthebarpackage (with--minify), which uses only a few things from thefoopackage. The output of thebarpackage, won't have the unused things from thefoopackage. Iffoodoes not have themodulefield, thebaroutput includes everything fromfoo.If not by default, at least support a flag option for this.
Reproduce: https://github.com/tunnckoCore/ncc-modules
Open the
packages/bar/dist/index.jsand you won't see the FOO_PKG because it isn't used inbar.The only local change on node_modules on
nccis just removing themainFieldsoption. And still, the outputs are node compatible and CJS, so I don't see why not support this thing, by default with the Webpack's default resolving['module', 'main']. Also, even if everything is written in CJS or package does not havemodulefield Webpack will fallback tomainanyway.