Skip to content
This repository was archived by the owner on Feb 7, 2022. It is now read-only.

Handle config function return promise of config object array #84

Merged

Conversation

chenesan
Copy link
Contributor

For #76 .
I've changed a little how startFarm and webpackWorker get config and added a test for config function return promise of config object array.
After the change, there are some tests get failed. And I'm not sure how to handle them. @pago @efegurkan I need some advices about them:

webpackWorker.spec.js

  • webpackWorker › arguments › multi config options › should fail if expectedConfigLength > 1 in case of single config
  • webpackWorker › arguments › multi config options › should fail if expectedConfigLength dont match with config.length

This two all expect Promise.reject will be called when call webpackWorker function. Before this change they will be called immediately. But since we have to get the config array after promise resolved,
I move the config length checking part into the then part, so they will not be called immediately and we cannot check the mock synchronously. I have tried checking calls asynchronously in test (webpackWorker.then(...)) but it seems that webpackWorker will not finish until jest test time out.

index.spec.js

  • index.js › run › error callback › should log and reject with error
  • index.js › run › then callback › should filter non-truthy and return results
  • index.js › run › shutdownCallback › should call end and remove callback

The above three snapshot tests will lose one line "[WEBPACK] Building 1 target" since we have to move the console.log into promise(again now we have to resolve config function promise before we know its length). Not sure if it's ok to pass those snapshot tests.

@paales
Copy link

paales commented Apr 29, 2019

@chenesan Any updates on this?

@chenesan
Copy link
Contributor Author

chenesan commented May 7, 2019

I may try to take a look again this week.

@chenesan chenesan force-pushed the resolve-config-func-return-promise-of-array branch from 5cae89e to 72f3733 Compare May 7, 2019 01:49
@chenesan chenesan force-pushed the resolve-config-func-return-promise-of-array branch from 72f3733 to 4c39c80 Compare May 8, 2019 01:50
@coveralls
Copy link

coveralls commented May 8, 2019

Coverage Status

Coverage decreased (-3.4%) to 83.524% when pulling 8d7df7b on chenesan:resolve-config-func-return-promise-of-array into 66da53e on trivago:master.

@chenesan
Copy link
Contributor Author

chenesan commented May 8, 2019

@pago I just fixed the tests and it's ok to review it :-) You could also test it by manually create a minimal config file which is a function return promise of config array and run ./bin/run:

/* webpack.config.js */
var path = require('path');
module.exports = () => Promise.resolve([{
    entry: './pageA.js',
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: 'pageA.bundle.js'
    }
}, {
    entry: './pageB.js',
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: 'pageB.bundle.js'
    }
}]);

@chenesan chenesan changed the title [WIP] handle config function return promise of config object array Handle config function return promise of config object array May 8, 2019
@pago
Copy link
Contributor

pago commented May 8, 2019

Looks very good to me. Thank you for the time you put into building this feature!

@byara could you please also take a look? Then we can proceed with merging and releasing this feature. :)

@byara
Copy link
Contributor

byara commented May 9, 2019

Thank you @chenesan, good work 👍
@pago It looks good to me :)

@chenesan
Copy link
Contributor Author

Hi @pago and @byara sorry for pinging, anything I could do to help proceeding?

@pago pago merged commit afeb3d3 into trivago:master Jun 3, 2019
@pago
Copy link
Contributor

pago commented Jun 3, 2019

Hi @chenesan , I'm sorry I didn't manage to take care of this before my vacation. I'll release it in a moment.

@pago
Copy link
Contributor

pago commented Jun 3, 2019

Released as 2.4.0

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

Successfully merging this pull request may close these issues.

5 participants