From b8f22e7b36cf0180d27e23f69f7620beec140b65 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Fri, 23 Nov 2018 23:04:53 +0000 Subject: [PATCH] Stop adding .wasm to the compile/linting rules Fixes #1179. --- docs/api.md | 4 ++-- docs/creating-presets.md | 6 +++--- packages/airbnb-base/test/airbnb_test.js | 2 +- packages/airbnb/test/airbnb_test.js | 2 +- packages/eslint/test/middleware_test.js | 4 ++-- packages/library/index.js | 9 ++++++++- packages/neutrino/extensions.js | 2 +- packages/neutrino/test/api_test.js | 1 + packages/node/index.js | 9 ++++++++- packages/standardjs/test/standardjs_test.js | 2 +- packages/vue/test/vue_test.js | 2 +- packages/web/index.js | 9 ++++++++- 12 files changed, 37 insertions(+), 15 deletions(-) diff --git a/docs/api.md b/docs/api.md index 42ccc137a..4a98b80d4 100644 --- a/docs/api.md +++ b/docs/api.md @@ -178,7 +178,7 @@ information, inspecting processes, or changing configuration which is helpful fo ### `options.extensions` Informs interested middleware the preferred list of module extensions to support. -By default, `options.extensions` is set to `['wasm', 'mjs', 'vue', 'jsx', 'tsx', 'ts', 'js']`. +By default, `options.extensions` is set to `['mjs', 'jsx', 'js']`. ### `options.packageJson` @@ -303,6 +303,6 @@ without any parameters which fallback to `neutrino.options.extensions`. // resolves to /\.(vue|js)$/ neutrino.regexFromExtensions(['vue', 'js']); -// defaults neutrino.options.extensions which resolves to /\.(wasm|mjs|vue|jsx|tsx|ts|js)$/ +// defaults neutrino.options.extensions which resolves to /\.(mjs|jsx|js)$/ neutrino.regexFromExtensions(); ``` diff --git a/docs/creating-presets.md b/docs/creating-presets.md index 744092b5b..10f8d9ef9 100644 --- a/docs/creating-presets.md +++ b/docs/creating-presets.md @@ -294,11 +294,11 @@ module.exports = { ### `options.extensions` Set the preferred list of module extensions to inform interested middleware. If the option is not set, -Neutrino defaults it to `['wasm', 'mjs', 'vue', 'jsx', 'tsx', 'ts', 'js']`. +Neutrino defaults it to `['mjs', 'jsx', 'js']`. ```js module.exports = neutrino => { - // if not specified, defaults to ['wasm', 'mjs', 'vue', 'jsx', 'tsx', 'ts', 'js'] + // if not specified, defaults to ['mjs', 'jsx', 'js'] neutrino.options.extensions; // overwrites the default list @@ -307,7 +307,7 @@ module.exports = neutrino => { module.exports = { options: { - // extends the default list to ['wasm', 'mjs', 'vue', 'jsx', 'tsx', 'ts', 'js', 'elm'] + // extends the default list to ['mjs', 'jsx', 'js', 'elm'] extensions: ['elm'] } }; diff --git a/packages/airbnb-base/test/airbnb_test.js b/packages/airbnb-base/test/airbnb_test.js index f2bc6345b..5bcbe9c46 100644 --- a/packages/airbnb-base/test/airbnb_test.js +++ b/packages/airbnb-base/test/airbnb_test.js @@ -62,7 +62,7 @@ test('sets defaults when no options passed', t => { api.use(mw()); const lintRule = api.config.module.rule('lint'); - t.deepEqual(lintRule.get('test'), /\.(wasm|mjs|jsx|js)$/); + t.deepEqual(lintRule.get('test'), /\.(mjs|jsx|js)$/); t.deepEqual(lintRule.include.values(), [api.options.source, api.options.tests]); t.deepEqual(lintRule.exclude.values(), []); t.deepEqual(lintRule.use('eslint').get('options'), { diff --git a/packages/airbnb/test/airbnb_test.js b/packages/airbnb/test/airbnb_test.js index dcd92abbd..d47cd738f 100644 --- a/packages/airbnb/test/airbnb_test.js +++ b/packages/airbnb/test/airbnb_test.js @@ -62,7 +62,7 @@ test('sets defaults when no options passed', t => { api.use(mw()); const lintRule = api.config.module.rule('lint'); - t.deepEqual(lintRule.get('test'), /\.(wasm|mjs|jsx|js)$/); + t.deepEqual(lintRule.get('test'), /\.(mjs|jsx|js)$/); t.deepEqual(lintRule.include.values(), [api.options.source, api.options.tests]); t.deepEqual(lintRule.exclude.values(), []); t.deepEqual(lintRule.use('eslint').get('options'), { diff --git a/packages/eslint/test/middleware_test.js b/packages/eslint/test/middleware_test.js index eba1fbf6d..40f0d14b5 100644 --- a/packages/eslint/test/middleware_test.js +++ b/packages/eslint/test/middleware_test.js @@ -118,7 +118,7 @@ test('sets defaults when no options passed', t => { api.use(mw()); const lintRule = api.config.module.rule('lint'); - t.deepEqual(lintRule.get('test'), /\.(wasm|mjs|jsx|js)$/); + t.deepEqual(lintRule.get('test'), /\.(mjs|jsx|js)$/); t.deepEqual(lintRule.include.values(), [api.options.source, api.options.tests]); t.deepEqual(lintRule.exclude.values(), []); t.deepEqual(lintRule.use('eslint').get('options'), { @@ -331,7 +331,7 @@ test('sets only loader-specific defaults if useEslintrc true', t => { api.use(mw(), { eslint: { useEslintrc: true } }); const lintRule = api.config.module.rule('lint'); - t.deepEqual(lintRule.get('test'), /\.(wasm|mjs|jsx|js)$/); + t.deepEqual(lintRule.get('test'), /\.(mjs|jsx|js)$/); t.deepEqual(lintRule.include.values(), [api.options.source, api.options.tests]); t.deepEqual(lintRule.exclude.values(), []); t.deepEqual(lintRule.use('eslint').get('options'), { diff --git a/packages/library/index.js b/packages/library/index.js index d48581b95..409de1e64 100644 --- a/packages/library/index.js +++ b/packages/library/index.js @@ -76,7 +76,14 @@ module.exports = (neutrino, opts = {}) => { .end() .resolve .extensions - .merge(neutrino.options.extensions.concat('json').map(ext => `.${ext}`)) + // Based on the webpack defaults: + // https://webpack.js.org/configuration/resolve/#resolve-extensions + // Keep in sync with the options in the node and web presets. + .merge([ + '.wasm', + ...neutrino.options.extensions.map(ext => `.${ext}`), + '.json' + ]) .end() .end() .node diff --git a/packages/neutrino/extensions.js b/packages/neutrino/extensions.js index 674391b51..a28136f0b 100644 --- a/packages/neutrino/extensions.js +++ b/packages/neutrino/extensions.js @@ -4,7 +4,7 @@ module.exports = { // Modifying a value here should have an accompanying change there as well. // We can't pull in neutrino there as that would potentially give us // conflicting versions in node_modules. - source: ['wasm', 'mjs', 'jsx', 'js'], + source: ['mjs', 'jsx', 'js'], style: ['css', 'less', 'sass', 'scss'], media: [ 'jpg', diff --git a/packages/neutrino/test/api_test.js b/packages/neutrino/test/api_test.js index 17af60214..b0ea3ee8f 100644 --- a/packages/neutrino/test/api_test.js +++ b/packages/neutrino/test/api_test.js @@ -197,6 +197,7 @@ test('creates a webpack config', t => { test('regexFromExtensions', t => { const api = new Neutrino(); + t.is(String(api.regexFromExtensions()), '/\\.(mjs|jsx|js)$/'); t.is(String(api.regexFromExtensions(['js'])), '/\\.js$/'); t.is(String(api.regexFromExtensions(['js', 'css'])), '/\\.(js|css)$/'); t.is(String(api.regexFromExtensions(['worker.js', 'worker.jsx'])), '/\\.(worker\\.js|worker\\.jsx)$/'); diff --git a/packages/node/index.js b/packages/node/index.js index 593cbca82..9e34fcd2a 100644 --- a/packages/node/index.js +++ b/packages/node/index.js @@ -77,7 +77,14 @@ module.exports = (neutrino, opts = {}) => { .end() .resolve .extensions - .merge(neutrino.options.extensions.concat('json').map(ext => `.${ext}`)) + // Based on the webpack defaults: + // https://webpack.js.org/configuration/resolve/#resolve-extensions + // Keep in sync with the options in the web and library presets. + .merge([ + '.wasm', + ...neutrino.options.extensions.map(ext => `.${ext}`), + '.json' + ]) .end() .end() // The default output is too noisy, particularly with multiple entrypoints. diff --git a/packages/standardjs/test/standardjs_test.js b/packages/standardjs/test/standardjs_test.js index 10d3637ae..38e1dc881 100644 --- a/packages/standardjs/test/standardjs_test.js +++ b/packages/standardjs/test/standardjs_test.js @@ -62,7 +62,7 @@ test('sets defaults when no options passed', t => { api.use(mw()); const lintRule = api.config.module.rule('lint'); - t.deepEqual(lintRule.get('test'), /\.(wasm|mjs|jsx|js)$/); + t.deepEqual(lintRule.get('test'), /\.(mjs|jsx|js)$/); t.deepEqual(lintRule.include.values(), [api.options.source, api.options.tests]); t.deepEqual(lintRule.exclude.values(), []); t.deepEqual(lintRule.use('eslint').get('options'), { diff --git a/packages/vue/test/vue_test.js b/packages/vue/test/vue_test.js index 757cc0cce..e19acab54 100644 --- a/packages/vue/test/vue_test.js +++ b/packages/vue/test/vue_test.js @@ -50,7 +50,7 @@ test('updates lint config by default', t => { api.use(mw()); const lintRule = api.config.module.rule('lint'); - t.deepEqual(lintRule.get('test'), /\.(wasm|mjs|jsx|vue|js)$/); + t.deepEqual(lintRule.get('test'), /\.(mjs|jsx|vue|js)$/); t.deepEqual(lintRule.use('eslint').get('options').baseConfig, { env: { browser: true, diff --git a/packages/web/index.js b/packages/web/index.js index 1c525573e..575fa6689 100644 --- a/packages/web/index.js +++ b/packages/web/index.js @@ -206,7 +206,14 @@ module.exports = (neutrino, opts = {}) => { .end() .resolve .extensions - .merge(neutrino.options.extensions.concat('json').map(ext => `.${ext}`)) + // Based on the webpack defaults: + // https://webpack.js.org/configuration/resolve/#resolve-extensions + // Keep in sync with the options in the node and library presets. + .merge([ + '.wasm', + ...neutrino.options.extensions.map(ext => `.${ext}`), + '.json' + ]) .end() .end() .node