Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
TypeError: module.nameForCondition is not a function

I am using webpack 4 splitchunk to export the js file, my app have 4 entry:

  entry : {
    bg : './src/background-scripts/' ,
    content : ['./src/content-scripts/firefox-fix.js', './src/content-scripts/'] ,
    options : [
      './src/options/'
    ],
    popup : './src/popup/' ,
    'bs-lite' : './src/public/bootstrap-lite.scss'
  } ,

I want to package the popup and content entry to common1.js. then I config the splitchunk like this:

optimization: {
    splitChunks: {
      cacheGroups: {
        commons1: {
          name: 'commons1.js',
          test: module => {
            for (const chunk of module.chunksIterable) {
                  if (chunk.name && /(popup|content)/.test(chunk.name)) {
                      if (module.nameForCondition() && /[\\/]node_modules[\\/]/.test(module.nameForCondition())) {
                       return true;
                   }
                  }
             }
            return false;
          },
          minChunks: 1,
          chunks: 'all'
        },
        commons2: {
          name: 'commons2.js',
          chunks(chunk){
            return chunk.name === 'commons1.js' || chunk.name === 'options'
          },
          minChunks: 1,
          chunks: 'all'
        },
        commons3: {
          name: 'commons3.js',
          chunks(chunk){
            return chunk.name === 'bg' || chunk.name === 'commons2.js'
          },
          minChunks: 1,
          chunks: 'all'
        },
      }
    }
  },

But when I run this config, shows error like this:

/Users/source/frontend/c/build/webpack.base.config.js:61
                      if (module.nameForCondition() && /[\\/]node_modules[\\/]/.test(module.nameForCondition())) {
                                 ^

TypeError: module.nameForCondition is not a function

I am searching from internet seems no one facing this problem. what should I do to fix it?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!