GithubHelp home page GithubHelp logo

parallel-webpack's People

Contributors

alan-agius4 avatar anilanar avatar benoitzugmeyer avatar byara avatar chenesan avatar clownay avatar eaglus avatar efegurkan avatar gandazgul avatar lime avatar luixo avatar natedanner avatar nickpresta avatar pago avatar rjanjic avatar robbilie avatar styfle avatar valscion avatar wkich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parallel-webpack's Issues

JSON.stringify, RangeError: Invalid String Length

Hi!

Thanks for this tool!! It has sped up our compilations for webpack immensely.

We are using Angular, and the amount of webpack work Angular does is huge. We do inmemory compilation of TypeScript and NGC, and other optimizations, and it gets up past 4GB of compilation.

We specify --max-old-space-size to node to complete the compilation. I assume this is passed along in the Node workers, correct?

Also, we are hitting this error on JSON.stringify, when stats: true is set on the run() method.

internal/child_process.js:626
    var string = JSON.stringify(message) + '\n';
                      ^

RangeError: Invalid string length
    at Object.stringify (native)
    at process.target._send (internal/child_process.js:626:23)
    at process.target.send (internal/child_process.js:538:19)

I am pretty sure this is due to a huge stats object being passed in. Thoughts on how to get this to not crash?

Thanks!
Joe

CTRL-C with `--max-retries=0` doesn't kill all processes

I'm running four webpack builds in parallel and occasionally have to terminate early by pressing CTRL-C.

When I press CTRL-C, I see the output about forcefully shutting down the child processes, but the main process stays alive and hangs without exiting. I need to press CTRL-C 1-2 more times to kill everything. I can verify that --max-retries=0 is getting correctly passed in. FWIW, one of my builds finishes rather quickly and the other three are longer running, so usually the SIGINT is sent after the first one is complete. Looks like if I CTRL-C quick enough before any builds have finished, the processes all terminate as expected.

Here is some example output from CTRL-C'ing later in the build:

^C[WEBPACK] Forcefully shutting down

(node:38167) Warning: a promise was rejected with a non-error: [object Object]
[WEBPACK] Build failed after 1.783 seconds
(node:38167) Warning: a promise was rejected with a non-error: [object Object]
(node:38167) Warning: a promise was rejected with a non-error: [object Object]
[WEBPACK] Forcefully shut down [name].js
CSPEER:(myBranch ⚡)$ events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: channel closed
    at process.target.send (internal/child_process.js:540:16)
    at callback (/Users/cspeer/repos/my-repo/node_modules/worker-farm/lib/child/index.js:29:17)
    at process.shutdownCallback (/Users/cspeer/repos/my-repo/node_modules/parallel-webpack/src/webpackWorker.js:96:17)
    at emitNone (events.js:86:13)
    at process.emit (events.js:185:7)
    at Signal.wrap.onsignal (internal/process.js:199:44)

CSPEER:(myBranch ⚡)$ events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: channel closed
    at process.target.send (internal/child_process.js:540:16)
    at callback (/Users/cspeer/repos/my-repo/node_modules/worker-farm/lib/child/index.js:29:17)
    at process.shutdownCallback (/Users/cspeer/repos/my-repo/node_modules/parallel-webpack/src/webpackWorker.js:96:17)
    at emitNone (events.js:86:13)
    at process.emit (events.js:185:7)
    at Signal.wrap.onsignal (internal/process.js:199:44)
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: channel closed
    at process.target.send (internal/child_process.js:540:16)
    at callback (/Users/cspeer/repos/my-repo/node_modules/worker-farm/lib/child/index.js:29:17)
    at process.shutdownCallback (/Users/cspeer/repos/my-repo/node_modules/parallel-webpack/src/webpackWorker.js:96:17)
    at emitNone (events.js:86:13)
    at process.emit (events.js:185:7)
    at Signal.wrap.onsignal (internal/process.js:199:44)

This is more of an annoyance than anything else most of the time, but sometimes results in stray processes left running. Not sure if this is an issue with worker farm or parallel-webpack's own worker management.

