Webpack-cli: Redundant \ in webpack.config.js generated by webpack init

Created on 29 Mar 2021  路  4Comments  路  Source: webpack/webpack-cli

Describe the bug

Redundant \ in webpack.config.js generated by webpack init which make the test condition never match.
{ test: /\\.(js|jsx)$/, loader: 'babel-loader', },

What is the current behavior?

babel-loader would't not be matched.

To Reproduce

  1. npm install --save webpack
  2. npx webpack init
  3. check the generated webpack.config.js

Expected behavior

Redundant \ in webpack.config.js

Screenshots

image

Please paste the results of webpack-cli info here, and mention other relevant information

System:
OS: Windows 10 10.0.19041
CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Memory: 15.94 GB / 31.78 GB
Binaries:
Node: 14.15.4 - D:\Work\bin\nodejs\node.EXE
Yarn: 1.19.0 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.6 - D:\Work\bin\nodejs\npm.CMD
Browsers:
Chrome: 89.0.4389.90
Edge: Spartan (44.19041.423.0)
Internet Explorer: 11.0.19041.1
Packages:
html-webpack-plugin: ^5.3.1 => 5.3.1
webpack: ^5.28.0 => 5.28.0
webpack-cli: ^4.6.0 => 4.6.0

Bug

All 4 comments

Thanks

Looking into it.

Running webpack-cli init in a fresh project this week introduces this redundant slash, which results in the following error when attempting to import some affected files:

Module parse failed: Unexpected token (1:36)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

Removing the slash resolves this error. It took me a long time to track down (it's 2am now!) because I never expected the CLI to generate a faulty webpack.config.js. Can this fix be escalated into a release? This seriously harms a new user's experience, if I hadn't used webpack in the past I likely would have tried a different tool today out of frustration. Thank you!

Yep, release will be in near future

Was this page helpful?
0 / 5 - 0 ratings

Related issues

claytonhottinger picture claytonhottinger  路  5Comments

jbottigliero picture jbottigliero  路  5Comments

heyalbert picture heyalbert  路  3Comments

billyjanitsch picture billyjanitsch  路  3Comments

sumukhah picture sumukhah  路  3Comments