@doracli/webpack 0.0.1 → 0.0.2

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,19 +1,18 @@
1
1
  import * as webpack from 'webpack';
2
- import webpack__default, { Configuration, Stats, Compiler } from 'webpack';
3
- import { Configuration as Configuration$1 } from 'webpack-dev-server';
2
+ import webpack__default, { Configuration, Stats, Compiler as Compiler$1 } from 'webpack';
3
+ import * as http from 'http';
4
+ import WebpackDevServer, { Configuration as Configuration$1 } from 'webpack-dev-server';
5
+ import { TPlainObject, TAny } from '@cclr/lang';
6
+ import { CompilerBase, ConfigCtx } from '@doracli/helper';
4
7
  import * as _doracli_type from '@doracli/type';
5
8
  import { TModule as TModule$1 } from '@doracli/type';
6
- import { TAny } from '@cclr/lang';
7
9
  import HtmlWebpackPlugin from 'html-webpack-plugin';
8
- import { ConfigCtx } from '@doracli/helper';
9
10
 
10
11
  declare const build: (options: Configuration) => Promise<{
11
12
  err?: Error | null;
12
13
  stats?: Stats;
13
14
  }>;
14
15
 
15
- declare const getDevServer: (serviceConfig: Configuration$1) => Configuration$1;
16
-
17
16
  type TAction = 'build' | 'server' | 'lib';
