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

refactor: pass a unique compiler name to get child compilation (webpack 3) #483

Merged
merged 1 commit into from
Jun 11, 2017

Conversation

sokra
Copy link
Member

@sokra sokra commented Apr 13, 2017

This is recommended after webpack/webpack#4704

It's not good to merge before this PR because it would create absolute paths in the records.

Closes #389

@jsf-clabot
Copy link

jsf-clabot commented Apr 13, 2017

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Apr 13, 2017

Codecov Report

Merging #483 into master will decrease coverage by 0.16%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #483      +/-   ##
==========================================
- Coverage   90.38%   90.22%   -0.17%     
==========================================
  Files           6        6              
  Lines         364      358       -6     
  Branches       77       75       -2     
==========================================
- Hits          329      323       -6     
  Misses         35       35
Impacted Files Coverage Δ
loader.js 89.74% <100%> (-0.74%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a284f3a...6777369. Read the comment docs.

@bstuff
Copy link

bstuff commented Apr 21, 2017

i've installed extract-text-webpack-plugin and webpack from these commits but i still get the error:

ERROR in   Error: Child compilation failed:
  Module build failed: Error: "extract-text-webpack-plugin" loader is used without the corresponding plugin

here's the repository to test: https://github.com/bstuff/require-styles-webpack

HtmlWebpackPlugin Template:

<html>
  <head></head>
  <body>
    <div class="header">Some template stuff</div>
    ${require('./body')}
  </body>
</html>

body/index.js:

import style from './style.styl'; // this line causes the error
import tpl from './tpl.html';

export default tpl;

@michael-ciniawsky michael-ciniawsky added this to the 3.0 milestone Apr 22, 2017
@michael-ciniawsky michael-ciniawsky changed the title pass a unique compiler name to get child compilation refactor: pass a unique compiler name to get child compilation Apr 22, 2017
@michael-ciniawsky michael-ciniawsky changed the title refactor: pass a unique compiler name to get child compilation refactor: pass a unique compiler name to get child compilation (webpack 3) Apr 25, 2017
@joshwiens
Copy link
Member

Note to @webpack-contrib/org-maintainers - Should be done in conjunction with #477 as a single semver: Major to coincide with the webpack@3.0.0 release.

@sokra
Copy link
Member Author

sokra commented May 6, 2017

@bstuff It's not automatically fixed. This webpack PR only allow to use the compiler matching in rules:

rules: [
  { test: /\.css$/, oneOf: [
    { compiler: "html-webpack-plugin", loader: "null-loader" },
    { use: ETP.extract(...) }
  ] }
]

@sokra
Copy link
Member Author

sokra commented May 6, 2017

btw. html-webpack-plugin can do a similar change for webpack 3. cc @jantimon

@joshwiens joshwiens self-assigned this May 19, 2017
@joshwiens joshwiens changed the base branch from master to feature/webpack3 June 11, 2017 00:32
@joshwiens joshwiens merged commit 77daf83 into feature/webpack3 Jun 11, 2017
@michael-ciniawsky michael-ciniawsky deleted the bugfix/unique-compiler-name branch July 7, 2017 16:58
joshwiens added a commit that referenced this pull request Jul 10, 2017
- refactor: Pass a unique compiler name to get child compilation [483](#483)
- refactor: Apply webpack-defaults [542](#542)

BREAKING CHANGE: Enforces `engines` of `"node": ">=4.3.0 < 5.0.0 || >= 5.10`

- refactor: DeprecationWarning: Chunk.modules [543](#543)

BREAKING CHANGE: Updates to `Chunk.mapModules`. This release is not backwards compatible with `Webpack 2.x` due to breaking changes in webpack/webpack#4764

- fix: css generation order issue see: webpack/webpack#5225

BREAKING CHANGE: Enforces `peerDependencies` of `"webpack": "^3.1.0"`.
@michael-ciniawsky michael-ciniawsky modified the milestone: 4.0.0 Aug 31, 2017
@marmelin
Copy link

marmelin commented Nov 15, 2017

Hi guys,
I'm using webpack@3.8.1 and still facing this problem.
Module build failed: Error: "extract-text-webpack-plugin" loader is used without the corresponding plugin

The rules-section looks like this:

 // CSS LOADER
      , {
          test: /\.css$/
        , use: ['css-to-string-loader'].concat(
              ExtractTextPlugin.extract({
                  fallback: 'style-loader'
                , use: ['css-loader']
              })
            )
        }

How ca I implement the above "oneOf" workaround into my loader config?
Is this still necessary?

Thanks.

@michael-ciniawsky
Copy link
Member

@marmelin remove css-to-string-loader

@marmelin
Copy link

marmelin commented Nov 17, 2017

Thanks,
btw. this is the AOT compiling part - normal JIT compilation works fine!

now without css-to-string-loader the configuration looks like this:

In config file :

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

as merged object in Config-object output :

...
{ test: /\.css$/,
  use:
   [ { loader: '<path>/node_modules/extract-text-webpack-plugin/dist/loader.js',
       options: [Object] },
     { loader: 'style-loader' },
     { loader: 'css-loader' } ] }

Error is still the same.

internal/streams/legacy.js:59
      throw er; // Unhandled stream error in pipe.
      ^
Error: Error: Child compilation failed:
Module build failed: Error: "extract-text-webpack-plugin" loader is used without the corresponding plugin,

PS:

Change config and passing compiler option, does not change anything:

, { test: /\.css$/
    , oneOf: [
               { compiler: "html-webpack-plugin", loader: "null-loader"}
             , { use:  ExtractTextPlugin.extract(
                    { fallback: 'style-loader' , use: ['css-loader'] }
                 )
                }
       ]
  }

QUESTION for clarity:

Is the "_filename" in /extract-text-webpack-plugin/dist/loader.js:42:59 the one from the config ...

  , new ExtractTextPlugin({
      filename: **"css/[name].[hash].styles.css"**
     , allChunks: true
    })

... or is this the "index.html" from html-webpack-plugin, which should be generated first?

Greetings.

@kimown
Copy link

kimown commented Jan 27, 2018

@marmelin I met the same problem, do you have any solution finally, thanks.

@marmelin
Copy link

Hi @kimown ,
I solved this error along with some others and so I forgot to mention it here :) .

See my repo here:marmelin/ngtools-webpack-error-message-undefined, where I solved the error and explain it.

It boils down to this:

You can't use extract-text-webpack-plugin for components CSS templates, because it does not support / or do not function with "Child compilations". However you can with global css. Use two CSS rules in webpack config: 1) with "css-loader" and second with extract-text-webpack-plugin and include statement, for your global CSS files.

  // COMPONENT CSS LOADER
      , { test: /\.css$/
        , use: ['css-to-string-loader'].concat(['css-loader'])
        }
      // GLOBAL CSS LOADER
      , { test: /\.css$/
         , include: helpers.getPath('src/client/style')
         , use: ['css-to-string-loader'].concat(
            ExtractTextPlugin.extract({
                fallback: 'style-loader'
              , use: ['css-loader']
            })
          )
        }

This is what I did and it solved the error!
Good luck :)

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

Successfully merging this pull request may close these issues.

7 participants