Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'call' of undefined #959

Closed
kfancy opened this issue Apr 8, 2015 · 231 comments

Comments

@kfancy
Copy link

commented Apr 8, 2015

I'm having an issue with webpack where if I stop watching and restart, it will build just fine, but if I edit a file and save it, the incremental build fails with this error:

Uncaught TypeError: Cannot read property 'call' of undefined

Hunting it down there's a module that does not get included in the incremental change build. Best guess is the path followed to re-make the bundle file is not being followed correctly. Upon re-running (stop and start), the missing module is included.

webpack.config.js (module names changed to protect the innocent):

var webpack = require("webpack"),
    path = require('path')
    ;

module.exports = {
  entry: {
    Entry1: "./app/Entry1.js",
    Entry2: "./app/Entry2.js",
    Entry3: "./app/Entry3.js",
    Entry4: "./app/Entry4.js",
    Entry5: "./app/Entry5.js",
    Entry6: "./app/Entry6.js",
    Entry7: "./app/Entry7.js",
    Entry8: "./app/Entry8.js",
  },
  output: {
    path: path.join(__dirname, "public/js"),
    filename: "[name].bundle.js",
    chunkFilename: "[id].chunk.js"
  },
  module: {
    loaders: [
      {test: /\.js$/, loader: 'jsx-loader'}
    ]
  },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin("shared.js")
    ]
};
@sokra

This comment has been minimized.

Copy link
Member

commented Apr 9, 2015

Is it really a incorrect bundle/chunk file or is the file in the browser cache just old?

@sokra

This comment has been minimized.

Copy link
Member

commented Apr 10, 2015

Maybe it's fixed... Please reopen if still an issue with 1.8.4

@sokra sokra closed this Apr 10, 2015

@kfancy

This comment has been minimized.

Copy link
Author

commented Apr 10, 2015

It is really an incorrect bundle/chunk, I've flushed the browser to make sure of that.
Essentially, the module trying to be required is 100% missing on an incremental watch build.
Doesn't happen all the time.

For instance, using reactjs key mirror, on a list of constants, I'd require('react/lib/keyMirror'). On first build, no problem. On watch build, keyMirror module is completely missing from the file where it used to be.

@makedonian

This comment has been minimized.

Copy link

commented Apr 13, 2015

I'm still having this issue with 1.8.4. Pretty much the same setup as @kfancy, except my loader is jsx-loader?harmony

Worth mentioning is that it started happening after upgrading to react 0.13.1. I was porting code from 0.12 and didn't have issues even with webpack 1.7.2. Upgraded react, started having the issue, upgraded webpack to 1.8.4, and the issue still persist. I even removed the CommonsChunckPlugin to see if that would fix the problem, but no luck with that either.

I'm also getting random errors like Uncaught Error: Cannot find module "classnames" every now and then, only when running --watch.

@DanielApt

This comment has been minimized.

Copy link

commented Jul 3, 2015

I'm still seeing this issue. Using the latest version v1.10.1

First build works fine, but incremental builds fail. I get the following error from my bundle:
Uncaught TypeError: Cannot read property 'apply' of undefined

It seems to break on the usage of apply in this function.

function(modules) {
    // Check all modules for deduplicated modules
    for(var i in modules) {
        if(Object.prototype.hasOwnProperty.call(modules, i)) {
            switch(typeof modules[i]) {
            case "function": break;
            case "object":
                // Module can be created from a template
                modules[i] = (function(_m) {
                    var args = _m.slice(1), fn = modules[_m[0]];
                    return function (a,b,c) {
                        fn.apply(this, [a,b,c].concat(args)); // Breaks here
                    };
                }(modules[i]));
                break;
            default:
                // Module is a copy of another module
                modules[i] = modules[modules[i]];
                break;
            }
        }
    }
    return modules;
}

The hashes of the builds are different.

@DanielApt

This comment has been minimized.

Copy link

commented Jul 3, 2015

It has something do with our entry points:

We have issues when we use:

