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

[fork] return a multi-compiler setup rather than fork behaviour. #876

Closed
ringods opened this issue May 17, 2018 · 2 comments
Closed

[fork] return a multi-compiler setup rather than fork behaviour. #876

ringods opened this issue May 17, 2018 · 2 comments

Comments

@ringods
Copy link
Contributor

ringods commented May 17, 2018

Bug or issue?

Please try to answer the following questions:

  • neutrino 8.2.3
  • Building my own preset: https://github.com/ringods/neutrino-hugo-preset
  • npm 5.6.0
  • node 9.11.1
  • MacOS X 10.13.4
  • Trying to use @neutrinojs/fork programmatically as webpack multi-compiler
  • Expected: Neutrino spitting out a list with 2 (or more) configs
  • Actual: Neutrino running two webpacks itself. This is not the same as multi-compiler.

Feature request or enhancement?

Webpack has the multi-compiler option, where you export a list of webpack configs and Webpack runs them all. The current implementation is that the fork package expects all settings for each of the configs upfront.

When using fork programmatically in my own preset, the middleware directly forks child processes. If I look at the unit tests for most other presets, it executes validations on the generated webpack config. Would it be possible to have a similar setup for fork? So drop the forking but just generate a list of webpack configs.

Some template code:

module.exports = (neutrino, opts = {}) => {
  var site_config = hugo.loadHugoConfig()

  neutrino.use('@neutrinojs/fork', [ callback1, callback2 ]

function callback1 (neutrino, opts = {}) {
  // child neutrino generating the first config
}

function callback2 (neutrino, opts = {}) {
  // child neutrino generating the second config
}

The parent neutrino.config.toConfig() would result in:

[
  { 
     entry: { ... },
     output: { ... },
     ...
  },
  {
     entry: { ... },
     output: { ... },
     ...
  }
]

before being passed on to Webpack as usual.

@eliperelman
Copy link
Member

eliperelman commented May 17, 2018

See #308 and #385 for some history here. Given the v8 architecture, it was very hard to make multiple configs a thing, and we landed on the fork middleware. I don't think it would be feasible to make the fork middleware do this.

Now, with #852 in progress, the fork middleware will go away, and it should be possible to return multiple configs for webpack. So yes, we want to support doing multiple builds, but not via the fork middleware.

Closing as a solution is in progress. Thank you for the issue!

@edmorley
Copy link
Member

@ringods, Hi! We've just released a Neutrino 9 beta, which makes it possible to export multiple configs from webpack.config.js - if you'd like to try it out? See #1129.

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

No branches or pull requests

3 participants