@atls/webpack-start-server-plugin 0.0.7 → 1.0.0

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.
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export * from './start-server.plugin';
2
- //# sourceMappingURL=index.d.ts.map
1
+ export * from './start-server.plugin.js';
package/dist/index.js CHANGED
@@ -1,18 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./start-server.plugin"), exports);
18
- //# sourceMappingURL=index.js.map
1
+ export * from "./start-server.plugin.js";
@@ -1,4 +1,4 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import type { Writable } from 'node:stream';
3
3
  export interface StartServerLoggerOptions {
4
4
  stdout?: Writable;
@@ -10,4 +10,3 @@ export declare class StartServerLogger {
10
10
  info(body: string): void;
11
11
  error(error: Error): void;
12
12
  }
13
- //# sourceMappingURL=start-server.logger.d.ts.map
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StartServerLogger = void 0;
4
- class StartServerLogger {
5
- options;
1
+ export class StartServerLogger {
6
2
  constructor(options = {}) {
7
3
  this.options = options;
8
4
  }
@@ -30,5 +26,3 @@ class StartServerLogger {
30
26
  }
31
27
  }
32
28
  }
33
- exports.StartServerLogger = StartServerLogger;
34
- //# sourceMappingURL=start-server.logger.js.map
@@ -1,9 +1,9 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
3
  import type { ChildProcess } from 'node:child_process';
4
4
  import type { Writable } from 'node:stream';
5
5
  import type webpack from 'webpack';
6
- import { StartServerLogger } from './start-server.logger';
6
+ import { StartServerLogger } from './start-server.logger.js';
7
7
  export interface StartServerPluginOptions {
8
8
  stdout?: Writable;
9
9
  stderr?: Writable;
@@ -20,4 +20,3 @@ export declare class StartServerPlugin {
20
20
  private startServer;
21
21
  private runWorker;
22
22
  }
23
- //# sourceMappingURL=start-server.plugin.d.ts.map
@@ -1,44 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StartServerPlugin = void 0;
4
- const node_child_process_1 = require("node:child_process");
5
- const node_path_1 = require("node:path");
6
- const start_server_logger_1 = require("./start-server.logger");
7
- class StartServerPlugin {
8
- options;
9
- entryFile = null;
10
- worker = null;
11
- initialized = false;
12
- logger;
1
+ import { fork } from 'node:child_process';
2
+ import { join } from 'node:path';
3
+ import { StartServerLogger } from './start-server.logger.js';
4
+ export class StartServerPlugin {
13
5
  constructor(options = {}) {
14
- this.logger = new start_server_logger_1.StartServerLogger(options);
6
+ this.entryFile = null;
7
+ this.worker = null;
8
+ this.initialized = false;
9
+ this.apply = (compiler) => {
10
+ compiler.hooks.afterEmit.tapAsync({ name: 'StartServerPlugin' }, this.afterEmit);
11
+ };
12
+ this.afterEmit = (compilation, callback) => {
13
+ if (!this.initialized) {
14
+ this.initialized = true;
15
+ callback();
16
+ }
17
+ else {
18
+ if (this.worker?.connected && this.worker.pid) {
19
+ process.kill(this.worker.pid);
20
+ }
21
+ this.startServer(compilation, callback);
22
+ }
23
+ };
24
+ this.startServer = (compilation, callback) => {
25
+ this.logger.info('Starting server...');
26
+ this.entryFile = join(compilation.compiler.options.output.path, 'index.js');
27
+ this.runWorker(this.entryFile, (worker) => {
28
+ this.worker = worker;
29
+ callback();
30
+ });
31
+ };
32
+ this.logger = new StartServerLogger(options);
15
33
  this.options = options;
16
34
  }
17
- apply = (compiler) => {
18
- compiler.hooks.afterEmit.tapAsync({ name: 'StartServerPlugin' }, this.afterEmit);
19
- };
20
- afterEmit = (compilation, callback) => {
21
- if (!this.initialized) {
22
- this.initialized = true;
23
- callback();
24
- }
25
- else {
26
- if (this.worker?.connected && this.worker.pid) {
27
- process.kill(this.worker.pid);
28
- }
29
- this.startServer(compilation, callback);
30
- }
31
- };
32
- startServer = (compilation, callback) => {
33
- this.logger.info('Starting server...');
34
- this.entryFile = (0, node_path_1.join)(compilation.compiler.options.output.path, 'index.js');
35
- this.runWorker(this.entryFile, (worker) => {
36
- this.worker = worker;
37
- callback();
38
- });
39
- };
40
35
  runWorker(entryFile, callback) {
41
- const worker = (0, node_child_process_1.fork)(entryFile, [], {
36
+ const worker = fork(entryFile, [], {
42
37
  silent: true,
43
38
  });
44
39
  if (this.options.stdout) {
@@ -52,5 +47,3 @@ class StartServerPlugin {
52
47
  }, 0);
53
48
  }
54
49
  }
55
- exports.StartServerPlugin = StartServerPlugin;
56
- //# sourceMappingURL=start-server.plugin.js.map
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "@atls/webpack-start-server-plugin",
3
- "version": "0.0.7",
3
+ "version": "1.0.0",
4
4
  "license": "BSD-3-Clause",
5
+ "type": "module",
6
+ "exports": {
7
+ "./package.json": "./package.json",
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
5
14
  "main": "dist/index.js",
6
15
  "files": [
7
16
  "dist"
@@ -12,15 +21,23 @@
12
21
  "postpack": "rm -rf dist"
13
22
  },
14
23
  "dependencies": {
15
- "webpack": "5.91.0"
24
+ "webpack": "^5.88.1"
16
25
  },
17
26
  "devDependencies": {
18
- "@types/node": "20"
27
+ "@types/node": "^20.14.9"
19
28
  },
20
29
  "publishConfig": {
21
30
  "access": "public",
31
+ "exports": {
32
+ "./package.json": "./package.json",
33
+ ".": {
34
+ "import": "./dist/index.js",
35
+ "types": "./dist/index.d.ts",
36
+ "default": "./dist/index.js"
37
+ }
38
+ },
22
39
  "main": "dist/index.js",
23
- "typings": "dist/index.d.ts"
40
+ "types": "dist/index.d.ts"
24
41
  },
25
- "typings": "dist/index.d.ts"
42
+ "types": "dist/index.d.ts"
26
43
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"start-server.logger.d.ts","sourceRoot":"","sources":["../src/start-server.logger.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,QAAQ,CAAA;IACjB,MAAM,CAAC,EAAE,QAAQ,CAAA;CAClB;AAED,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,GAAE,wBAA6B;IAEnE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAgBxB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAgB1B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"start-server.logger.js","sourceRoot":"","sources":["../src/start-server.logger.ts"],"names":[],"mappings":";;;AAOA,MAAa,iBAAiB;IACC;IAA7B,YAA6B,UAAoC,EAAE;QAAtC,YAAO,GAAP,OAA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