context: __dirname + '/project_name/static/js',
entry: {
        'static/dist/js/app': './components/app.js',
        'static/dist/js/log-in': './components/log-in.js',
        'static/dist/js/widget-a': './widgets/widget-a.js',
        'tests/testBundle': '../../tests/test.js', // removing this line fixes things
    },
    output: {
        path: __dirname + '/project_name',
        filename: '[name].js',
        sourceMapFileName: '[file].map'
    },

When removing testBundle things work nicely. Strangely enough the bundle throwing the error is actually app.js

PS: Sorry for the strange file system. We should address this once we have the chance.

@DanielApt

This comment has been minimized.

Copy link

commented Jul 23, 2015

@sokra could you re-open this issue?

@sokra sokra reopened this Jul 23, 2015

@sokra

This comment has been minimized.

Copy link
Member

commented Jul 23, 2015

Could you try upgrading to the lasted version?

@DanielApt

This comment has been minimized.

Copy link

commented Jul 23, 2015

Done. Still an issue.

@jeffutter

This comment has been minimized.

Copy link

commented Aug 11, 2015

I seem to be having this issue as well. It has been happening for the past few days, not sure if it was a webpack change or a code change that caused this. Let me know if I can help provide any info to track it down.

@Cap32

This comment has been minimized.

Copy link

commented Aug 13, 2015

😭I'm still seeing this issue. Using the latest version v1.11.0

@fxmaxvl

This comment has been minimized.

Copy link

commented Aug 27, 2015

Is there any progress on this issue?

@owais

This comment has been minimized.

Copy link

commented Aug 30, 2015

I'm facing this issue only when I use ExtractTextPlugin + SplitByPathPlugin (or split by name). It goes away if I remove either one of them.

@allantatter

This comment has been minimized.

Copy link

commented Sep 2, 2015

Same problem here, problem occurs after watch has detected a change and builds the bundle.

Uncaught TypeError: Cannot read property 'apply' of undefined

v1.11.0

@jinroh

This comment has been minimized.

Copy link

commented Sep 7, 2015

Same problem here.

Quite difficult to understand exactly how to reproduce the problem, but it seems to happen more frequently when I edit a symlinked module or simply a module inside node_modules during a watch build.

v1.12.1

@Jokcy

This comment has been minimized.

Copy link

commented Sep 8, 2015

maybe you have some module in umd factory like this:

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        /* AMD. Register as an anonymous module. */
        define(['require', 'exports'], factory);
    } else if (typeof exports === 'object') {
        /* CommonJS */
        factory(require, exports);
    } else {
        /* Browser globals - dangerous */
        factory(function(moduleName) { return root[moduleName]; }, root);
    }
}(this, function (require, exports) {
    var _ = require("lodash");
}))

maybe umd-require-webpack-plugin will help

@eddywashere

This comment has been minimized.

Copy link

commented Sep 27, 2015

@Jokcy how exactly do you use that plugin with webpack?

@stream7

This comment has been minimized.

Copy link

commented Oct 30, 2015

it also happens on v1.12.2.

In my case it happens in an entry point which is not included in the CommonsChunkPlugin as a chunk. If I remove the CommonsChunkPlugin it works fine.

However, I do have a few more entry points that are not included in the CommonsChunkPlugin and they work fine. The only thing that is special with this specific entry file is that the required files are not really modules. They don't export anything. This entry point is for the marketing site of the project and it just concatenates a few scripts so it looks like this:

require('./about');
require('./copy-buttons');
require('./documentation');
require('./get-started');
require('./header');

and these files have a few jquery stuff with no use of module.exports

Saqoosha added a commit to Whatever-Inc/KAMRA-Deja-Vu that referenced this issue Nov 8, 2015

Remove CommonsChunkPlugin related code
CommonsChunkPlugin がバグってるくさい
webpack/webpack#959

しょーがないので window に loader ぶっこむ。
@zbyte64

This comment has been minimized.

Copy link

commented Nov 10, 2015

I am also having this issue with v1.12.2

For me the issue goes away if I disable the DedupePlugin

