Skip to content

webpack.IngorePlugin failure with webpackMissingModule #15876

@rictt

Description

@rictt

Bug report

What is the current behavior?
I have the folling config, i trying to ignore some file(module) for reduce build time.

// webpack.config.js
module.exports = {
  mode: "none",
  entry: "./src/index.js",
  output: {
    filename: "bundle.js"
  },
  resolve: {
    alias: {
      '@': path.join(__dirname, './src')
    }
  },
  devtool: 'eval-source-map',
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'style-loader',
          'css-loader'
        ]
      }
    ]
  },
  plugins: [
    new webpack.IgnorePlugin({
      // ingore file end with a or b 
      resourceRegExp: /a|b\.js$/
    })
  ]
}

// src/index.js
import "@/a"
import "./index.css"

// src/a.js
console.log('aaaaa')

and then i run build and preview index.html in the browser, i got the below result Cannot find module '@/a', seems like ignorePlugin works, but resolve failed.

In my opinion, I hope that when the plugin takes effect, the module parsing is removed and the project runs normally.

If the current behavior is a bug, please provide the steps to reproduce.

I not sure this is bug, may my demand is not match the ignorePlugin.

What is the expected behavior?

I hope that when the plugin takes effect, the module parsing is removed and the project runs normally

Other relevant information:
webpack version: 4.42.1
Node.js version: 12.22.7
Operating System: mac os
Additional tools: vscode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions