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

TypeError: chunk.isInitial is not a function #449

Closed
daryn-k opened this issue Mar 5, 2017 · 47 comments
Closed

TypeError: chunk.isInitial is not a function #449

daryn-k opened this issue Mar 5, 2017 · 47 comments

Comments

@daryn-k
Copy link

daryn-k commented Mar 5, 2017

There is this error:

var shouldExtract = !!(options.allChunks || chunk.isInitial());
TypeError: chunk.isInitial is not a function

I have no idea what is it.

My webpack.config.js file:

var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
    entry: './app/client.js',
    output: {
        filename: 'bundle.js',
        path: 'public/js'
    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015', 'stage-1']
                }
            },
            {
                test: /\.css/,
                loader: ExtractTextPlugin.extract('css')
            }
        ]
    },
    plugins: [
        new ExtractTextPlugin('styles.css')
    ]
};
@bebraw
Copy link
Contributor

bebraw commented Mar 5, 2017

There's not enough information to debug. Which version of webpack/extract-text-webpack-plugin are you using? If you have webpack 1 and are using extract-text-webpack-plugin 2, that error could happen. In that case you'll have to use extract-text-webpack-plugin 1 or upgrade webpack to 2.

@daryn-k
Copy link
Author

daryn-k commented Mar 5, 2017

I use last versions of 'extract-text-webpack-plugin' and webpack (2.2.1)

@bebraw
Copy link
Contributor

bebraw commented Mar 5, 2017

Ok, still not enough info. Maybe someone else has a better idea.

@daryn-k
Copy link
Author

daryn-k commented Mar 5, 2017

I don't know what else... It's just about a simple functionality - build 'bundle.css' from all css-files from project. What kind of information do you need?

@bebraw
Copy link
Contributor

bebraw commented Mar 5, 2017

I would need a project to run. chunk.isInitial() is something provided by webpack itself. If chunk is missing, there is something fatally wrong.

@daryn-k
Copy link
Author

daryn-k commented Mar 5, 2017

Maybe these lines?

 at C:\site.dev\site-spa\react\node_modules\extract-text-webpack-plugin\index.js:259:55
    at C:\site.dev\site-spa\react\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3025:16
    at eachOfArrayLike (C:\site.dev\site-spa\react\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:940:9)
    at eachOf (C:\site.dev\site-spa\react\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:990:5)
    at Object.eachLimit (C:\site.dev\site-spa\react\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3089:3)
    at ExtractTextPlugin.<anonymous> (C:\site.dev\site-spa\react\node_modules\extract-text-webpack-plugin\index.js:257:10)
    at Compilation.applyPluginsAsync (C:\site.dev\site-spa\react\node_modules\tapable\lib\Tapable.js:71:13)
    at Compilation.seal (C:\site.dev\site-spa\react\node_modules\webpack\lib\Compilation.js:525:7)
    at Compiler.<anonymous> (C:\site.dev\site-spa\react\node_modules\webpack\lib\Compiler.js:397:15)
    at C:\site.dev\site-spa\react\node_modules\tapable\lib\Tapable.js:103:11
    at Compilation.<anonymous> (C:\site.dev\site-spa\react\node_modules\webpack\lib\Compilation.js:445:10)
    at C:\site.dev\site-spa\react\node_modules\webpack\lib\Compilation.js:417:12
    at C:\site.dev\site-spa\react\node_modules\webpack\lib\Compilation.js:332:10
    at C:\site.dev\site-spa\react\node_modules\async\lib\async.js:52:16
    at done (C:\site.dev\site-spa\react\node_modules\async\lib\async.js:246:17)
    at C:\site.dev\site-spa\react\node_modules\async\lib\async.js:44:16
    at C:\site.dev\site-spa\react\node_modules\webpack\lib\Compilation.js:332:10
    at C:\site.dev\site-spa\react\node_modules\async\lib\async.js:52:16
    at done (C:\site.dev\site-spa\react\node_modules\async\lib\async.js:246:17)
    at C:\site.dev\site-spa\react\node_modules\async\lib\async.js:44:16
    at C:\site.dev\site-spa\react\node_modules\webpack\lib\Compilation.js:332:10
    at C:\site.dev\site-spa\react\node_modules\async\lib\async.js:52:16
    at done (C:\site.dev\site-spa\react\node_modules\async\lib\async.js:246:17)
    at C:\site.dev\site-spa\react\node_modules\async\lib\async.js:44:16
    at C:\site.dev\site-spa\react\node_modules\webpack\lib\Compilation.js:332:10
    at C:\site.dev\site-spa\react\node_modules\async\lib\async.js:52:16
    at done (C:\site.dev\site-spa\react\node_modules\async\lib\async.js:246:17)
    at C:\site.dev\site-spa\react\node_modules\async\lib\async.js:44:16
    at C:\site.dev\site-spa\react\node_modules\webpack\lib\Compilation.js:332:10
    at C:\site.dev\site-spa\react\node_modules\async\lib\async.js:52:16