var Develop = _.merge({
  watch: true,
  plugins: [
    //new webpack.optimize.DedupePlugin(),
    new webpack.optimize.CommonsChunkPlugin("vendors", "vendors.js"),
    new webpack.ResolverPlugin(
      new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
    ),
    new ExtractTextPlugin("[name].css"),
  ]
}, Common);

@bebraw bebraw added the bug label Nov 15, 2015

@maksimr

This comment has been minimized.

Copy link

commented Nov 15, 2015

+1 Have same issue when run karma in watch mode.
Workaround remove entry property of webpack config object in karma.conf.js

    delete webpackConf.entry;
@architectcodes

This comment has been minimized.

Copy link

commented Nov 21, 2015

I have the same problem since I’ve symlinked my node_modules/ folder of a package to the root node_modules/ in a monorepo.

To reproduce:

git clone git@github.com:parametric-svg/- parametric-svg
cd parametric-svg
git checkout b5a6259b921a48cdef4c010c03ebc56fb593ea01
npm install
cd packages/parse
npm run browser-test

saem added a commit to saem/hairpiece that referenced this issue Nov 29, 2015

Hot Module Replacement no longer crashes
HMR provided by webpack crashes, with the error: "Uncaught TypeError:
Cannot read property 'apply' of undefine" as shown in the following
issue on github:
webpack/webpack#959

I'm not exactly sure what this issue is, as the cause isn't quite clear
to me from reading the bug report. But the latest code changes seemed to
have resolved the problem, as all of the root level modules that have
side-effects now properly support hot code reloading. This required
significant refactoring, and undoubtedly will require yet more.

The current issue is that whenever a change is made, a full reload is
required, and the only hint of issue is the following error message:
"[HMR] Error: Aborted because 125 is not accepted". Checking the file
that comes back from webpack indeed shows that 125 is empty. I'm
guessing this is some dependency such as freezer, rx, or what have you
that is causing the hot reload to fail.
@joefiorini

This comment has been minimized.

Copy link

commented Dec 23, 2015

We're seeing this too in our app.

Uncaught TypeError: Cannot read property 'setPrototypeOf' of undefined(anonymous function) 

@ set-prototype-of.js:1__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71(anonymous function) @ application.bundle.js:25900__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71(anonymous function) @ inherits.js:5__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71(anonymous function) @ Dock.js:3__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71(anonymous function) @ index.js:7__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71(anonymous function) @ DockMonitor.js:19__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71(anonymous function) @ index.js:5__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71(anonymous function) @ Pagination.component.js:17__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71createStore @ createStore.js:18(anonymous function) @ index.js:10__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71(anonymous function) @ numberFormatInputs.js:25__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71webpackContext @ src Rails.js$:7(anonymous function) @ application.js:46(anonymous function) @ application.js:43__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71(anonymous function) @ application.bundle.js:5__webpack_require__ @ bootstrap 8aa52402241fffbcfe8b:71webpackJsonpCallback @ bootstrap 8aa52402241fffbcfe8b:42(anonymous function) @ application.bundle.js:1
VM62167:1 Uncaught ReferenceError: railsExports is not defined(anonymous function) @ VM62167:1window.ReactRailsUJS.mountComponents @ vendor.sprockets.js:1655(anonymous function) @ vendor.sprockets.js:1709fire @ jquery.js:3099self.fireWith @ jquery.js:3211jQuery.extend.ready @ jquery.js:3417completed @ jquery.js:3433

Occassionally it's also cannot read property apply of undefined. The culprit is typically a missing dependency from core-js. In the digging I did, I found that the missing file was included by react-dock which uses the static keyword from babel's es7 support. Could be a red herring, but our app only declares support for es6, so I'm wondering if maybe on an incremental rebuild it's not rebuilding react-dock (or anything else using es7-specific code from core-js) and therefore rebuilds the core-js dep with only things needed for es6 support.

