Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Cannot use happypack in a chain with other loader. #32

Closed
Strate opened this issue Apr 18, 2016 · 9 comments
Closed

Cannot use happypack in a chain with other loader. #32

Strate opened this issue Apr 18, 2016 · 9 comments

Comments

@Strate
Copy link

Strate commented Apr 18, 2016

Trying yo implement this:

loaders: [
  "happypack/loader?id=babel"
  "ts-loader"
]

causes to call babel on non-transpiled typescript file.

@amireh
Copy link
Owner

amireh commented Apr 18, 2016

Hmm, yeah that is reasonable because up until now we assume happypack is running as the fore-most loader (it can chain up to other loaders but not the other way around, which is more complicated when pitch loaders are in play.)

Is there any reason you don't want to use ts-loader inside of happypack too? It is supported.

@Strate
Copy link
Author

Strate commented Apr 18, 2016

Hmm, seems that I have missed something, but you have said that ts-loader is not supported because loader uses private _compiler api, with hooking into compiler by adding after-compile plugin. Is it realy supported?

@amireh
Copy link
Owner

amireh commented Apr 18, 2016

Oh, I'm sorry. I mixed those up. You're totally right, only the linter is supported. I'll take a look at this when I have the time.

Did you try using ts-loader as a preLoader and have happypack be in the main loaders array?

@Strate
Copy link
Author

Strate commented Apr 18, 2016

Omg, no:-) How it could works? Seems that happypack works only with file, stored on disk, not with a string, passed from another loader. Did webpack preLoader rewrites file?

@Strate
Copy link
Author

Strate commented Apr 18, 2016

Just tried this config:

module: {
    preLoaders: [
      {
        test: /\.tsx?$/,
        include: srcDir,
        loaders: [
          "ts-loader",
          "tslint-loader"
        ],
      }
    ],

    loaders: [
      {
        test: /\.tsx?$/,
        include: srcDir,
        loaders: [
          "happypack/loader?id=babel"
        ],
      },
    ]

same error: hapypack starts on non-transpiled tsx file

@amireh
Copy link
Owner

amireh commented Apr 18, 2016

No no :) it wouldn't make sense for it to work currently, but I'm wondering if that's the way to go.

We can make HappyPack skip reading the source from disk using some flag (that is, also skip the pitching phase, because webpack doesn't read the source until the pitching phase is done). We would use that flag in such cases where we know there are no pitching loaders - ts-loader doesn't pitch.

The config would be something like:

module: {
  loaders: [{
    test: /\.tsx?$/,
    loaders: [ 'happypack/loader?id=babel', 'tslint', 'ts' ]
  }]
},
plugins: [
  new HappyPack({
    id: 'babel',
    readSourceFromDisk: false // or something
  }]
]

This way, HappyPack would use a temp file to store the initial contents and read that temp file instead of the source file in its background processes (because I don't think it's a good idea to send such big blobs across the process sockets.)

@Strate
Copy link
Author

Strate commented Apr 18, 2016

Maybe there is any way to check that happypack's loader is the loader first in a chain?

@amireh
Copy link
Owner

amireh commented May 26, 2016

What's the status on this? I believe HappyPack has started accepting the source from the loader chain instead of disk since a7c4dff - is this still valid?

@amireh
Copy link
Owner

amireh commented Jun 19, 2016

Closing as I believe this was fixed. For ts-loader support we have a different thread.

@amireh amireh closed this as completed Jun 19, 2016
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

2 participants