@bebraw
Copy link
Contributor

bebraw commented Mar 5, 2017

Sorry, that doesn't help.

I'm closing this issue until someone can provide a proper project to examine as instructed in the issue template.

@bebraw bebraw closed this as completed Mar 5, 2017
@Rob--
Copy link

Rob-- commented Mar 19, 2017

Unable to provide a project, but I'd just like to mention that this is happening to me also.

Package versions:

"webpack": "^1.14.0"
"extract-text-webpack-plugin": "^2.1.0"

Properties from config file:

module: {
  rules: [
    {
      test: /\.css$/,
      use: ExtractTextPlugin.extract({
        fallback: "style-loader",
        use: "css-loader"
      })
    }
  ]
},
plugins: [
  new ExtractTextPlugin("styles.css")
]

Error when running webpack:

C:\project\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:940
        iteratee(coll[index], index, onlyOnce(iteratorCallback));
        ^
TypeError: chunk.isInitial is not a function
    at C:\project\node_modules\extract-text-webpack-plugin\index.js:267:55
    at C:\project\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3025:16
    at eachOfArrayLike (C:\project\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:940:9)
    at eachOf (C:\project\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:990:5)
    at Object.eachLimit (C:\project\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3089:3)
    at ExtractTextPlugin.<anonymous> (C:\project\node_modules\extract-text-webpack-plugin\index.js:265:10)
    at Compilation.applyPluginsAsync (C:\project\node_modules\tapable\lib\Tapable.js:71:13)
    at Compilation.seal (C:\project\node_modules\webpack\lib\Compilation.js:525:7)
    at Compiler.<anonymous> (C:\project\node_modules\webpack\lib\Compiler.js:397:15)
    at C:\project\node_modules\tapable\lib\Tapable.js:103:11
    at Compilation.<anonymous> (C:\project\node_modules\webpack\lib\Compilation.js:445:10)
    at C:\project\node_modules\webpack\lib\Compilation.js:417:12
    at C:\project\node_modules\webpack\lib\Compilation.js:332:10
    at C:\project\node_modules\async\lib\async.js:52:16
    at done (C:\project\node_modules\async\lib\async.js:246:17)
    at C:\project\node_modules\async\lib\async.js:44:16
    at C:\project\node_modules\webpack\lib\Compilation.js:332:10
    at C:\project\node_modules\async\lib\async.js:52:16
    at done (C:\project\node_modules\async\lib\async.js:246:17)
    at C:\project\node_modules\async\lib\async.js:44:16
    at C:\project\node_modules\webpack\lib\Compilation.js:332:10
    at C:\project\node_modules\async\lib\async.js:52:16
    at done (C:\project\node_modules\async\lib\async.js:246:17)
    at C:\project\node_modules\async\lib\async.js:44:16
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

The same problem is also referenced here.

I would submit a pull request but after bypassing this problem I receive another issue (Expecting Unicode escape sequence \uXXXX (1:4) You may need an appropriate loader to handle this file type.).