Adjust documentation regarding createVariants baseOptions parameter

As discovered in #3 the documentation is unclear about what the baseOptions parameter for the createVariants utility is doing.
That effect is increased by using a valid Webpack configuration option (devtool) as the option name and then not actually using it within the configuration creation callback.

We should adjust the documentation to explain more clearly what that parameter is intended to be used for and also use a different option name (i.e. preferredDevTool) which ideally should be read from the environment and then we also need to make sure that the option is actually used within the callback.

Change default for max-retries to 0

The max-retries option can easily cause confusion and leftover processes when combined with webpacks watch mode.

As max-retries is rarely useful, it makes sense to set its default value to 0.

On complete hook

Is there any way to determine when building has been completed? I'm launching the app using OpenBrowserPlugin but I don't know when it's completed all parallel builds.

Expose API that takes array of webpack configs

Assume I have an array of unrelated, handcrafted webpack configurations. I would like to run them in parallel using parallel-webpack node.js API. For example if run function took an array of configs instead of config paths, it would somewhat work for me.

My proposal is to have a lower level API for running array of configs that is reused by the actual run function that takes config path.

Array of promises vs promise of the array

Explain the problem

When using webpack you can return promise from webpack config function. If you want multiple configurations you need to return a promise that returns an array of configs. parallel-webpack instead works only if you return array of promises.
This breaks compatibility with webpack and webpack-dev-server

Expected Behaviour

parallel-webpack should work same as webpack and correctly handle promise that returns array of configs.

Actual Behaviour

parallel-webpack sees only one target and then crashes because of error:
Unhandled rejection TypeError: Cannot read property 'filename' of undefined

Steps to reproduce

Create webpack config that returns promise that resolves to array instead of array of promises.

Provide your webpack config

module.exports = (env) => {
  return getTranslations().then(allTranslations => langs
    .map(lang => translations: allTranslations[lang])
    .map(translations => {
      return {
        entry: ...
        ...
      }
  }))
}

Provide your Environment details

  • Node version: 9.4.0
  • Operating System: Windows 10
  • webpack version: 3.6.0
  • parallel-webpack version: 2.2.0

Incorrect behavior with watch option.

For now webpack workers build and start watch only for first maxConcurrentCallsPerWorker * maxConcurrentWorkers variants. Rest variants never builds until we press Ctrl+C and stop watching first variants.

I don't know how to fix this.

Support for dynamic configurations??

Is it possible to pass configuration array to the 'run' method. Currently it only takes configuration file name(as string).
I have a scenario where I need to dynamically create configurations and kickstart webpack bundling.

EventEmitter memory leak warnings

I get a huge amount EventEmitter warnings when running with either Webpack 1.x or 2.x:

(node:10856) Warning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added. Use emitter.setMaxListeners() to increase limit
(node:10867) Warning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added. Use emitter.setMaxListeners() to increase limit
(node:10856) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10867) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10856) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10855) Warning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added. Use emitter.setMaxListeners() to increase limit
(node:10867) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10855) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10856) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10849) Warning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added. Use emitter.setMaxListeners() to increase limit
(node:10849) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10867) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10855) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10849) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10855) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
(node:10849) Warning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit

I'm using NodeJS 6.8.1 on Ubuntu 16.04 with parallel-webpack 1.5.0. I do not get any warnings running webpack normally.

I imagine that these items may be the cause:

I suspect that there's no real issue here, but the warnings are unsightly. Very happy that it works with Webpack2.

Can you support --bail and --json flags?

My current build requires these two flags provided by the webpack binary. Is there some way I can get the same effect from parallel-webpack? Here is the full command:

$(npm bin)/webpack --colors --config config/webpack/production.config.js --json --bail 2>&1

Upcoming release - 3.x

Hey everyone,

We are in process of rewriting the workers with jest-worker in favor of simplifying the code base and getting rid of the zombie leftover process issues.

