webpack serve compiling twice with a specific dependency package.json
See original GitHub issueBug report
What is the current behavior?
Webpack is compiling the project twice, when running in serve mode, if the project imports a library with the following package.json
main
config:
"main": "./lib/",
If the current behavior is a bug, please provide the steps to reproduce.
- Open https://stackblitz.com/edit/webpack-double-compilation
- Run
npm start
- Notice that compilation is run twice on start:
webpack 5.38.1 compiled successfully in 649 ms
...
webpack 5.38.1 compiled successfully in 54 ms
This will fix the problem:
- Open
webpack.config.js
- Add the commented
sdp-transform
alias - Run
npm start
again - Notice that compilation is run once only:
webpack 5.38.1 compiled successfully in 588 ms
You can also test this locally following this steps:
- Install
sdp-transform
as a dependency - Import
sdp-transform
in an entry point - Run
webpack serve
- Notice that the compilation is now run twice
What is the expected behavior?
Compilation should only run once.
Other relevant information: webpack version: 5.38.1 and 5.37.1 Node.js version: v14.16.0 and v14.17.0 Operating System: stackblitz OS (?) and Windows 10 Additional tools: none
Issue Analytics
- State:
- Created 2 years ago
- Comments:25 (17 by maintainers)
Top Results From Across the Web
webpack serve compiling twice with a specific dependency ...
Webpack is compiling the project twice, when running in serve mode, if the project imports a library with the following package.json main config ......
Read more >webpack-dev-server runs twice - Stack Overflow
I realised that I had webpack-dev-server package installed twice, one in my project folder node_modules since it was listed as dependency in my ......
Read more >sass-loader - webpack - JS.ORG
The special implementation option determines which implementation of Sass to use. By default the loader resolve the implementation based on your dependencies.
Read more >Serverless Webpack - Serverless Framework: Plugins
A Serverless Framework plugin to build your lambda functions with Webpack. ... must appear in your service's production dependencies in package.json .
Read more >webpack Tutorial: How to Set Up webpack 5 From Scratch
the webpack-dev-server command is now webpack-serve ... In package.json , we can make a build script that runs the webpack command.
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
I think I am experiencing the same issue with storybook webpack5 doing a build twice
I think resolver try to watch something wrong, I do not look it deeply, but if you change
"main": "./lib/index.js"
(i.e.index.js
) all works fine, anyway using"main": "./lib/"
is working in commonjs Node.js, because by default we try to loadindex.js
in directly, it is very intresting, because no RFC or something else about it, it s just side effect built-in Node.js commonjs loader