webpack5 > webpack.IgnorePlugin failure
See original GitHub issueBug report
What is the current behavior?
In the process of learning Webpack 5
> webpack5-ignoreplugin@1.0.0 build
> webpack
asset main.js 628 KiB [emitted] (name: main) 1 related asset
runtime modules 1020 bytes 4 modules
modules by path ./node_modules/moment/dist/locale/*.js 407 KiB 135 modules
./src/index.js 300 bytes [built] [code generated]
./node_modules/moment/dist/moment.js 150 KiB [built] [code generated]
./node_modules/moment/dist/locale/ sync ^\.\/.*$ 3.21 KiB [optional] [built] [code generated]
webpack 5.38.1 compiled successfully in 1237 ms
Expectations for main.js <=170kb
If the current behavior is a bug, please provide the steps to reproduce.
// src/index.js
import moment from 'moment'
console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));
// webpack.config.js
const path = require('path')
const webpack = require('webpack');
module.exports = {
mode:'none',
devtool:'source-map',
context:process.cwd(),
entry:'./src/index.js',
output:{
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
resolve: {
modules:['node_modules'],
mainFields:['jsnext:main','main']
},
plugins:[
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
]
}
What is the expected behavior?
ignore
moment>dist>locale
Other relevant information: webpack version: ^5.38.1 Node.js version: v12.16.3 Operating System: mac 10.15.7 Additional tools:
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
IgnorePlugin - webpack
IgnorePlugin prevents the generation of modules for import or require calls matching the regular expressions or filter functions: ...
Read more >Webpack 5 IgnorePlugin - Not ignoring JS file from output on ...
I am using my Webpack file only to create a CSS file. On build, it outputs a JS file. But I don't want...
Read more >webpack/webpack - Gitter
Any idea where to start looking for the cause of this error. ... IgnorePlugin(/packery/) but the resulting bundle has errors in it because...
Read more >How do I ignore an import in webpack? - Reddit
So in fact I would like webpack to ignore completely /opt/nodejs/orm and not even try to pack it. I've tried using the ignore...
Read more >Webpack: ignore module - remarkablemark
ts file is there which loads the module lazily but IgnorePlugin is not working as expected can you help on the same.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, there are some problems mentioned above, should be increased
I will send a PR later
Thanks @myNameIsDu . I was intentionally not escaping the periods, but I should have added a glob, and you’re right that my regex probably should include escaped periods to be more specific: (i.e.
/.*\.test(\.).*(ts|tsx)$/
) Here’s what I’m running:Seems to work with Webpack 4, but build fails with Webpack 5 enabled:
I assume this means that the modified Webpack config didn’t add up to a proper array in some regard, but I’m not sure.