You can try and give feedback on our latest alpha release currently: 3.0.0-alpha.2. Keep in mind it is still in progress a lot of things are not working as expected.

We will drop support for some features initially. Either because of we don't have any internal usages left for it or some features that were coming from node-worker-farm does not exist on jest-worker. Some of them we may re-introduce in time. If you are relying on that features you can still use 2.x versions. PR's and feedback are very much appreciated as always.

Cheers,

Branch

Pass config directly to Node API

Doing this would allow for a lot more freedom when it comes to configurations, for example depending on when mine is run my config slightly changes meaning that it needs to be a function that can be executed rather than simply required in which causes problems when coming to use this package.

Expose compiler plugin API

Explain the problem

I use karma-webpack for testing, and there is no karma-parallel-webpack plugin. My code gets built three times -- during build (using parallel-webpack), and twice more for two test suites. I can't (easily) write a karma-parallel-webpack plugin, because parallel-webpack doesn't expose the compiler/compiler.plugin API that karma-webpack relies on.

What is involved in exposing this API? It seems like it would involve lots of message-passing.

Add documentation for configurable configurations

parallel-webpack version 1.2.0 added support for using process.argv within the webpack.config.js by forwarding it consistently. This should serve the same purpose as the fork that @ascbfgwewe created (input welcome!) but it is currently still lacking documentation.

CommonsChunkPlugin

Hi,

Today my webpack config has around 10 entries and I use the CommonsChunkPlugin to generate a common.js file. Is it possible to use CommonsChunkPlugin with parallel-webpack?

Do I have to change my webpack config from a object with many entries to an array like you do in your example?

Best regards,
Kenneth

WatchOptions.ignored

Hi!

I use the parallel-webpack watch feature, but it seems to watch all files in my filesystem. Also, it doesn't seem to respect the setting: watchOptions.ignored in my webpack config when set.

Is there a way to get this in parallel-webpack as well? I can consider a PR when I find some time. Maybe it already supports this and I am not setting it up correctly?

Thanks!

Webpack 2 config export as function

I've seen the other two issues about webpack 2 but this one is slightly more specific;

You can now export a function as your webpack config file which is their recommended way of doing so if you want to use custom command arguements.

module.exports = function(env) {
  var customStuff = env.customStuff;
  /* ... */
  return config;
};

I believe parallel-webpack expects an object so this isn't supported. Is this something you would consider? Without knowing the code inside out I believe it's a straightforward amend.

[name] logging

I have an environment where I build 3 entry points and use '[name]' for output, so I set up the parallel with variants. It's working great, build time went down and the config was easily shared. Good stuff! Only downside is that in the console the processes are all logged as '[name] started ...'.

I can't really use an extra variant property (ex. name) because I'm only interested in those 3 builds, the others would only provide overhead, or am I missing something crucial here? If not, I think it would be fairly easy to implement some sort of name resolver / fallback, something like:

// webpackWorker.js
function getAppName(webpackConfig) {
    var entryName = webpackConfig.name || webpackConfig.output.filename;
    return entryName.indexOf('[name]') === -1 ? entryName : entryName.replace('[name]', Object.keys(webpackConfig.entry));
}

using babel-loader

I am wondering if this tool allows using various kinds of module loaders such as babel-loader, I tried to use that with babel-loader, but it seems skip the loader and not understand ES6 in the build.

Improve UI

We can probably utilize Listr (https://www.npmjs.com/package/listr) to generate a much cleaner UI with a --verbose flag that allows switching back to the current UI.

While the information that we print is useful in some cases, most commonly the only interesting part is knowing when a build starts/is finished.

Multi-Variant CommonChunks

Although #1 is closed, I might believe there is a follow-up use case for a "common" chunk across all variants. So: When a given module is the same in all variants, it gets extracted to a "common" chunk. Opposed to that, the current behaviour creates one "common" chunk for each variant, dropping potential re-use of chunks across multivariant environments quite a bit.

Think of our trivago use case: A user on trivago.ae switching from the LTR to the RTL layout of that page would have to re-download each of the chunks, although only relatively little may actually be altered.

And no: I have not the slightest idea how to achieve this given the current code.

some childprocesses don't get killed when quitting

in a current project of mine, i have 12 builds running in watch mode. every now and then, when i quit watch mode (ctrl+c), some of the child processes keep staying alive, leading to a couple of them running at the end of the day.

now that i am aware of this, i kill them manually each time i stop watch mode, but obviously, that should not be the way to handle that.

can i change anything in my setup to prevent this in the first place? are there any known bugs unfortunately i cannot share any project details...

Edit: Using latest version 1.6.1

Watcher for 'npm start' gives wrong statistics about build time

When using 'npm start' it seems that the statistics for build times are adding up on the start time of the watcher when it was initially fired up.

This leads to
[WEBPACK] Finished building es5.ltr within 787.011 seconds
[WEBPACK] Finished building es5.ltr within 811.579 seconds
even though the builds just took a few mseconds.

[Question] Does it work with webpack dev server or middleware ?

In dev mode, webpack dev server or webpack dev middleware delivers great performance by not writing assets to disk. However, it would be awesome if it would also compile the entry points in parallel(I have about 3 of them). Does parallel-webpack work with these 2 ? Could it be made to work with them if not ?

Watch usage with server startup

I'm really interested in using this package for bundling our client/server scripts in parallel, however, I am struggling with how to go about orchestrating running the builds, with watch enabled, and starting our server.

ex. Webpack Bundles -> Server Startup -> Watcher Start

Do you have any thoughts on this topic?

Using a config object directly instead of configPath?

Is this built in such a way that you can only supply a path to a Webpack config file and not an object containing the configuration? Glancing at the code, it seems that way, but I wanted to ask in case I was missing something. Thanks!

Support argv as second config param

Explain the problem

Sometimes a developer wants to access webpacks internal command line options in his config.

Expected Behaviour

The config function should pass two params into the config function:

  • An environment as the first parameter. See the environment options CLI documentation for syntax examples.
  • An options map (argv) as the second parameter. This describes the options passed to webpack, with keys such as output-filename and optimize-minimize.

source

Actual Behaviour

parallel-webpack omits the second param (argv).

Provide your webpack config

module.exports = (env, argv) => {
     console.log('isEnvSet', !!env)
     console.log('isArgvSet', !!argv)
     return {}
}

Steps to reproduce

Use the config above and run:

parallel-webpack --config=webpack.config.js

Provide your Environment details

  • Node version: v9.1.0
  • Operating System: MacOS 10.13.3
  • webpack version: 3.11.0
  • parallel-webpack version: 2.3.0

After ctrl+c build/watch restarts

After upgrading to 1.6.0 from 1.3.1 my build (with --watch arg) restarts in the background when I ctrl+c the currently running one. BTW I'm on webpack 2.2.0-rc.2.

Add timestamp for continously rebuilds with the watcher in the console output

It would be nice, if you could also add an time stamp for the current build to the console output for the continously rebuilds via the watcher. If you running the watcher for a long time, then it is easy to loose the overview of your rebuilds.
Sometimes I am not sure when I am touching some code and the watcher is turned on, if the latest changes are already built or are still in building.

Best regards,
Chris

Don't let SIGINT output errors

At my organization, we currently parallelize four configs. It has resulted in console outputs multiplied by 4 when building with webpack or starting a watch task.
I managed to make most of the logs silent with the json option. But, when shutting down the process with Ctrl+C (SIGINT), I still get 4 log messages that bleed out in the next prompt.

Worker Farm: Received message for unknown child. This is likely as a result of premature child death, the operation will have been re-queued.
Worker Farm: Received message for unknown child. This is likely as a result of premature child death, the operation will have been re-queued.
Worker Farm: Received message for unknown child. This is likely as a result of premature child death, the operation will have been re-queued.
➜  my-app git:(yg/better-logs) ✗ Worker Farm: Received message for unknown child. This is likely as a result of premature child death, the operation will have been re-queued.

Would it be possible to make those silent as well?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.