From 9b1686f7e503c0fa30bfb43608ab859d32178c93 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Fri, 14 Sep 2018 00:17:33 +0100 Subject: [PATCH] Make removal of the 'polyfills' option more obvious Support for the preset option `polyfills.babel` was removed in #315 (Neutrino 7), leaving just `polyfills.async` which was removed in #790. --- packages/library/index.js | 4 ++++ packages/library/test/library_test.js | 7 +++++++ packages/node/index.js | 4 ++++ packages/node/test/node_test.js | 7 +++++++ packages/web/index.js | 4 ++++ packages/web/test/web_test.js | 7 +++++++ 6 files changed, 33 insertions(+) diff --git a/packages/library/index.js b/packages/library/index.js index ae1cf9766..4efaf7110 100644 --- a/packages/library/index.js +++ b/packages/library/index.js @@ -10,6 +10,10 @@ module.exports = (neutrino, opts = {}) => { throw new Error('Missing required preset option "name". You must specify a library name when using this preset.'); } + if ('polyfills' in opts) { + throw new Error('The polyfills option has been removed, since polyfills are no longer included by default.'); + } + const options = merge({ target: 'web', libraryTarget: 'umd', diff --git a/packages/library/test/library_test.js b/packages/library/test/library_test.js index 94f7672b1..b298fd71b 100644 --- a/packages/library/test/library_test.js +++ b/packages/library/test/library_test.js @@ -28,6 +28,13 @@ test('throws when missing library name', t => { t.true(err.message.includes('You must specify a library name')); }); +test('throws when polyfills defined', async t => { + const api = new Neutrino(); + + const err = t.throws(() => api.use(mw(), { name: 'alpha', polyfills: {} })); + t.true(err.message.includes('The polyfills option has been removed')); +}); + test('valid preset production', t => { process.env.NODE_ENV = 'production'; const api = new Neutrino(); diff --git a/packages/node/index.js b/packages/node/index.js index 9ba0e64a4..d4df4284f 100644 --- a/packages/node/index.js +++ b/packages/node/index.js @@ -20,6 +20,10 @@ const getOutputForEntry = entry => basename( ); module.exports = (neutrino, opts = {}) => { + if ('polyfills' in opts) { + throw new Error('The polyfills option has been removed, since polyfills are no longer included by default.'); + } + const pkg = neutrino.options.packageJson; const sourceMap = (pkg && pkg.dependencies && pkg.dependencies['source-map-support']) || pkg && pkg.devDependencies && pkg.devDependencies['source-map-support'] || diff --git a/packages/node/test/node_test.js b/packages/node/test/node_test.js index e1e402a2c..aaad52461 100644 --- a/packages/node/test/node_test.js +++ b/packages/node/test/node_test.js @@ -75,3 +75,10 @@ test('valid preset development', t => { const errors = validate(config); t.is(errors.length, 0); }); + +test('throws when polyfills defined', async t => { + const api = new Neutrino(); + + const err = t.throws(() => api.use(mw(), { polyfills: {} })); + t.true(err.message.includes('The polyfills option has been removed')); +}); diff --git a/packages/web/index.js b/packages/web/index.js index 73d9e7204..3486d571f 100644 --- a/packages/web/index.js +++ b/packages/web/index.js @@ -58,6 +58,10 @@ module.exports = (neutrino, opts = {}) => { throw new Error('The minify.style option has been removed. To enable style minification use the @neutrinojs/style-minify preset.'); } + if ('polyfills' in options) { + throw new Error('The polyfills option has been removed, since polyfills are no longer included by default.'); + } + if (typeof options.devtool === 'string' || typeof options.devtool === 'boolean') { options.devtool = { development: options.devtool, diff --git a/packages/web/test/web_test.js b/packages/web/test/web_test.js index 5b50bf870..65e319d61 100644 --- a/packages/web/test/web_test.js +++ b/packages/web/test/web_test.js @@ -260,3 +260,10 @@ test('throws when minify.style defined', async t => { const err = t.throws(() => api.use(mw(), { minify: { style: false } })); t.true(err.message.includes('The minify.style option has been removed')); }); + +test('throws when polyfills defined', async t => { + const api = new Neutrino(); + + const err = t.throws(() => api.use(mw(), { polyfills: {} })); + t.true(err.message.includes('The polyfills option has been removed')); +});