My proposed solution:
On lines 267, 302 and 306 add in a check to see if .isInitial is a function. If it is then use it, else use .initial

@bebraw
Copy link
Contributor

bebraw commented Mar 19, 2017

@Rob-- Can you either upgrade to webpack 2 or downgrade the plugin to 1 series? I don't think the 2.x version of the plugin is supposed to work with webpack 1. That could be forced through a peer dependency.

@Rob--
Copy link

Rob-- commented Mar 19, 2017

@bebraw I'm a complete idiot, for some reason I thought I was using Webpack 2.0 even though I saw my Webpack version was clearly not 2.0. It's working perfectly now, sorry for wasting your time! I did a clean install of Webpack and assumed it would download the latest version, instead it used an old version in my NPM cache.

@bebraw
Copy link
Contributor

bebraw commented Mar 19, 2017

@Rob-- No probs. We may still want to set that peer dep to avoid these kind of issues. 👍

@jony89
Copy link

jony89 commented Mar 20, 2017

occurs for me as well - same exact issue same exact config.

webpack : 2.2.1
extract-text-webpack-plugin : 2.1.0

@bebraw
Copy link
Contributor

bebraw commented Mar 20, 2017

@jony89 There's still not enough info to help. 😢

@jony89
Copy link

jony89 commented Mar 20, 2017

@bebraw what do you need?

latest webpack, latest package of this module. add the following config to webpack :

        rules: [
            {
                test: /\.css$/, 
                loader: ExtractTextPlugin.extract({
                   fallback: 'style-loader',
                   use: [ 
                     { 
                       loader: 'css-loader', 
                       options : { autoprefixer: false, sourceMap: true, importLoaders: 1 } 
                     }, 
                     'postcss-loader'
                   ]
                 })
            }            
        ],

and :

    plugins: [
        new ExtractTextPlugin('index.css'),
    ]

Then run the project with that webpack config and you will get :

