webpack-dev-service 0.13.3 → 0.14.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/README.md +9 -8
- package/cjs/client/client.cjs +24 -9
- package/cjs/client/client.d.cts +14 -0
- package/cjs/client/events.cjs +1 -1
- package/cjs/client/events.d.cts +28 -0
- package/cjs/client/hot.cjs +19 -21
- package/cjs/client/hot.d.cts +16 -0
- package/cjs/client/index.cjs +1 -1
- package/cjs/client/index.d.cts +4 -0
- package/cjs/client/main.cjs +4 -3
- package/cjs/client/main.d.cts +4 -0
- package/cjs/client/ui/Overlay.cjs +1 -1
- package/cjs/client/ui/Overlay.d.cts +12 -0
- package/cjs/client/ui/Progress.cjs +1 -1
- package/cjs/client/ui/Progress.d.cts +12 -0
- package/cjs/client/ui/utils.cjs +1 -1
- package/cjs/client/ui/utils.d.cts +15 -0
- package/cjs/server/compose.cjs +13 -12
- package/cjs/server/compose.d.cts +18 -0
- package/cjs/server/dev/ReadStream.cjs +1 -1
- package/cjs/server/dev/ReadStream.d.cts +43 -0
- package/cjs/server/dev/Service.cjs +1 -1
- package/cjs/server/dev/Service.d.cts +48 -0
- package/cjs/server/dev/index.cjs +1 -1
- package/cjs/server/dev/index.d.cts +8 -0
- package/cjs/server/dev/interface.d.cts +38 -0
- package/cjs/server/dev/middleware.cjs +1 -1
- package/cjs/server/dev/middleware.d.cts +6 -0
- package/cjs/server/dev/utils/fs.cjs +1 -1
- package/cjs/server/dev/utils/fs.d.cts +24 -0
- package/cjs/server/dev/utils/hash.cjs +1 -1
- package/cjs/server/dev/utils/hash.d.cts +9 -0
- package/cjs/server/dev/utils/http.cjs +1 -1
- package/cjs/server/dev/utils/http.d.cts +37 -0
- package/cjs/server/dev/utils/path.cjs +1 -1
- package/cjs/server/dev/utils/path.d.cts +22 -0
- package/cjs/server/dev/utils/paths.cjs +1 -1
- package/cjs/server/dev/utils/paths.d.cts +7 -0
- package/cjs/server/dev/utils/ready.cjs +1 -1
- package/cjs/server/dev/utils/ready.d.cts +5 -0
- package/cjs/server/dev/utils/setupHooks.cjs +2 -5
- package/cjs/server/dev/utils/setupHooks.d.cts +5 -0
- package/cjs/server/dev/utils/setupOutputFileSystem.cjs +1 -1
- package/cjs/server/dev/utils/setupOutputFileSystem.d.cts +5 -0
- package/cjs/server/dev/utils/setupWatching.cjs +1 -1
- package/cjs/server/dev/utils/setupWatching.d.cts +5 -0
- package/cjs/server/dev/utils/setupWriteToDisk.cjs +2 -2
- package/cjs/server/dev/utils/setupWriteToDisk.d.cts +5 -0
- package/cjs/server/hot/Message.d.cts +49 -0
- package/cjs/server/hot/Socket.cjs +109 -97
- package/cjs/server/hot/Socket.d.cts +11 -0
- package/cjs/server/hot/index.cjs +3 -10
- package/cjs/server/hot/index.d.cts +8 -0
- package/cjs/server/hot/interface.d.cts +22 -0
- package/cjs/server/hot/utils.cjs +11 -36
- package/cjs/server/hot/utils.d.cts +12 -0
- package/cjs/server/index.cjs +8 -2
- package/cjs/server/index.d.cts +17 -0
- package/cjs/server/interface.d.cts +14 -0
- package/cjs/server/schema.cjs +1 -1
- package/cjs/server/schema.d.cts +7 -0
- package/cjs/server/utils.cjs +1 -5
- package/cjs/server/utils.d.cts +11 -0
- package/esm/client/client.d.ts +14 -0
- package/esm/client/client.js +25 -10
- package/esm/client/events.d.ts +28 -0
- package/esm/client/events.js +1 -1
- package/esm/client/hot.d.ts +16 -0
- package/esm/client/hot.js +19 -19
- package/esm/client/index.d.ts +4 -0
- package/esm/client/index.js +1 -1
- package/esm/client/main.d.ts +4 -0
- package/esm/client/main.js +4 -3
- package/esm/client/ui/Overlay.d.ts +12 -0
- package/esm/client/ui/Overlay.js +1 -1
- package/esm/client/ui/Progress.d.ts +12 -0
- package/esm/client/ui/Progress.js +1 -1
- package/esm/client/ui/utils.d.ts +15 -0
- package/esm/client/ui/utils.js +1 -1
- package/esm/server/compose.d.ts +18 -0
- package/esm/server/compose.js +13 -12
- package/esm/server/dev/ReadStream.d.ts +43 -0
- package/esm/server/dev/ReadStream.js +1 -1
- package/esm/server/dev/Service.d.ts +48 -0
- package/esm/server/dev/Service.js +1 -1
- package/esm/server/dev/index.d.ts +8 -0
- package/esm/server/dev/index.js +1 -1
- package/esm/server/dev/interface.d.ts +38 -0
- package/esm/server/dev/middleware.d.ts +6 -0
- package/esm/server/dev/middleware.js +1 -1
- package/esm/server/dev/utils/fs.d.ts +24 -0
- package/esm/server/dev/utils/fs.js +1 -1
- package/esm/server/dev/utils/hash.d.ts +9 -0
- package/esm/server/dev/utils/hash.js +1 -1
- package/esm/server/dev/utils/http.d.ts +37 -0
- package/esm/server/dev/utils/http.js +1 -1
- package/esm/server/dev/utils/path.d.ts +22 -0
- package/esm/server/dev/utils/path.js +1 -1
- package/esm/server/dev/utils/paths.d.ts +7 -0
- package/esm/server/dev/utils/paths.js +1 -1
- package/esm/server/dev/utils/ready.d.ts +5 -0
- package/esm/server/dev/utils/ready.js +1 -1
- package/esm/server/dev/utils/setupHooks.d.ts +5 -0
- package/esm/server/dev/utils/setupHooks.js +2 -5
- package/esm/server/dev/utils/setupOutputFileSystem.d.ts +5 -0
- package/esm/server/dev/utils/setupOutputFileSystem.js +1 -1
- package/esm/server/dev/utils/setupWatching.d.ts +5 -0
- package/esm/server/dev/utils/setupWatching.js +1 -1
- package/esm/server/dev/utils/setupWriteToDisk.d.ts +5 -0
- package/esm/server/dev/utils/setupWriteToDisk.js +2 -2
- package/{types/client → esm/server/hot}/Message.d.ts +15 -7
- package/esm/server/hot/Socket.d.ts +11 -0
- package/esm/server/hot/Socket.js +110 -98
- package/esm/server/hot/index.d.ts +8 -0
- package/esm/server/hot/index.js +3 -10
- package/esm/server/hot/interface.d.ts +22 -0
- package/esm/server/hot/utils.d.ts +12 -0
- package/esm/server/hot/utils.js +12 -38
- package/esm/server/index.d.ts +17 -0
- package/esm/server/index.js +8 -2
- package/esm/server/interface.d.ts +14 -0
- package/esm/server/schema.d.ts +7 -0
- package/esm/server/schema.js +1 -1
- package/esm/server/utils.d.ts +11 -0
- package/esm/server/utils.js +2 -5
- package/global.d.ts +2 -0
- package/package.json +19 -18
- package/types/client/client.d.ts +2 -1
- package/types/client/events.d.ts +2 -9
- package/types/client/hot.d.ts +3 -14
- package/types/server/compose.d.ts +2 -2
- package/types/server/dev/index.d.ts +1 -1
- package/types/server/dev/interface.d.ts +2 -2
- package/types/server/dev/utils/fs.d.ts +2 -4
- package/types/server/dev/utils/paths.d.ts +1 -1
- package/types/server/dev/utils/ready.d.ts +1 -1
- package/types/server/dev/utils/setupHooks.d.ts +1 -1
- package/types/server/dev/utils/setupOutputFileSystem.d.ts +1 -1
- package/types/server/dev/utils/setupWatching.d.ts +1 -1
- package/types/server/dev/utils/setupWriteToDisk.d.ts +1 -1
- package/types/server/hot/Message.d.ts +49 -0
- package/types/server/hot/Socket.d.ts +1 -4
- package/types/server/hot/index.d.ts +4 -4
- package/types/server/hot/interface.d.ts +8 -6
- package/types/server/hot/utils.d.ts +4 -4
- package/types/server/index.d.ts +6 -26
- package/types/server/interface.d.ts +3 -0
- package/types/server/utils.d.ts +0 -1
package/types/client/hot.d.ts
CHANGED
|
@@ -2,22 +2,11 @@
|
|
|
2
2
|
* @module hot
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* @function
|
|
6
|
-
* @description
|
|
7
|
-
*/
|
|
8
|
-
export declare function isUpdateAvailable(): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* @function setHash
|
|
11
|
-
* @description Set webpack hash.
|
|
5
|
+
* @function updateHash
|
|
6
|
+
* @description Update webpack hash.
|
|
12
7
|
* @param value The new hash value.
|
|
13
8
|
*/
|
|
14
|
-
export declare function
|
|
15
|
-
/**
|
|
16
|
-
* @function setStatus
|
|
17
|
-
* @description Set hot status.
|
|
18
|
-
* @param value The new status of the hot update.
|
|
19
|
-
*/
|
|
20
|
-
export declare function setStatus(value: HotUpdateStatus): void;
|
|
9
|
+
export declare function updateHash(value: string): void;
|
|
21
10
|
/**
|
|
22
11
|
* @function applyUpdate
|
|
23
12
|
* @description Apply update.
|
|
@@ -12,7 +12,7 @@ export interface Middleware<C> {
|
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* @function compose
|
|
15
|
-
* @description
|
|
16
|
-
* @param middlewares
|
|
15
|
+
* @description Compose middlewares.
|
|
16
|
+
* @param middlewares The middlewares list.
|
|
17
17
|
*/
|
|
18
18
|
export declare function compose<C>(...middlewares: Middleware<C>[]): Composed<C>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module index
|
|
3
3
|
*/
|
|
4
4
|
import { Middleware } from 'koa';
|
|
5
|
-
import { UnionCompiler } from '
|
|
5
|
+
import { UnionCompiler } from '/server/interface';
|
|
6
6
|
import { Expose, Options } from './interface';
|
|
7
7
|
export { Expose, Options };
|
|
8
8
|
export declare function dev(compiler: UnionCompiler, options: Options): Middleware & Expose;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import webpack from 'webpack';
|
|
5
5
|
import { FileSystem } from './utils/fs';
|
|
6
6
|
import { Options as ServiceOptions, Service } from './Service';
|
|
7
|
-
import { Logger, Optional, StatsOptions, UnionCompiler, UnionStats, UnionWatching } from '
|
|
7
|
+
import { Logger, Optional, StatsOptions, UnionCompiler, UnionStats, UnionWatching } from '/server/interface';
|
|
8
8
|
export interface Callback {
|
|
9
9
|
(stats: UnionStats): void;
|
|
10
10
|
}
|
|
@@ -18,12 +18,12 @@ export interface Expose {
|
|
|
18
18
|
readonly close: (callback: ErrorCallback) => void;
|
|
19
19
|
readonly invalidate: (callback: ErrorCallback) => void;
|
|
20
20
|
}
|
|
21
|
+
export type FileService = [publicPath: string, service: Service];
|
|
21
22
|
export interface Options extends Optional<ServiceOptions, 'fs'> {
|
|
22
23
|
stats?: StatsOptions;
|
|
23
24
|
writeToDisk?: boolean | ((targetPath: string) => boolean);
|
|
24
25
|
onCompilationDone?: (stats: UnionStats, statsOptions: Readonly<webpack.StatsOptions>) => void;
|
|
25
26
|
}
|
|
26
|
-
export type FileService = [publicPath: string, service: Service];
|
|
27
27
|
export interface Context {
|
|
28
28
|
logger: Logger;
|
|
29
29
|
callbacks: Callback[];
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import webpack from 'webpack';
|
|
5
5
|
import fs, { Stats } from 'node:fs';
|
|
6
|
-
import { GetProp } from '
|
|
7
|
-
|
|
8
|
-
export interface FileSystem extends GetProp<Compiler, 'outputFileSystem'> {
|
|
6
|
+
import { GetProp } from '/server/interface';
|
|
7
|
+
export interface FileSystem extends GetProp<webpack.Compiler, 'outputFileSystem'> {
|
|
9
8
|
stat: typeof fs.stat;
|
|
10
9
|
open: typeof fs.open;
|
|
11
10
|
read: typeof fs.read;
|
|
@@ -23,4 +22,3 @@ export declare function createMemfs(): FileSystem;
|
|
|
23
22
|
* @param path The file path.
|
|
24
23
|
*/
|
|
25
24
|
export declare function stat(fs: FileSystem, path: string): Promise<Stats | null>;
|
|
26
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module paths
|
|
3
3
|
*/
|
|
4
|
-
import { UnionStats } from '
|
|
4
|
+
import { UnionStats } from '/server/interface';
|
|
5
5
|
type PathsItem = [outputPath: string, publicPath: string];
|
|
6
6
|
export declare function getPaths(stats: UnionStats): PathsItem[];
|
|
7
7
|
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module message
|
|
3
|
+
*/
|
|
4
|
+
import webpack from 'webpack';
|
|
5
|
+
import { GetProp } from '/server/interface';
|
|
6
|
+
export interface Invalid {
|
|
7
|
+
action: 'invalid';
|
|
8
|
+
payload: {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
path: string | null;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface Progress {
|
|
14
|
+
action: 'progress';
|
|
15
|
+
payload: {
|
|
16
|
+
status: string;
|
|
17
|
+
messages: string[];
|
|
18
|
+
percentage: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface Hash {
|
|
22
|
+
action: 'hash';
|
|
23
|
+
payload: {
|
|
24
|
+
hash: string;
|
|
25
|
+
timestamp: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface Issues {
|
|
29
|
+
action: 'issues';
|
|
30
|
+
payload: {
|
|
31
|
+
timestamp: number;
|
|
32
|
+
errors: webpack.StatsError[];
|
|
33
|
+
warnings: webpack.StatsError[];
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface Ok {
|
|
37
|
+
action: 'ok';
|
|
38
|
+
payload: {
|
|
39
|
+
timestamp: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface Messages {
|
|
43
|
+
ok: GetProp<Ok, 'payload'>;
|
|
44
|
+
hash: GetProp<Hash, 'payload'>;
|
|
45
|
+
issues: GetProp<Issues, 'payload'>;
|
|
46
|
+
invalid: GetProp<Invalid, 'payload'>;
|
|
47
|
+
progress: GetProp<Progress, 'payload'>;
|
|
48
|
+
}
|
|
49
|
+
export type Message = Invalid | Progress | Hash | Issues | Ok;
|
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
* @module Socket
|
|
3
3
|
*/
|
|
4
4
|
import { Context } from 'koa';
|
|
5
|
-
import
|
|
5
|
+
import { UnionCompiler } from '/server/interface';
|
|
6
6
|
import { Options } from './interface';
|
|
7
|
-
import { UnionCompiler } from '../../server/interface';
|
|
8
7
|
export declare class Socket {
|
|
9
8
|
#private;
|
|
10
9
|
constructor(compiler: UnionCompiler, options?: Options);
|
|
11
|
-
clients(): Set<WebSocket>;
|
|
12
10
|
upgrade(context: Context): boolean;
|
|
13
|
-
broadcast<T>(clients: Set<WebSocket> | WebSocket[], action: string, payload: T): void;
|
|
14
11
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module index
|
|
3
3
|
*/
|
|
4
4
|
import { Middleware } from 'koa';
|
|
5
|
-
import {
|
|
6
|
-
import { UnionCompiler } from '
|
|
7
|
-
export {
|
|
8
|
-
export declare function hot(compiler: UnionCompiler, options?: Options): Middleware
|
|
5
|
+
import { Options } from './interface';
|
|
6
|
+
import { UnionCompiler } from '/server/interface';
|
|
7
|
+
export { Options };
|
|
8
|
+
export declare function hot(compiler: UnionCompiler, options?: Options): Middleware;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import WebSocket from 'ws';
|
|
5
5
|
import webpack from 'webpack';
|
|
6
|
+
import { RequiredKeys } from '/server/interface';
|
|
6
7
|
export interface Options {
|
|
7
8
|
hmr?: boolean;
|
|
8
9
|
path?: string;
|
|
@@ -11,10 +12,11 @@ export interface Options {
|
|
|
11
12
|
overlay?: boolean;
|
|
12
13
|
progress?: boolean;
|
|
13
14
|
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
readonly clients:
|
|
19
|
-
|
|
15
|
+
export type Clients = Set<WebSocket>;
|
|
16
|
+
export interface CompilerContext {
|
|
17
|
+
percentage: number;
|
|
18
|
+
readonly uuid: string;
|
|
19
|
+
readonly clients: Clients;
|
|
20
|
+
stats: Required<webpack.StatsCompilation> | null;
|
|
20
21
|
}
|
|
22
|
+
export type NormalizedOptions = RequiredKeys<Options, 'hmr' | 'path' | 'reload' | 'overlay' | 'progress'>;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import webpack from 'webpack';
|
|
5
5
|
import { Context } from 'koa';
|
|
6
|
-
import { Options } from './interface';
|
|
7
|
-
|
|
6
|
+
import { NormalizedOptions, Options } from './interface';
|
|
7
|
+
export declare const BASE_URL = 'wss://127.0.0.1';
|
|
8
8
|
export declare function isUpgradable({ request }: Context): boolean;
|
|
9
|
-
export declare function getOptions(options?: Options):
|
|
9
|
+
export declare function getOptions(options?: Options): NormalizedOptions;
|
|
10
10
|
export declare function hasIssues<T>(issues: ArrayLike<T> | undefined): boolean;
|
|
11
|
-
export declare function getStatsOptions(compiler:
|
|
11
|
+
export declare function getStatsOptions(compiler: webpack.Compiler): webpack.StatsOptions;
|
|
12
12
|
export declare function getTimestamp({ builtAt, children }: webpack.StatsCompilation): number;
|
package/types/server/index.d.ts
CHANGED
|
@@ -3,35 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Middleware } from 'koa';
|
|
5
5
|
import { UnionCompiler } from './interface';
|
|
6
|
-
import {
|
|
7
|
-
import { Expose
|
|
8
|
-
type
|
|
9
|
-
hot
|
|
6
|
+
import { Options as HotOptions } from './hot';
|
|
7
|
+
import { Expose, Options as DevOptions } from './dev';
|
|
8
|
+
export type Options = DevOptions & {
|
|
9
|
+
hot?: HotOptions | false;
|
|
10
10
|
};
|
|
11
|
-
type EnableHotOptions = DevOptions & {
|
|
12
|
-
hot?: HotOptions;
|
|
13
|
-
};
|
|
14
|
-
export type DisableHotMiddleware = Middleware & DevExpose;
|
|
15
|
-
export type Options = EnableHotOptions | DisableHotOptions;
|
|
16
|
-
export type EnableHotMiddleware = DisableHotMiddleware & HotExpose;
|
|
17
|
-
/**
|
|
18
|
-
* @function server
|
|
19
|
-
* @description Create koa dev server middleware.
|
|
20
|
-
* @param compiler The webpack compiler instance.
|
|
21
|
-
*/
|
|
22
|
-
export default function server(compiler: UnionCompiler): EnableHotMiddleware;
|
|
23
|
-
/**
|
|
24
|
-
* @function server
|
|
25
|
-
* @description Create koa dev server middleware.
|
|
26
|
-
* @param compiler The webpack compiler instance.
|
|
27
|
-
* @param options Options.
|
|
28
|
-
*/
|
|
29
|
-
export default function server(compiler: UnionCompiler, options: EnableHotOptions): EnableHotMiddleware;
|
|
30
11
|
/**
|
|
31
12
|
* @function server
|
|
32
13
|
* @description Create koa dev server middleware.
|
|
33
|
-
* @param compiler The
|
|
14
|
+
* @param compiler The rspack compiler instance.
|
|
34
15
|
* @param options Options.
|
|
35
16
|
*/
|
|
36
|
-
export
|
|
37
|
-
export {};
|
|
17
|
+
export declare function server(compiler: UnionCompiler, options?: Options): Middleware & Expose;
|
|
@@ -6,6 +6,9 @@ export type UnionStats = webpack.Stats | webpack.MultiStats;
|
|
|
6
6
|
export type GetProp<T, P extends keyof T> = NonNullable<T[P]>;
|
|
7
7
|
export type StatsOptions = GetProp<webpack.Configuration, 'stats'>;
|
|
8
8
|
export type UnionCompiler = webpack.Compiler | webpack.MultiCompiler;
|
|
9
|
+
export type RequiredKeys<T, K extends keyof T> = T & {
|
|
10
|
+
[P in K]-?: T[P];
|
|
11
|
+
};
|
|
9
12
|
export type Logger = ReturnType<GetProp<webpack.Compiler, 'getInfrastructureLogger'>>;
|
|
10
13
|
export type UnionWatching = webpack.Watching | ReturnType<GetProp<webpack.MultiCompiler, 'watch'>>;
|
|
11
14
|
export type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
package/types/server/utils.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import webpack from 'webpack';
|
|
5
5
|
import { UnionCompiler } from './interface';
|
|
6
6
|
export declare const PLUGIN_NAME: string;
|
|
7
|
-
export declare function isObject(value: unknown): value is object;
|
|
8
7
|
export declare function isString(value: unknown): value is string;
|
|
9
8
|
export declare function isBoolean(value: unknown): value is boolean;
|
|
10
9
|
export declare function isFunction(value: unknown): value is Function;
|