Add externalBuiltins
option or make them external by default.
#146
Comments
Hm, please correct me if I'm wrong - maybe I'm not understanding the problem - but rollup-plugin-node-resolve/src/index.js Lines 172 to 173 in 7846a19
In fact with a small repo using your first config, I get the following output: $ rollup -c rollup.config.js
src/index.js → build/server.js...
(!) Unresolved dependencies
https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency
fs (imported by index.js)
created build.js in 15ms
$ cat build/server.js
'use strict';
var fs = require('fs');
console.log(fs.readFile('x')); |
Yes, but it gives you a warning for each builtin that users have to silence by filling the if ( ~builtins.indexOf( resolved ) ) {
fulfil( externalBuiltins ? false : null ); making use of the fact the |
Adding an option just to silence a warning seems - to me - that it does not really meet the complexity-benefit-tradeoff; as you've demonstrated it certainly would be a simple change to implement but another option to document and more complexity inherited by people consuming the plugin. We could instead look to document how to acheive this without changes to this code: import resolve from 'rollup-plugin-node-resolve';
import builtins from 'builtin-modules'
export default ({
input: 'src/index.js',
plugins: [resolve()],
externals: builtins,
output: {
file: 'build/server.js',
format: 'cjs'
}
}) |
Yes, the alternative would be to add this example to the documentation. |
This is definitely useful, great suggestion! Could also be worth considering if this should be a more generic |
Anything new on this subject? How do you do it at the moment, you add all the built-ins to external? |
Also interested in this |
Any updates? |
@mmomtchev @franhaselden @mecurc please take a look at #146 (comment); providing |
This is a proposal in response to https://twitter.com/SavePointSam/status/975146310855622656
At the moment if someone wants to bundle everything but keep builtins as external dependencies, they have to do something like this:
i.e. they have to list all builtins manually in their externals list (and adapt this manually in the future). My feeling is that
rollup-plugin-node-resolve
already has the necessary dependencies to trivially implement an optionexternalBuiltins
to do that for the user, i.e. the example could becomeWould like some feedback before preparing a PR (maybe this is already possible in some way?)
cc @keithamus, @guybedford
The text was updated successfully, but these errors were encountered: