Comments (5)
Is this a tested/support configuration?
First time I've heard about this feature, no I haven't really tested this.
Any ideas on what's happening?
It could be that if webpack is creating only 1 compiler for those builds then HappyPack will run only on the first build, because right now it's coded to stop after the initial build unless we're in watch mode (and in this case, we're not in watch mode, but there are two "initial" builds.)
That's just a wild guess though. We can take a look at this.
from happypack.
I'm not too familiar with the multi-compiler mode in Webpack, but if it helps at all, here is how I'm running concurrent builds (with HappyPack) for 12 different environments:
gulp.task('compile:all', function(done) {
const promises = configs.map(
config => new Promise((resolve, reject) => {
webpack(config, (err, stats) => {
if (err) reject(err);
else resolve(stats)
})
})
)
Promise.all(promises)
.then(stats => done(null))
.catch(error => done(error))
})
There are some issues with process file limits on OS X. Might be worth looking into spawning child processes or some other workaround.
from happypack.
I've just tried this in a simple example and it seems to work fine for me. Make sure you're not using shared thread pools between the builds since each provides a different compiler and that won't work.
var path = require('path');
var HappyPack = require('../../');
var HAPPY_LOADER = path.resolve(__dirname, '../../loader.js');
var IDENTITY_LOADER = path.resolve(__dirname, './identity-loader.js');
module.exports = [
{
entry: path.resolve(__dirname, 'lib/a.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new HappyPack({
id: 'happy-build-1',
loaders: [ IDENTITY_LOADER ],
threads: 2
})
],
module: {
loaders: [
{
test: /\.js$/,
loader: HAPPY_LOADER + '?id=happy-build-1',
}
]
},
},
{
entry: path.resolve(__dirname, 'lib/a.js'),
output: {
path: path.resolve(__dirname, 'dist-2'),
filename: '[name].js'
},
plugins: [
new HappyPack({
id: 'happy-build-2',
loaders: [ IDENTITY_LOADER ],
threads: 2
})
],
module: {
loaders: [
{
test: /\.js$/,
loader: HAPPY_LOADER + '?id=happy-build-2',
}
]
},
}
];
Closing this since I can't reproduce and no context was provided.
from happypack.
Here:
webpack.config.js
'use strict'
const path = require('path')
const webpack = require('webpack')
const commonConfig = require('./config.js')
let configs = []
const common = commonConfig()
const config1 = Object.assign(
{},
common,
{
entry: './app.coffee',
output: {
path: path.join(__dirname, 'dest'),
filename: 'mobile.js'
},
plugins: common.plugins.concat(
new webpack.DefinePlugin({
ENV: JSON.stringify('mobile')
})
)
}
)
configs.push(config1)
const config2 = Object.assign(
{},
common,
{
entry: './app.coffee',
output: {
path: path.join(__dirname, 'dest'),
filename: 'desktop.js'
},
plugins: common.plugins.concat(
new webpack.DefinePlugin({
ENV: JSON.stringify('desktop')
})
)
}
)
configs.push(config2)
module.exports = configs
config.js
'use strict'
const HappyPackPlugin = require('happypack')
module.exports = () => {
return {
module: {
loaders: [
{ test: /\.coffee$/, loader: 'happypack/loader?id=coffeescript' },
]
},
plugins: [
new HappyPackPlugin({
id: 'coffeescript',
threads: 4,
loaders: ['coffee-loader'],
verbose: false
})
]
}
}
app.coffee
console.log 'ENV: ', ENV
expected: dist/mobile.js
and dist/desktop.js
from happypack.
Try to avoid reusing the common config instance.. just create the common config twice since it's a factory anyway, a la:
const config1 = Object.assign({}, common(), { ... });
const config2 = Object.assign({}, common(), { ... });
Then you end up with 2 actually unique HappyPlugin instances as opposed to sharing one.
from happypack.
Related Issues (20)
- It works in CSS, but it doesn't work in Babel HOT 2
- webpack4 is more slower?
- How do you remove the happypack cache? HOT 5
- The translation of thread and process
- can't resolve module "happypack/loader"
- not support SASS-LOADER implementation HOT 4
- [email protected] new webpack api support request
- Channel closed HOT 2
- happypack and scoped/postcss-loader conflict?
- Non-deterministic build output when used with ts-loader
- customized babel plugin throw an error
- Cannot read property 'normal' of undefined HOT 5
- Example references missing example-utils repo
- How to use in webpack-chain
- unable to locate the plugin list! This most likely indicates an internal error. HOT 5
- Happypack v5.0.0 breaking emoji-mart v3.0.0
- build error HOT 2
- Happypack semver issue
- Loaded 0 entries from cache. (0 were stale)
- Why not give it a more specific name, such as multi-thread-pack? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from happypack.