Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

273
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda