levp / wrapper-webpack-plugin

A webpack plugin that wraps output files (chunks) with custom text or code.
91 stars 37 forks source link

Doesn't play nice with ExtractTextPlugin #3

Closed jknight12882 closed 7 years ago

jknight12882 commented 7 years ago

When I use WrapperPlugin with ExtractTextPlugin, I get the following exception

Module build failed: TypeError: text.forEach is not a function
    at /Users/jknight/Workspace/xxx/node_modules/extract-text-webpack-plugin/dist/loader.js:131:14
    at compile (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compiler.js:304:11)
    at applyPluginsAsync.err (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compiler.js:520:14)
    at next (/Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:184:11)
    at Compiler.<anonymous> (/Users/jknight/Workspace/xxx/node_modules/extract-text-webpack-plugin/dist/loader.js:108:7)
    at next (/Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:186:14)
    at Compiler.<anonymous> (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/CachePlugin.js:62:5)
    at Compiler.applyPluginsAsyncSeries (/Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:188:13)
    at compilation.seal.err (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compiler.js:517:11)
    at Compilation.applyPluginsAsyncSeries (/Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:177:46)
    at self.applyPluginsAsync.err (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compilation.js:654:19)
    at Compilation.applyPluginsAsyncSeries (/Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:177:46)
    at self.applyPluginsAsync.err (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compilation.js:645:11)
    at next (/Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:184:11)
    at Compilation.<anonymous> (/Users/jknight/Workspace/xxx/node_modules/wrapper-webpack-plugin/wrapper-webpack-plugin.js:31:4)
    at Compilation.applyPluginsAsyncSeries (/Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:188:13)
    at self.applyPluginsAsync.err (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compilation.js:640:10)
    at Compilation.applyPluginsAsyncSeries (/Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:177:46)
    at sealPart2 (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compilation.js:636:9)
    at Compilation.applyPluginsAsyncSeries (/Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:177:46)
    at Compilation.seal (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compilation.js:579:8)
    at applyPluginsParallel.err (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compiler.js:514:17)
    at /Users/jknight/Workspace/xxx/node_modules/tapable/lib/Tapable.js:271:11
    at _addModuleChain (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compilation.js:481:11)
    at processModuleDependencies.err (/Users/jknight/Workspace/xxx/node_modules/webpack/lib/Compilation.js:452:13)
    at _combinedTickCallback (internal/process/next_tick.js:95:7)
    at process._tickCallback (internal/process/next_tick.js:161:9)
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js!src/ot-common/components/Main/styles.css:
       2 modules
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js!src/ot-common/components/Main/styles.css:
       2 modules

Removing WrapperPlugin causes the issue to go away

levp commented 7 years ago

@jknight12882 I can't reproduce the error, the two plugins co-exist fine for me. What versions of webpack and of the two plugins are you using?

jknight12882 commented 7 years ago

https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/585

levp commented 7 years ago

@jknight12882 Which version of wrapper-webpack-plugin?

jknight12882 commented 7 years ago

The latest v1.0.0

levp commented 7 years ago

@jknight12882 The configuration you posted in the other issue works fine for me. I created an empty vendor-manifest.json file to make it work, so perhaps that's the different.

eg

levp commented 7 years ago

@jknight12882 Closed for now, if you manage to reproduce it let me know.

jknight12882 commented 7 years ago

This issue reproduces repeatedly and consistently using the above listed configuration. I had to remove this plugin in order to get things running smoothly. Not sure why you weren't able to reproduce

levp commented 7 years ago

@jknight12882 Your configuration example is complex so I filled in the gaps as best I could to make it work; and got webpack to build normally.

I assume you're using babel to transpile the webpack configuration to es5/6, so could it possibly be related to the version/config of babel you're using?

I used babel-cli 6.24.1 with the following configuration:

{
    "presets": ["es2015"],
    "plugins": ["transform-object-rest-spread"]
}

Node.js version is latest v6, which is v6.11.2.

It would help if you could distill the configuration into just the bare necessities to recreate the issue as you understand it.

sresant commented 7 years ago

I am also seeing this issue. When digging deeper into the code, I placed a log statement to see what the text variable actually is and it turns out it is a function instead of an array. I am using webpack 3 with etp 3.0.0 my loaders being used are less, css and style loader. Im seeing this specifically on watch mode. The first compilation succeeds but when attempting to make a change sometimes this error pops up. I can't seem to pin it down to a single reproducible set of configurations but thought this information might provide some light on the situation.

levp commented 7 years ago

@sresant Thanks for the extra info, I'll take another look into it.

ctavan commented 7 years ago

Have you tried it again with webpack@3.5.5? I was experiencing similar problems with webpack@3.4.1 but they are gone after upgrading webpack.

levp commented 7 years ago

@sresant I still can't recreate this error, and as per @ctavan newer versions of webpack seem to not cause this error at all (hopefully).

If anyone can post a webpack configuration that can consistently recreate this error it would be very helpful, otherwise there isn't much I can do about it.