Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
This repository was archived by the owner on May 29, 2019. It is now read-only.

[bug] async js chunks that include css/scss imports cause => Uncaught (in promise) TypeError: Cannot read property 'call' of undefined #456

@ericnoguchi

Description

@ericnoguchi

Tested with
ETP:2.1.0
webpack: 2.2.1
Node v7.7.1

There seems to be some issue when importing a scss file in a common chunk if that common chunk also imports an async/dynamic js chunk which imports another scss file.

File setup

//===== a.js =====
import './common';

//===== b.js =====
import './common';

//===== common.js =====
import './common.scss';
import ('./async.js'); // async import

//===== async.js =====
import './async.scss'

This issue happens when allChunks:false [I would like to lazy load js and associated css], and what seems to be happening is that the runtime code for css-loader is not always being included in the bundle which results in the below error?

Uncaught (in promise) TypeError: Cannot read property 'call' of undefined
    at __webpack_require__ (bootstrap 3d99482…:52)
    at Object.95 (async.scss:1)
    at __webpack_require__ (bootstrap 3d99482…:52)
    at Object.96 (async.scss?eb60:4)
    at __webpack_require__ (bootstrap 3d99482…:52)
    at Object.94 (0.cb65e0.chunk.js:8)
    at __webpack_require__ (bootstrap 3d99482…:52)

But if I for example update common.scss while webpack-dev-server is running, when the bundle gets rebuilt and the page refreshes I can see the code for css-loader in the chunk and the error goes away, but if I restart webpack-dev-server again and refresh the error comes back and css-loader code is gone.

I have created a repo with showing this error
https://github.com/ericnoguchi/webpack-testing

steps to reproduce.

  1. npm install
  2. npm run startDev
  3. go to http://localhost:8080/ and observe error
  4. updated any of the scss modules e.g. common.scss and after webpack-dev-server refreshes error is gone.
  5. check async/*.chunk.js contents in each case injected in the head tag.

Link stack overflow issue:
http://stackoverflow.com/questions/42687881/async-js-chunks-that-include-scss-imports-cause-uncaught-in-promise-typeerr

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions