From fecb4ae661c81f8d55bd5c59db6de50d28dfa16a Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Tue, 16 Jun 2020 15:53:18 +0100 Subject: [PATCH] feat: default to not include node globals anf builtins (#578) This PR changes webpack config to not include node globals and built-ins by default. For now theres still a --node flag to allow node globals if needed. `process` is still includes because `readable-stream` will only remove it in v4 https://github.com/nodejs/readable-stream/pull/435 closes https://github.com/ipfs/js-ipfs/issues/2924 BREAKING CHANGE: browser code will NOT have node globals and builtins available. --- cli.js | 6 ++++++ cmds/build.js | 5 ----- cmds/test.js | 5 ----- src/config/webpack.config.js | 4 +++- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cli.js b/cli.js index 8df170ef1..cffd0de03 100755 --- a/cli.js +++ b/cli.js @@ -34,6 +34,12 @@ cli default: false, alias: 'debug' }) + // TODO remove after webpack 5 upgrade + .options('node', { + type: 'boolean', + describe: 'Flag to control if bundler should inject node globals or built-ins.', + default: false + }) .help() .alias('h', 'help') .alias('v', 'version') diff --git a/cmds/build.js b/cmds/build.js index 01b770829..657567411 100644 --- a/cmds/build.js +++ b/cmds/build.js @@ -10,11 +10,6 @@ module.exports = { yargs .epilog(EPILOG) .options({ - node: { - type: 'boolean', - describe: 'Flag to control when to tell the bundler to include node global packages.', - default: true - }, bundlesize: { alias: 'b', type: 'boolean', diff --git a/cmds/test.js b/cmds/test.js index 3f35050af..17caebe88 100644 --- a/cmds/test.js +++ b/cmds/test.js @@ -89,11 +89,6 @@ module.exports = { describe: 'If true, unhandledRejection events will cause tests to fail', type: 'boolean', default: true - }, - node: { - type: 'boolean', - describe: 'Flag to control when to tell the bundler to include node global packages.', - default: true } }) }, diff --git a/src/config/webpack.config.js b/src/config/webpack.config.js index b9a27f427..58e110c1b 100644 --- a/src/config/webpack.config.js +++ b/src/config/webpack.config.js @@ -124,7 +124,9 @@ const base = (env, argv) => { tls: false, child_process: false, console: false, - process: true, // TODO remove this once readable-stream is fixed + // TODO remove this once readable-stream is fixed probably on in v4 + // https://github.com/nodejs/readable-stream/pull/435 + process: true, Buffer: false, setImmediate: false, os: false,