TypeError: chunk.isInitial is not a function
at \node_modules\extract-text-webpack-plugin\index.js:267:55
at \node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3025:16
at eachOfArrayLike (\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:940:9)
at eachOf (\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:990:5)
at Object.eachLimit (\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3089:3)
at ExtractTextPlugin. (\node_modules\extract-text-webpack-plugin\index.js:265:10)
at Compilation.applyPluginsAsync (\node_modules\gulp-webpack\node_modules\tapable\lib\Tapable.js:71:13)
at Compilation.seal (\node_modules\gulp-webpack\node_modules\webpack\lib\Compilation.js:525:7)
at Compiler. (\node_modules\gulp-webpack\node_modules\webpack\lib\Compiler.js:397:15)
at \node_modules\gulp-webpack\node_modules\tapable\lib\Tapable.js:103:11
at Compilation. (\node_modules\gulp-webpack\node_modules\webpack\lib\Compilation.js:445:10)
at \node_modules\gulp-webpack\node_modules\webpack\lib\Compilation.js:417:12
at \node_modules\gulp-webpack\node_modules\webpack\lib\Compilation.js:332:10
at \node_modules\async\lib\async.js:52:16
at done (\node_modules\async\lib\async.js:246:17

@bebraw
Copy link
Contributor

bebraw commented Mar 20, 2017

@jony89 I would need a standalone project. Any chance you could open a separate issue with that?

@jony89
Copy link

jony89 commented Mar 20, 2017

k

@jony89
Copy link

jony89 commented Mar 20, 2017

see #461

@bebraw
Copy link
Contributor

bebraw commented Mar 20, 2017

@jony89 Ok. Hopefully someone can debug based on that. Thanks.

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Mar 20, 2017

@jony89 There is no { autoprefixer: false } in css-loader, which version of css-loader do you use and does it work without setting sourceMap? Please also try without postcss-loader and provide your postcss.config.js. Don't take it personal but I won't download any kind of .zip or other files as long as I cannot take a first glance at them before I execute that on my system 😛 (#461)

@jony89
Copy link

jony89 commented Mar 20, 2017

@michael-ciniawsky so how do you expect me to provide a stand alone project?

create one by your own, it is pretty easy. postcss is not needed to reproduce the issue. (I just tried to create standalone as fast as possible) this will trigger the same issue :

        rules: [
            {
                test: /\.css$/, 
                loader: ExtractTextPlugin.extract({
                   fallback: 'style-loader',
                   use: [ 
                     { 
                       loader: 'css-loader'
                     }
                   ]
                 })
            }            
        ],

It start to look like you guys don't really want to try and fix that. I'm trying to help here.

Don't take it personal but I won't download any kind of .zip or other files as long as I cannot take a first glance at them before I execute that on my system

you can open the zip, and see the files before you run them.

@Rob--
Copy link

Rob-- commented Mar 20, 2017

@jony89 you could make a new repo and upload an example project there?

@bebraw
Copy link
Contributor

bebraw commented Mar 20, 2017

@jony89 node_modules/.bin/webpack --config webpack.dev.config.js against that completes without a problem for me (Node 6). There's still some info missing (Node version for one). Missing something subtle.

@1e1f
Copy link

1e1f commented May 19, 2017

This is a little old now, but I just ran into this same error when I moved to a machine running node 7.0.0, after installing nvm and switching to 7.10.0 the error was resolved. webpack2.2 / extract 2.1

@flyon
Copy link

flyon commented May 22, 2017

Same problem. All current stable versions: webpack 2.5.1 / extract-text-webpack-plugin 2.1.0. Just upgraded to node 7.10.0, still have the problem.

TypeError: extractedChunk.isInitial is not a function

Edit: fixed by fixing webpack versions, see below

@bebraw bebraw reopened this May 22, 2017
@jony89
Copy link

jony89 commented May 22, 2017

some of the conversation moved to the issue, so i write my temp solution here as well:

temporary solution is to give webpack-stream your own webpack version:

webpackStream(config, require('webpack'))

see shama/webpack-stream#125

this is the issue : #461

hope it helps for others.

@flyon
Copy link

flyon commented May 29, 2017

I thought I thoroughly checked all the versions, but it turned out I had a different webpack version running in node_modules of a higher level folder. So webpack was globally 2.5.1 but require('webpack') was an older version. Working fine now that I've got that sorted out. You can close this again

@bebraw bebraw closed this as completed May 29, 2017
@elliotwesoff
Copy link

Hello I am getting this error as well.

$ webpack -v
3.0.0
$ node -v
v7.7.1
 optimizeUnhandled rejection TypeError: chunk.isInitial is not a function
    at C:\project\node_modules\extract-text-webpack-plugin\index.js:267:55
    at C:\project\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3047:16
    at eachOfArrayLike (C:\project\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1039:9)
    at eachOf (C:\project\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:1087:5)
    at Object.eachLimit (C:\project\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3109:3)
    at ExtractTextPlugin.<anonymous> (C:\project\node_modules\extract-text-webpack-plugin\index.js:265:10)
    at Compilation.applyPluginsAsync (C:\project\node_modules\tapable\lib\Tapable.js:71:13)
    at Compilation.seal (C:\project\node_modules\webpack\lib\Compilation.js:525:7)
    at Compiler.<anonymous> (C:\project\node_modules\webpack\lib\Compiler.js:397:15)
    at C:\project\node_modules\tapable\lib\Tapable.js:103:11
    at C:\project\node_modules\html-webpack-plugin\index.js:60:9
    at tryCatcher (C:\project\node_modules\html-webpack-plugin\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\project\node_modules\html-webpack-plugin\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (C:\project\node_modules\html-webpack-plugin\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (C:\project\node_modules\html-webpack-plugin\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (C:\project\node_modules\html-webpack-plugin\node_modules\bluebird\js\release\promise.js:693:18)

@ghostd
Copy link

ghostd commented Jun 21, 2017

@elliotwesoff look at this html-webpack-plugin comment, it fixed my 'undefined' error (mainly back to webpack@2.6.1 or use npm@5)

@elliotwesoff
Copy link

elliotwesoff commented Jun 22, 2017

Hey @ghostd , I still get the same error after doing cd node_modules/html-webpack-plugin && npm install webpack extract-text-webpack-plugin

Is there a known working combination of webpack and node versions that I can use? Or even of this package's version?

@joehannes-zz
Copy link

same issue here. jony89 comment helped me in my case, even though i'm using gulp-webpack, not webpack-stream as he states.
I got my setup on github, so you can clone and play around if you want to ...

Just to let you know:
gulp-webpack 1.5.0
webpack 2.6.1
extract-text-webpack-plugin 2.1.2
sass-loader (which is using E-T-W-P) 6.0.6

Basically, to make it work, try and provide to your webpack-stream or as in my case gulp-webpack webpack as a second param after your config ... that's what makes it work in my case as well :)

@iddqdidkfa
Copy link

Can't believe this issue still closed:

node: 8.1.4
webpack: 3.1.0
extract-text-webpack-plugin: 3.0

@webpack-contrib webpack-contrib deleted a comment from jony89 Jul 13, 2017
@zullusa
Copy link

zullusa commented Jul 16, 2017

Hi! Can You review this article? You even don't need to know russian. Just execute commands and create files. I get topic error, when I execute npm run build.
TypeError: chunk.sortModules is not a function.

What has forgotten the article author to do?

@marcopeg
Copy link

Hi guys, I ran into this problem myself. After reading it I tried to downgrade the plugin to 2.1.0 and it works for me. So far I can say that 3.x didn't work with webpack 2.2.0.

Hope this will help somebody here ;-)

@nfriend
Copy link

nfriend commented Jul 20, 2017

Thanks @marcopeg, I had the same issue. For me I was able to instead fix this issue by upgrading from webpack 2 to webpack 3.

@jk171505
Copy link

node: 8.4.0
webpack: 3.0.0, 3.1.0, 3.5.5
extract-text-webpack-plugin: 3.0

the same problem...

@sundagy
Copy link

sundagy commented Sep 17, 2017

I am install local version webpack-dev-server and it solved the problem.

@brpsmith
Copy link

I solved this issue by upgrading webpack-stream.

webpack 3.5.6
webpack-stream 4.0.0
extract-text-webpack-plugin 3.0.0

@enmanuelduran
Copy link

Im having this situation with webpack 1.13.2 and extract-text-webpack-plugin 3.0.1 :/

@navasiloy
Copy link

for webpack 3

npm install --save-dev extract-text-webpack-plugin

for webpack 2

npm install --save-dev extract-text-webpack-plugin@2.1.2

for webpack 1

npm install --save-dev extract-text-webpack-plugin@1.0.1

@enmanuelduran
Copy link

@navasiloy your suggestion made the trick for my case. thanks.

@andrew-aladev
Copy link

I'm closing this issue until someone can provide a proper project to examine as instructed in the issue template.

@webpack You definitely need another admin for this repository.

@alexander-akait
Copy link
Member

@andrew-aladev please provide minimum reproducible test repo

@andrew-aladev
Copy link

I was able to reproduce it with empty string as an extension for webpacker. I am going to provide more detailed info later.

@alexander-akait
Copy link
Member

@andrew-aladev just ping me when repo is ready 👍

@andrew-aladev
Copy link

My chunks was created in webpack/lib/Compilation.js in addChunk. But my version of webpack is 1.15.0. So we have misconfigured webpack here.

It is an npm issue. It shouldn't be possible for me to install latest extract-text-webpack-plugin with webpack 1x.

@alexander-akait
Copy link
Member

latest extract-text-webpack-plugin is not compatibility with webpack@1

@andrew-aladev
Copy link

The problem was about webpacker. It was using the wrong version of webpack. It's so easy to receive the same problem with npm.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests