chore: ignore some not-used code from node_modules (-9KB)

This commit is contained in:
Roman Hotsiy 2018-03-26 13:55:50 +03:00
parent c3c46e1713
commit 39352e6e4a
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 18 additions and 0 deletions

View File

@ -78,6 +78,11 @@ export default (env: { playground?: boolean; bench?: boolean } = {}, { mode }) =
performance: false, performance: false,
externals: {
esprima: 'esprima',
'node-fetch': 'null',
},
module: { module: {
rules: [ rules: [
{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader' }, { enforce: 'pre', test: /\.js$/, loader: 'source-map-loader' },
@ -123,6 +128,12 @@ export default (env: { playground?: boolean; bench?: boolean } = {}, { mode }) =
template: env.playground ? 'demo/playground/index.html' : 'demo/index.html', template: env.playground ? 'demo/playground/index.html' : 'demo/index.html',
}), }),
new ForkTsCheckerWebpackPlugin(), new ForkTsCheckerWebpackPlugin(),
ignore(/js-yaml\/dumper\.js$/),
ignore(/json-schema-ref-parser\/lib\/dereference\.js/),
new CopyWebpackPlugin(['demo/openapi.yaml']), new CopyWebpackPlugin(['demo/openapi.yaml']),
], ],
}); });
function ignore(regexp) {
return new webpack.NormalModuleReplacementPlugin(regexp, require.resolve('lodash/noop.js'));
}

View File

@ -55,6 +55,7 @@ export default (env: { standalone?: boolean } = {}, { mode }) => ({
: (context, request, callback) => { : (context, request, callback) => {
// ignore node-fetch dep of swagger2openapi as it is not used // ignore node-fetch dep of swagger2openapi as it is not used
if (/node-fetch$/i.test(request)) return callback(null, 'var undefined'); if (/node-fetch$/i.test(request)) return callback(null, 'var undefined');
if (/esprima$/i.test(request)) return callback(null, 'var undefined');
return nodeExternals(context, request, callback); return nodeExternals(context, request, callback);
}, },
@ -124,5 +125,11 @@ export default (env: { standalone?: boolean } = {}, { mode }) => ({
}), }),
new ForkTsCheckerWebpackPlugin({ silent: true }), new ForkTsCheckerWebpackPlugin({ silent: true }),
new webpack.BannerPlugin(BANNER), new webpack.BannerPlugin(BANNER),
ignore(/js-yaml\/dumper\.js$/),
ignore(/json-schema-ref-parser\/lib\/dereference\.js/),
], ],
}); });
function ignore(regexp) {
return new webpack.NormalModuleReplacementPlugin(regexp, require.resolve('lodash/noop.js'));
}