2

I have tried configuring it multiple ways and reduced the config file to a bare minimal but it always compiles my node_modules folder.

I have tried using a regular expression as seen below, as well as inserting the direct path.

Webpack requires direct paths which I am using instead of the path module for clarity.

Webpack config file

// style-loader and css-loader are both required to handle .css files const css = { test: /\.css$/i, use: ['style-loader', 'css-loader'], }; // babel-loader handles .js and .jsx files const jsx = { test: /\.jsx?/, exclude: [ /node_modules/ ], use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env', '@babel/preset-react'] } } }; // this webpack configuration file supports these two file types const file_types = { rules: [ css, jsx ] }; const input = '/Users/c/top/frame/index.jsx'; const output = { filename: 'bundle.js', path: '/Users/c/top/frame-server/dist' }; const stats = { warnings: true }; // combine above objects and export const config_obj = { stats: stats, entry: input, output: output, module: file_types }; module.exports = (env) => { return config_obj; }; 

Yet still I see them compiled:

asset bundle.js 209 KiB [compared for emit] [minimized] (name: main) 1 related asset orphan modules 787 KiB [orphan] 460 modules runtime modules 663 bytes 3 modules cacheable modules 375 KiB modules by path ./node_modules/ 155 KiB 22 modules modules by path ./A1People/ 4.31 KiB 6 modules modules by path ./F1PageUser/ 4.9 KiB 5 modules modules by path ./F1Apex/ 2.87 KiB 4 modules modules by path ./A1Article/ 3.43 KiB 4 modules modules by path ./F1M1/ 2.9 KiB 4 modules modules by path ./C0Images/ 2.02 KiB 3 modules modules by path ./C2Menu/ 2.04 KiB 3 modules modules by path ./C3BarAdmin/ 1.56 KiB ./node_modules/css-loader/dist/cjs.js!./C3BarAdmin/C3BarAdmin.css 504 bytes [built] [code generated] + 2 modules + 8 modules webpack 5.69.1 compiled with 2 warnings in 6635 ms 

I am following the documentation by webpack found here.

and version as follows:

"webpack": "^5.69.1", "webpack-cli": "^4.9.2" 

I am getting a strange warning but I don't know if it is relevant:

WARNING in ./node_modules/React/cjs/react.production.min.js There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. Use equal casing. Compare these module identifiers: * /Users/c/top/frame/node_modules/React/cjs/react.production.min.js Used by 1 module(s), i. e. /Users/c/top/frame/node_modules/React/index.js * /Users/c/top/frame/node_modules/react/cjs/react.production.min.js Used by 1 module(s), i. e. /Users/c/top/frame/node_modules/react/index.js @ ./node_modules/React/index.js 4:2-59 @ ./F1PageUser/ULogin.jsx 2:0-26 5:22-41 7:18-37 9:18-37 11:31-50 @ ./F1PageUser/User.jsx 4:0-34 14:47-53 @ ./F1Page/F1Page.jsx 8:0-44 21:57-63 @ ./F1/F1.jsx 5:0-42 18:184-190 @ ./index.jsx 8:0-29 12:36-38 
3
  • This question has a similar answer here. Commented Mar 21, 2022 at 20:33
  • 1
    That is a different Question ... I need node_modules included in the output file, but I do not need them compiled. node_modules in this case are already compiled and simply need to be added to the bundle.js which I send to the client. Commented Mar 21, 2022 at 20:39
  • I've added in the strange warning, but I don't know if it is related. Commented Mar 21, 2022 at 20:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.