@dotcom-tool-kit/webpack 1.3.0 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import { Logger } from 'winston';
1
2
  import type { WebpackOptions } from '@dotcom-tool-kit/types/lib/schema/webpack';
2
- export default function runWebpack(options: WebpackOptions): Promise<void>;
3
+ export default function runWebpack(logger: Logger, options: WebpackOptions): Promise<void>;
3
4
  //# sourceMappingURL=run-webpack.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-webpack.d.ts","sourceRoot":"","sources":["../src/run-webpack.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAI/E,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBzE"}
1
+ {"version":3,"file":"run-webpack.d.ts","sourceRoot":"","sources":["../src/run-webpack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAK/E,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CASzF"}
@@ -1,22 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const child_process_1 = require("child_process");
4
+ const logger_1 = require("@dotcom-tool-kit/logger");
4
5
  const webpackCLIPath = require.resolve('webpack-cli/bin/cli');
5
- function runWebpack(options) {
6
- return new Promise((resolve, reject) => {
7
- const child = (0, child_process_1.fork)(webpackCLIPath, [
8
- 'build',
9
- `--mode=${options.mode}`,
10
- options.configPath ? `--config=${options.configPath}` : ''
11
- ]);
12
- child.on('exit', (code) => {
13
- if (code === 0) {
14
- resolve();
15
- }
16
- else {
17
- reject(new Error(`Webpack returned an error`));
18
- }
19
- });
20
- });
6
+ function runWebpack(logger, options) {
7
+ logger.info('starting Webpack...');
8
+ const args = ['build', '--color', `--mode=${options.mode}`];
9
+ if (options.configPath) {
10
+ args.push(`--config=${options.configPath}`);
11
+ }
12
+ const child = (0, child_process_1.fork)(webpackCLIPath, args, { silent: true });
13
+ (0, logger_1.hookFork)(logger, 'webpack', child);
14
+ return (0, logger_1.waitOnExit)('webpack', child);
21
15
  }
22
16
  exports.default = runWebpack;
@@ -5,7 +5,7 @@ const types_1 = require("@dotcom-tool-kit/types");
5
5
  const run_webpack_1 = (0, tslib_1.__importDefault)(require("../run-webpack"));
6
6
  class WebpackDevelopment extends types_1.Task {
7
7
  async run() {
8
- await (0, run_webpack_1.default)({
8
+ await (0, run_webpack_1.default)(this.logger, {
9
9
  ...this.options,
10
10
  mode: 'development'
11
11
  });
@@ -5,7 +5,7 @@ const types_1 = require("@dotcom-tool-kit/types");
5
5
  const run_webpack_1 = (0, tslib_1.__importDefault)(require("../run-webpack"));
6
6
  class WebpackProduction extends types_1.Task {
7
7
  async run() {
8
- await (0, run_webpack_1.default)({
8
+ await (0, run_webpack_1.default)(this.logger, {
9
9
  ...this.options,
10
10
  mode: 'production'
11
11
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcom-tool-kit/webpack",
3
- "version": "1.3.0",
3
+ "version": "1.4.3",
4
4
  "main": "lib",
5
5
  "description": "",
6
6
  "author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
@@ -17,7 +17,9 @@
17
17
  "test": "cd ../../ ; npx jest --silent --projects plugins/webpack"
18
18
  },
19
19
  "dependencies": {
20
- "@dotcom-tool-kit/types": "^1.3.0",
20
+ "@dotcom-tool-kit/error": "^1.4.3",
21
+ "@dotcom-tool-kit/logger": "^1.4.3",
22
+ "@dotcom-tool-kit/types": "^1.4.3",
21
23
  "webpack-cli": "^4.6.0"
22
24
  },
23
25
  "peerDependencies": {
@@ -26,7 +28,8 @@
26
28
  "devDependencies": {
27
29
  "@jest/globals": "^27.4.6",
28
30
  "ts-node": "^10.0.0",
29
- "webpack": "^4.42.1"
31
+ "webpack": "^4.42.1",
32
+ "winston": "^3.5.1"
30
33
  },
31
34
  "files": [
32
35
  "/lib",