amireh / happypack

Happiness in the form of faster webpack build times.
MIT License
4.23k stars 124 forks source link

AssertionError: HappyPlugin[js]; you have not specified any loaders and there is no matching loader entry with this id either. #48

Closed IAMtheIAM closed 8 years ago

IAMtheIAM commented 8 years ago

HappyPack does not seem to work when trying to "infer" the loaders from preLoaders. Is this true? Can it be made to work? If not, I can easily specify it, just wondering.

  new HappyPack({ id: 'js' }),
       preLoaders: [

        /*
       * Source map loader support for *.js files
       * Extracts SourceMaps for source files that as added as sourceMappingURL comment.
       *
       * See: https://github.com/webpack/source-map-loader
       */
      {
        test: /\.js$/,
        loader: 'source-map-loader',
        exclude: [
          // these packages have problems with their sourcemaps
          helpers.root('node_modules/rxjs'),
          helpers.root('node_modules/@angular2-material'),
          helpers.root('node_modules/@angular')
        ],
        happy: { id: 'js' } // HappyPack middleware

      }
    ],
Happy[js]: Version: 2.1.1. Using cache? yes. Threads: 3

D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\happypack\lib\HappyPlugin.js:165
      assert(loaders && loaders.length > 0,
      ^
AssertionError: HappyPlugin[js]; you have not specified any loaders and there is no matching loader entry with this id either.
    at normalizeLoaders (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\happypack\lib\HappyPlugin.js:165:7)
    at D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\happypack\node_modules\async\lib\async.js:713:13
    at Immediate.iterate [as _onImmediate] (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\happypack\node_modules\async\lib\async.js:262:13)
    at processImmediate [as _immediateCallback] (timers.js:383:17)
amireh commented 8 years ago

Oh no the infer option only works on loaders not pre / post. Hmm. Personally I'm not a fan of this option altogether because it irreversibly mutates the options which is bad in some contexts (like running behind grunt-watch or similar) so if you could get rid of it (yes I know, more typing!) you might be better off.

If you feel strongly about it, we can add support for inferring from preLoaders and postLoaders but I would rather not.

IAMtheIAM commented 8 years ago

Thanks for the reply. Actually it's not a big deal, I was just curious. It was because I am using source-map-loader and they put their loader into in preLoaders

IAMtheIAM commented 8 years ago

I just noticed that it had trouble interring from the [awesome-typescript-loader](https://github.com/s-panferov/awesome-typescript-loader) but when I specify maunally in the webpack plugin, it works fine. Seems to work fine for the other loaders. Just letting you know.

==================================================
            Building for DEVELOPMENT
==================================================

Happy[js]: Version: 2.1.1. Using cache? yes. Threads: 3
Happy[js]: No cache was found, starting fresh.
Happy[js]: All set; signalling webpack to proceed.
Happy[ts]: Version: 2.1.1. Using cache? yes. Threads: 3
Happy[ts]: Loaded 1 entries from cache. (0 were stale)
Happy[ts]: All set; signalling webpack to proceed.
Happy[json]: Version: 2.1.1. Using cache? yes. Threads: 3
Happy[json]: Loaded 0 entries from cache. (0 were stale)
Happy[json]: All set; signalling webpack to proceed.
Happy[css]: Version: 2.1.1. Using cache? yes. Threads: 3
Happy[css]: Loaded 0 entries from cache. (0 were stale)
Happy[css]: All set; signalling webpack to proceed.
Happy[html]: Version: 2.1.1. Using cache? yes. Threads: 3
Happy[html]: Loaded 0 entries from cache. (0 were stale)
Happy[html]: All set; signalling webpack to proceed.
Happy[jpg]: Version: 2.1.1. Using cache? yes. Threads: 3
Happy[jpg]: Loaded 0 entries from cache. (0 were stale)
Happy[jpg]: All set; signalling webpack to proceed.
Happy[png]: Version: 2.1.1. Using cache? yes. Threads: 3
Happy[png]: Loaded 0 entries from cache. (0 were stale)
Happy[png]: All set; signalling webpack to proceed.
Happy[scss]: Version: 2.1.1. Using cache? yes. Threads: 3
Happy[scss]: Loaded 0 entries from cache. (0 were stale)
Happy[scss]: All set; signalling webpack to proceed.
813ms build modules
2ms seal
3ms optimize
3ms hashing
2ms create chunk assets
3ms additional chunk assets
3ms optimize chunk assets
103ms optimize assets
37ms emit
Hash: 6c2cd446ebd48e9e5802
Version: webpack 1.13.1
Time: 4487ms
                                 Asset       Size  Chunks             Chunk Names
    assets/icon/apple-icon-180x180.png      11 kB          [emitted]
                        _Layout.cshtml  994 bytes          [emitted]
                     assets/humans.txt  268 bytes          [emitted]
                  assets/manifest.json  810 bytes          [emitted]
                     assets/robots.txt   34 bytes          [emitted]
              assets/service-worker.js   45 bytes          [emitted]
                   assets/css/.gitkeep   15 bytes          [emitted]
       assets/mock-data/mock-data.json   48 bytes          [emitted]
  assets/icon/android-icon-144x144.png    8.43 kB          [emitted]
  assets/icon/android-icon-192x192.png    9.71 kB          [emitted]
    assets/icon/android-icon-36x36.png     2.3 kB          [emitted]
    assets/icon/android-icon-48x48.png    2.92 kB          [emitted]
    assets/icon/android-icon-72x72.png    4.23 kB          [emitted]
    assets/icon/android-icon-96x96.png     5.6 kB          [emitted]
    assets/icon/apple-icon-114x114.png    6.55 kB          [emitted]
    assets/icon/apple-icon-120x120.png    6.92 kB          [emitted]
    assets/icon/apple-icon-144x144.png    8.43 kB          [emitted]
    assets/icon/apple-icon-152x152.png    8.99 kB          [emitted]
                      assets/data.json   33 bytes          [emitted]
      assets/icon/apple-icon-57x57.png     3.4 kB          [emitted]
      assets/icon/apple-icon-60x60.png    3.56 kB          [emitted]
      assets/icon/apple-icon-72x72.png    4.23 kB          [emitted]
      assets/icon/apple-icon-76x76.png    4.46 kB          [emitted]
assets/icon/apple-icon-precomposed.png    10.3 kB          [emitted]
            assets/icon/apple-icon.png    10.3 kB          [emitted]
         assets/icon/browserconfig.xml  282 bytes          [emitted]
         assets/icon/favicon-16x16.png    1.52 kB          [emitted]
         assets/icon/favicon-32x32.png    2.07 kB          [emitted]
         assets/icon/favicon-96x96.png     5.6 kB          [emitted]
               assets/icon/favicon.ico    1.15 kB          [emitted]
       assets/icon/ms-icon-144x144.png    8.43 kB          [emitted]
       assets/icon/ms-icon-150x150.png    8.88 kB          [emitted]
       assets/icon/ms-icon-310x310.png    24.1 kB          [emitted]
         assets/icon/ms-icon-70x70.png    4.12 kB          [emitted]
           assets/img/angular-logo.png      19 kB          [emitted]
    assets/img/angularclass-avatar.png    32.8 kB          [emitted]
      assets/img/angularclass-logo.png    36.7 kB          [emitted]
    + 1 hidden modules

ERROR in ./src/webpack.entry.bundle.ts
Module parse failed: D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\happypack\lib\HappyLoader.js?id=ts!D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\src\webpack.entry.bundle.ts Unexpected token (1:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:8)
    at Parser.pp.raise (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:920:13)
    at Parser.pp.unexpected (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:1483:8)
    at Parser.pp.expect (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:1477:26)
    at Parser.pp.parseExprList (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:647:12)
    at Parser.pp.parseExprAtom (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:309:28)
    at Parser.pp.parseExprSubscripts (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:225:19)
    at Parser.pp.parseMaybeUnary (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:204:17)
    at Parser.pp.parseExprOps (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:151:19)
    at Parser.pp.parseMaybeConditional (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:133:19)
    at Parser.pp.parseMaybeAssign (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:110:19)
    at Parser.pp.parseExpression (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:86:19)
    at Parser.pp.parseStatement (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:1753:23)
    at Parser.pp.parseTopLevel (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:1648:21)
    at Parser.parse (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:1616:17)
    at Object.parse (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\acorn\dist\acorn.js:882:44)
    at Parser.parse (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\lib\Parser.js:902:15)
    at DependenciesBlock.<anonymous> (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\lib\NormalModule.js:104:16)
    at DependenciesBlock.onModuleBuild (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
    at nextLoader (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
    at D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:292:15
    at context.callback (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:148:14)
    at D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\happypack\lib\HappyLoader.js:44:5
    at HappyPlugin.compileInBackground (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\happypack\lib\HappyPlugin.js:266:12)
    at HappyPlugin.compile (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\happypack\lib\HappyPlugin.js:255:17)
    at Object.HappyLoader (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\happypack\lib\HappyLoader.js:23:15)
    at WEBPACK_CORE_LOADER_EXECUTION (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:155:71)
    at runSyncOrAsync (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:155:93)
    at nextLoader (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:290:3)
    at D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
    at Storage.finished (D:\Source\POC\ASP.Net.Core1.Angular2.Webpack.Starter\src\starterproject\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)

When I specify manually, it works fine with no error.

amireh commented 8 years ago

awesome-typescript-loader doesn't really work with HappyPack yet I'm surprised you got this far... see #33 .

By the way, if you have that many happy plugins, you should really use a shared thread pool of, say, 5 threads instead of the 24 you're using! That's an overkill and it will likely be slower. See https://github.com/amireh/happypack#shared-thread-pools for more information

amireh commented 8 years ago

Okay gonna close this one as there's no real harm done, the inferLoaders is a convenience and if it doesn't work we can just resort to the manual plugin approach.

Thanks for reporting! :)

IAMtheIAM commented 8 years ago

@amireh Thanks for the tip about shared threads, I didn't realize it was 3 PER happypack instance, I thought it was sharing 3 already! Now it makes sense. I'll follow the thread #33 for updates on typescript integration.