18
17
  type TEnvParams = {
19
18
  action: TAction;
@@ -33,6 +32,30 @@ type TModule = Configuration['module'];
33
32
  type TPlugins = Configuration['plugins'];
34
33
  type TOptimization = Configuration['optimization'];
35
34
 
35
+ type TBuildResult = {
36
+ Error: Error;
37
+ Stats: Stats;
38
+ };
39
+ declare class Compiler extends CompilerBase<Configuration, {
40
+ build: Promise<TBuildResult>;
41
+ watch: TPlainObject;
42
+ server: Promise<WebpackDevServer>;
43
+ }> {
44
+ context: (webpackConfig: Configuration) => Promise<{
45
+ rebuild: () => Promise<TBuildResult>;
46
+ cancel: () => Promise<void>;
47
+ }>;
48
+ inOutMap: (inputOutputMap: Record<string, string>) => Promise<TBuildResult>;
49
+ input: (input: string) => Promise<{
50
+ output: (output: TOutput) => Promise<TBuildResult>;
51
+ }>;
52
+ build: (webpackConfig: Configuration) => Promise<TBuildResult>;
53
+ watch: (watchOptions: Configuration["watchOptions"], webpackConfig: Configuration, cb?: (err: Error | null, stats?: Stats) => void) => webpack.Watching;
54
+ server: (serverOptions: Configuration$1, webpackConfig?: Configuration) => Promise<WebpackDevServer<any, http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>>>;
55
+ }
56
+
57
+ declare const getDevServer: (serviceConfig: Configuration$1) => Configuration$1;
58
+
36
59
  declare const getDevtool: (envParams: TEnvParams, devtoolConfig?: TDevtool) => TDevtool;
37
60
 
38
61
  declare const getEntry: (params: TEnvParams, input?: string) => TEntry;
@@ -70,7 +93,7 @@ declare const getHtmlWebpackPlugin: (params: HtmlWebpackPlugin.Options) => HtmlW
70
93
  declare class TsconfigPlugin {
71
94
  private workRootDir;
72
95
  constructor(workRootDir: string);
73
- apply(compiler: Compiler): void;
96
+ apply(compiler: Compiler$1): void;
74
97
  }
75
98
 
76
99
  declare const getTsconfigPlugin: (envParams: TEnvParams) => TsconfigPlugin;
@@ -105,19 +128,20 @@ declare class Ctx {
105
128
  geTDoraConfigWebpack(): _doracli_type.TDoraConfigWebpack;
106
129
  }
107
130
 
108
- /**
109
- * 启动服务
110
- * @param options
111
- * @param compiler
112
- */
113
- declare const service: (options: Configuration$1, compiler: Compiler) => Promise<void>;
114
-
131
+ declare const mergeWebpackConfig: <T extends Partial<Configuration>>(first: T | undefined, second: T | undefined) => Partial<Configuration>;
115
132
  /**
116
133
  * 合并多个 devServer 配置
117
134
  * @param configs
118
135
  * @returns
119
136
  */
120
- declare const mergeServerConfig: (...configs: Configuration$1[]) => Configuration$1;
137
+ declare const mergeServerConfig: <T extends Partial<Configuration$1>>(...configs: (T | undefined)[]) => Configuration$1;
138
+
139
+ /**
140
+ * 启动服务
141
+ * @param options
142
+ * @param compiler
143
+ */
144
+ declare const service: (options: Configuration$1, compiler: Compiler$1) => Promise<void>;
121
145
 
122
- export { Ctx, babelLoader, build, createCompiler, cssLoader, getBabelConfig, getCssBaseLoader, getDevServer, getDevtool, getEntry, getExternals, getHtmlWebpackPlugin, getMode, getOptimization, getOutput, getReactModulePreset, getReactPluginsPreset, getResolve, getResolveLoader, getTsconfigPlugin, lessLoader, mergeServerConfig, postcssLoader, postcssPresetEnv, sassLoader, service, styleLoader };
123
- export type { TAction, TDevtool, TEntry, TEnvParams, TExperiments, TExternals, TMode, TModule, TOptimization, TOutput, TPlugins, TResolve, TResolveLoader };
146
+ export { Compiler, Ctx, babelLoader, build, createCompiler, cssLoader, getBabelConfig, getCssBaseLoader, getDevServer, getDevtool, getEntry, getExternals, getHtmlWebpackPlugin, getMode, getOptimization, getOutput, getReactModulePreset, getReactPluginsPreset, getResolve, getResolveLoader, getTsconfigPlugin, lessLoader, mergeServerConfig, mergeWebpackConfig, postcssLoader, postcssPresetEnv, sassLoader, service, styleLoader };
147
+ export type { TAction, TBuildResult, TDevtool, TEntry, TEnvParams, TExperiments, TExternals, TMode, TModule, TOptimization, TOutput, TPlugins, TResolve, TResolveLoader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doracli/webpack",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "use webpack",
5
5
  "author": "cclr <18843152354@163.com>",
6
6
  "homepage": "",
@@ -33,13 +33,13 @@
33
33
  "devDependencies": {
34
34
  "@cclr/lang": "^0.1.28",
35
35
  "@cclr/utils": "^0.1.28",
36
- "@dorabag/config-loader": "^1.0.10",
36
+ "@dorabag/config-loader": "^1.0.11",
37
37
  "@dorabag/file-pro": "^1.0.10",
38
38
  "@dorabag/open-browser": "^1.0.7",
39
39
  "@dorabag/srv-tool": "^1.0.10",
40
- "@doracli/helper": "^0.0.1",
41
- "@doracli/preset-babel": "^0.0.1",
42
- "@doracli/type": "^0.0.1",
40
+ "@doracli/helper": "^0.0.2",
41
+ "@doracli/preset-babel": "^0.0.2",
42
+ "@doracli/type": "^0.0.2",
43
43
  "babel-loader": "^10.0.0",
44
44
  "css-loader": "^7.1.2",
45
45
  "html-webpack-plugin": "^5.6.4",
@@ -51,7 +51,7 @@
51
51
  "postcss-loader": "^8.2.0",
52
52
  "postcss-preset-env": "^10.4.0",
53
53
  "sass": "^1.93.2",
54
- "sass-loader": "^16.0.5",
54
+ "sass-loader": "^16.0.6",
55
55
  "style-loader": "^4.0.0",
56
56
  "terser-webpack-plugin": "^5.3.14",
57
57
  "webpack": "^5.102.1",
@@ -59,5 +59,5 @@
59
59
  "webpack-dev-server": "^5.2.2",
60
60
  "webpackbar": "^7.0.0"
61
61
  },
62
- "gitHead": "40ab496f25042487a671979074515f3345c96453"
62
+ "gitHead": "912cb44292b64679630a799974d18c22b2e69738"
63
63
  }