Obviously this is only a hunch. I'm at a loss as to how to prove this. It happens sporadically, but probably a couple times per hour. It's also hard to tell if it's a problem with webpack, babel-loader, react-dock (not very likely) or something else.

To determine the above, I set the debugger to stop on uncaught exceptions and followed the stack trace down to where react-dock was calling setPrototypeOf.

Is anyone experiencing the issue in the same way I am? Or is this just different for everyone?

@kawing-chiu

This comment has been minimized.

Copy link

commented Dec 30, 2015

The same Uncaught TypeError: Cannot read property 'call' of undefined bug on webpack 1.12.9.

It breaks on this line in the runtime (I've extract the runtime in a separate chunk, and inserted it into the html):

/******/// Execute the module function
/******/modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/

As @zbyte64 noted, disabling the DedupePlugin plugin fixes the problem.

To reproduce:

git clone https://github.com/kawing-chiu/flask-react-redux-example.git
cd flask-react-redux-example
git checkout 3b3e198a1582e8
cd client
npm install
gulp build

Then serve the content in the build/ directory and see the bug:

cd build/
python3 -m http.server 3000
@nnur

This comment has been minimized.

Copy link

commented Jan 2, 2016

Hey, I'm getting this issue when I try to require textAngular and textAngular-santize. Any ideas on how I can get around it would be much appreciated!

@patriciussanctus

This comment has been minimized.

Copy link

commented Oct 1, 2018

webpack update @4.12.2 -> @4.20.2 broke my build 😞

@mjntan35

This comment has been minimized.

Copy link

commented Oct 3, 2018

setting concatenateModules: false in optimization fixed the problem in my case

@patriciussanctus

This comment has been minimized.

Copy link

commented Oct 3, 2018

after some tests I decided that my build breaks on config:

optimization: {
  splitChunks: {
    default: {
      chunks: 'all'
    }
  }
}
@Danita

This comment has been minimized.

Copy link

commented Oct 24, 2018

It happened to me from nowhere. I was happily compiling styled Vue single file components. Now if the component has a <style> tag the compilation fails with this very error. Removing the style fixes the compilation.

@Volcaner

This comment has been minimized.

Copy link

commented Nov 22, 2018

it still exists in webpack@4.21.0

@mohamedmhiri

This comment has been minimized.

Copy link

commented Dec 3, 2018

@Danita I got the same error and I fixed it by adding lang="scss" in the style tag like this:

<style lang="scss"></style>
@iannbing

This comment has been minimized.

Copy link

commented Dec 4, 2018

I'm using webpack@4.26.1. This issue appears when I set mode to development. I fixed it by removing ModuleConcatenationPlugin from my webpack.dev.js and adding it back to prod mode

{
  mode: 'production',
  plugins: [new webpack.optimize.ModuleConcatenationPlugin()]
}
@goonwzz

This comment has been minimized.

Copy link

commented Dec 5, 2018

change my minChunkSize fixed

@DemonCloud

This comment has been minimized.

Copy link

commented Jan 21, 2019

Still, have this problem. with producation building

@xuweikang

This comment has been minimized.

Copy link

commented Jan 24, 2019

Still, have this problem. with producation building

Still, have this problem. with producation building too . @sokra can we reopen this issue

@domoritz

This comment has been minimized.

Copy link

commented Feb 25, 2019

I'm seeing the same issue with the latest webpack and optimization.splitChunks on.

@roemhildtg

This comment has been minimized.

Copy link

commented Mar 20, 2019

I'm now running into this issue in production. It doesn't happen when building locally, it only happens when built in Azure dev-ops. Anyone have any insights into this particular situation?

I see

main.js?43b5fa107039e0157301:1 Uncaught (in promise) TypeError: Cannot read property 'call' of 
main.js?43b5fa107039e0157301:393 TypeError: Cannot read property 'call' of undefined
    at i (main.js?43b5fa107039e0157301:1)
    at Function.i.t (main.js?43b5fa107039e0157301:1)
    at main.js?43b5fa107039e0157301:304
Webpack config
const HtmlWebPackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const path = require('path');
const MinifyPlugin = require('terser-webpack-plugin');

module.exports = {
    entry: ['./src/app/main.js'],
    output: {
        chunkFilename: '[id].main.js',
        filename: 'app/main.js',
        library: 'app/main',
        libraryTarget: 'amd',
        path: path.resolve(__dirname, 'dist'),
        publicPath: '',
    },

    plugins: [
        new CleanWebpackPlugin(['dist', 'build']),
        new MiniCssExtractPlugin({
            // Options similar to the same options in webpackOptions.output
            // both options are optional
            filename: './[name].[hash].css',
            chunkFilename: './[id].[hash].css',
        }),
        new HtmlWebPackPlugin({
            template: './src/index.html',
            filename: './index.html',
            chunksSortMode: 'none',
            JSAPI: 'js.arcgis.com/4.9',
            inject: false,
        }),
        new HtmlWebPackPlugin({
            inject: false,
            template: './src/oauth-callback.html',
            filename: './oauth-callback.html',
            chunksSortMode: 'none',
        }),
    ],

    module: {
        rules: [{
            test: /\.stache$/,
            use: [{loader: 'can-stache-loader'}],
        }, {
            test: /\.layout$/,
            use: [{loader: 'raw-loader'}],
        }, {
            test: /\.js$/,
            exclude: /node_modules/,
            use: [{
                loader: 'babel-loader',
                options: {
                    sourceMap: true,
                },
            }],
        }, {
            test: /\.css$/,
            use: [
                MiniCssExtractPlugin.loader,
                {loader: 'css-loader', options: {sourceMap: true}},
                'postcss-loader', {
                    loader: 'resolve-url-loader',
                    options: {
                        sourceMap: true,
                    },
                },
            ],
        }, {
            test: /\.less$/,
            use: [
                MiniCssExtractPlugin.loader,
                'css-loader',
                'postcss-loader',
                'less-loader',
            ],
        }, {
            test: /\.scss$/,
            use: [
                MiniCssExtractPlugin.loader,
                {loader: 'css-loader', options: {sourceMap: true}},
                'postcss-loader', {
                    loader: 'resolve-url-loader',
                    options: {
                        sourceMap: true,
                    },
                }, {
                    loader: 'sass-loader',
                    options: {
                        sourceMap: true,
                    },
                },
            ],
        }, {
            test: /\.(jpe?g|png|gif|webp)$/,
            loader: 'url-loader',
            options: {
                // Inline files smaller than 10 kB (10240 bytes)
                limit: 10 * 1024,
            },
        }, {
            test: /\.(wsv|ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
            use: [{
                loader: 'file-loader',
                options: {
                    name: 'build/[name].[ext]',
                },
            }],
        }],
    },


    resolve: {
        extensions: ['.wasm', '.js', '.json'],
        modules: [
            path.resolve(__dirname, '/src'),
            path.resolve(__dirname, 'node_modules/'),
        ],
        alias: {
            'esri': 'arcgis-js-api',
            'sweetalert2$': 'sweetalert2/dist/sweetalert2',
            'moment': 'moment/moment',
        },
    },


    node: {
        process: false,
        global: false,
        fs: 'empty',
    },


    externals: [
        (context, request, callback) => {
            if (/pe-wasm$/.test(request)) {
                return callback(null, 'amd ' + request);
            }

            if (/^@dojo/.test(request) || /^esri/.test(request)) {
                return callback(null, 'amd ' + request);
            }

            callback();
        },
    ],

    optimization: {
        minimizer: [
            new MinifyPlugin({
                parallel: true,
            }),
        ],
    },
};

Other info:

  • webpack: 4.29.6
  • webpack-cli: 3.3.0
  • npm: 6.8.0
  • node: 8.11.2
@samuelcastro

This comment has been minimized.

Copy link

commented Mar 21, 2019

I'm having the exactly same problem in production (AWS), not happening locally.

main.4f753858.js:1 Uncaught (in promise) TypeError: Cannot read property 'call' of undefined
    at o (main.4f753858.js:1)
    at Object.3041 (index.less:12)
    at o (main.4f753858.js:1)
    at Object.3040 (index.js:1)
    at o (main.4f753858.js:1)
    at Object.3122 (index.tsx:3)
    at o (main.4f753858.js:1)
    at Object.3121 (index.tsx:1)
    at o (main.4f753858.js:1)
@roemhildtg

This comment has been minimized.

Copy link

commented Mar 21, 2019

@samuelcastro which version of npm are you using in aws? any luck in fixing it? I've tried completely reinstalling all my node_modules, and even updating versions by removing package lock. No luck so far.

@evilebottnawi

This comment has been minimized.

Copy link
Member

commented Mar 21, 2019

Before post message about problem please create minimum reproducible test repo

@samuelcastro

This comment has been minimized.

Copy link

commented Mar 21, 2019

@evilebottnawi We already have that, just read comments above.

@samuelcastro

This comment has been minimized.

Copy link

commented Mar 21, 2019

@roemhildtg No luck so far, it's happening on prod.

@samuelcastro

This comment has been minimized.

Copy link

commented Mar 21, 2019

Btw @roemhildtg the latest node version supported by AWS is 8.10.

@volkanunsal

This comment has been minimized.

Copy link

commented Mar 21, 2019

@samuelcastro I just started having this problem too. Setting concatenateModules: false fixed it for me.

@samuelcastro

This comment has been minimized.

Copy link

commented Mar 21, 2019

@volkanunsal concatenateModules: false is an optimization option, isn't it going to affect performance?

@volkanunsal

This comment has been minimized.

Copy link

commented Mar 21, 2019

@samuelcastro It's breaking some libraries that I use and I'd disabled it in production for a while. (see #8384). I haven't seen any major downsides to disabling it.

@HarshitChhipa

This comment has been minimized.

Copy link

commented Apr 22, 2019

This is my webpack.dev.js and I m having the same issue any help would be appreciated...
I have Tried everything to resolve it but nothing works.
It's weird that this is working on the server but on my local, it is not working.

/**

  • Weback.dev.js is the main build file which is used for various tasks for local dev
    */
    const webpack = require('webpack');
    const writeFilePlugin = require('write-file-webpack-plugin');
    const webpackMerge = require('webpack-merge');
    const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
    const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
    const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
    const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin');
    const WebpackNotifierPlugin = require('webpack-notifier');
    const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
    const path = require('path');

// Import utils.js for utility methods and webpack.common.js for common functions
const utils = require('./utils.js');
const commonConfig = require('./webpack.common.js');

// forcing env to be development
const ENV = 'development';

module.exports = (options) => webpackMerge(commonConfig({env: ENV}), {
mode: 'development',
devtool: 'cheap-module-eval-source-map',

entry: {
    polyfills: './src/polyfills',
    global: './src/assets/scss/global.scss',
    main: './src/main',
},
output: {
    path: utils.root('./../../public/app'),
    publicPath: 'app/',
    filename: '[name].bundle.js',
    sourceMapFilename: '[file].map',
    chunkFilename: '[id].chunk.js'
},
module: {
    rules: [
        {
            test: /\.ts$/,
            enforce: 'pre',
            use: [
                {
                    loader: 'tslint-loader',
                    options: {

                        // tslint does not interrupt the compilation by default
                        // if you want any file with tslint errors to fail
                        // set failOnHint to true
                        failOnHint: true,

                        // automatically fix linting errors
                        fix: true,
                    }
                }
            ],
            include: path.resolve(__dirname, 'src'),
            // exclude: ['node_modules', new RegExp('reflect-metadata\\' + path.sep + 'Reflect\\.ts')]
        },
        {
            test: /\.ts$/,
            use: [
                {loader: 'angular2-template-loader'},
                {
                    loader: 'cache-loader',
                    options: {
                        cacheDirectory: path.resolve('./../../storage/framework/ng-cache')
                    }
                },
                {
                    loader: 'thread-loader',
                    options: {
                        // there should be 1 cpu for the fork-ts-checker-webpack-plugin
                        workers: require('os').cpus().length - 1
                    }
                },
                {
                    loader: 'ts-loader',
                    options: {
                        transpileOnly: true,
                        happyPackMode: true
                    }
                },
                {loader: 'angular-router-loader'}
            ],
            exclude: ['node_modules']
        },
        {
            test: /\.scss$/,
            loaders: ['to-string-loader', 'css-loader', 'sass-loader'],
            exclude: /(vendor\.scss|global\.scss)/
        },
        {
            test: /(vendor\.scss|global\.scss)/,
            loaders: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader']
        },
        {
            test: /\.css$/,
            loaders: ['to-string-loader', 'css-loader'],
            exclude: /(vendor\.css|global\.css)/
        },
        {
            test: /(vendor\.css|global\.css)/,
            loaders: ['style-loader', 'css-loader']
        }
    ]
},
stats: options.stats,
plugins: [
    new SimpleProgressWebpackPlugin({
        format: options.stats === 'minimal' ? 'compact' : 'expanded'
    }),
    new webpack.HotModuleReplacementPlugin(),
    new HardSourceWebpackPlugin(),
    new FriendlyErrorsWebpackPlugin(),
    new ForkTsCheckerWebpackPlugin(),
    new BrowserSyncPlugin({
        host: 'localhost',
        hot: true,
        port: 9000,
        proxy: {
            target: 'http://localhost:9060'
        }
    }, {
        reload: false,
        live: false,
        files: [
            'src/assets/**/*',
            '*.html'
        ]
    }),
    new webpack.ContextReplacementPlugin(
        /angular(\\|\/)core(\\|\/)/,
        path.resolve(__dirname, './src/app')
    ),
    new writeFilePlugin(),
    new webpack.WatchIgnorePlugin([
        path.resolve(__dirname, './node_modules/'),
        utils.root('test'),
    ]),
    new WebpackNotifierPlugin({
        title: 'Arya Core',
        contentImage: path.join(__dirname, './src/assets/images/logo.png')
    })
],
devServer: {
    contentBase: utils.root('./../../public'),
    compress: true,
    hot: true,
    inline: true,
    historyApiFallback: true,
    port: 9060,
    proxy: [{
        context: [
            '/api',
            '/docs/api',
            '/docs/api/api-docs.json'
        ],
        target: 'http://127.0.0.1:8000',
        secure: false,
        headers: {host: 'localhost:8000'}
    }],
    stats: {colors: true},
    watchOptions: {
        ignored: /node_modules/
    }
},

});

@jizhangattw

This comment has been minimized.

Copy link

commented Apr 30, 2019

I'm seeing the same issue with the latest webpack and optimization.splitChunks on.

Awesome, it works.
https://webpack.js.org/configuration/optimization/#optimizationconcatenatemodules

@jlapointe

This comment has been minimized.

Copy link

commented May 13, 2019

Re-open please?

I'm also getting this problem, using webpack 4.31.0 and SplitChunksPlugin. I've provided a minimal project setup that reproduces the problem: https://gitlab.com/jlapointe/codesplittingtest

I've tried most of the fixes suggested earlier in the thread (toggling various config fields, including concatenateModules), but no luck.

Some commonalities with previous comments:

  • I have multiple named entry points and one depends on the other, as in #959 (comment)
  • One of my files imports the relative path '../../fixtures/mock_users.json', similar to #959 (comment)
@ericksepulveda

This comment has been minimized.

Copy link

commented Jun 14, 2019

I had this issue and it turns out it was because I had 2 chrome windows open with my app. I did some changes on my app, then refreshed one of those windows to see the changes and it threw this error, and it kept showing until I closed the other window, then again refresh my window and it worked.
Hope this helps someone.

@bigbn

This comment has been minimized.

Copy link

commented Jul 19, 2019

Got the same error message because of ExtractTextPlugin somehow unable to load less files in production mode, switching to MiniCssExtractPlugin resolved this issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.