@doracli/rspack 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.
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>cclr</title>
8
+ <!-- 引入样式 -->
9
+ <% for (var i in htmlWebpackPlugin.options.headBeforeStyle) { %>
10
+ <link
11
+ href="<%= htmlWebpackPlugin.options.headBeforeStyle[i] %>"
12
+ rel="stylesheet"
13
+ />
14
+ <% } %>
15
+
16
+ <!-- 引入js -->
17
+ <% for (var i in htmlWebpackPlugin.options.headAfterScript) { %>
18
+ <script src="<%= htmlWebpackPlugin.options.headAfterScript[i] %>"></script>
19
+ <% } %>
20
+ </head>
21
+ <body>
22
+ <div id="main">welcome use cclr !!</div>
23
+ </body>
24
+ </html>
@@ -0,0 +1,129 @@
1
+ import { CompilerBase, ConfigCtx } from '@doracli/helper';
2
+ import * as _rspack_core from '@rspack/core';
3
+ import { Configuration, Stats, RspackOptions, Watching, DevServer, Compiler as Compiler$1 } from '@rspack/core';
4
+ import { RspackDevServer, Configuration as Configuration$1 } from '@rspack/dev-server';
5
+ import * as _doracli_type from '@doracli/type';
6
+ import { TModule as TModule$1 } from '@doracli/type';
7
+ import { TAny } from '@cclr/lang';
8
+ import { Options } from '@rspack/plugin-html';
9
+
10
+ type TAction = 'build' | 'server' | 'lib';
11
+ type TEnvParams = {
12
+ action: TAction;
13
+ workRootDir: string;
14
+ format?: TModule$1;
15
+ };
16
+
17
+ type TMode = Configuration['mode'];
18
+ type TEntry = Configuration['entry'];
19
+ type TOutput = Configuration['output'];
20
+ type TDevtool = Configuration['devtool'];
21
+ type TExternals = Configuration['externals'];
22
+ type TExperiments = Configuration['experiments'];
23
+ type TResolve = Configuration['resolve'];
24
+ type TResolveLoader = Configuration['resolveLoader'];
25
+ type TModule = Configuration['module'];
26
+ type TPlugins = Configuration['plugins'];
27
+ type TOptimization = Configuration['optimization'];
28
+
29
+ type TBuildResult = {
30
+ err: Error;
31
+ stats: Stats;
32
+ };
33
+ declare class Compiler extends CompilerBase<RspackOptions, {
34
+ build: Promise<TBuildResult>;
35
+ watch: Watching;
36
+ server: Promise<RspackDevServer>;
37
+ }> {
38
+ context: (rspackConfig: Configuration) => Promise<{
39
+ rebuild: () => Promise<TBuildResult>;
40
+ cancel: () => Promise<void>;
41
+ }>;
42
+ inOutMap: (inputOutputMap: Record<string, string>) => Promise<TBuildResult>;
43
+ input: (input: string) => Promise<{
44
+ output: (output: TOutput) => Promise<TBuildResult>;
45
+ }>;
46
+ build: (rspackConfig: RspackOptions) => Promise<TBuildResult>;
47
+ watch: (watchOptions: Configuration["watchOptions"], rspackConfig: Configuration, cb?: (err: Error | null, stats?: Stats) => void) => Watching;
48
+ server: (serverOptions: DevServer, rspackConfig?: Configuration) => Promise<RspackDevServer>;
49
+ }
50
+
51
+ declare const getDevServer: (serviceConfig: Configuration$1) => Configuration$1;
52
+
53
+ declare const getDevtool: (envParams: TEnvParams, devtoolConfig?: TDevtool) => TDevtool;
54
+
55
+ declare const getEntry: (params: TEnvParams, input?: string) => TEntry;
56
+
57
+ declare const getExternals: (externals: TExternals) => TExternals;
58
+
59
+ declare const getMode: (envParams: TEnvParams, modeConfig?: TMode) => TMode;
60
+
61
+ declare const getCssBaseLoader: (envParams: TEnvParams, options?: {
62
+ postcssPluginExtra?: TAny[];
63
+ }) => any[];
64
+
65
+ declare const cssLoader: string;
66
+ declare const postcssLoader: string;
67
+ declare const styleLoader: string;
68
+ declare const lessLoader: string;
69
+ declare const swcLoader: string;
70
+ declare const postcssPresetEnv: string;
71
+
72
+ declare const getReactModulePreset: (envParams: TEnvParams, options?: {
73
+ postcssPluginExtra?: TAny[];
74
+ }) => _rspack_core.ModuleOptions;
75
+
76
+ declare const getOptimization: (params: {
77
+ minimize: boolean;
78
+ }) => TOptimization;
79
+
80
+ declare const getOutput: (envParams: TEnvParams, output?: TOutput) => TOutput;
81
+
82
+ declare const getHtmlWebpackPlugin: (params: Options) => any;
83
+
84
+ declare class TsconfigPlugin {
85
+ private workRootDir;
86
+ constructor(workRootDir: string);
87
+ apply(compiler: Compiler$1): void;
88
+ }
89
+
90
+ declare const getTsconfigPlugin: (envParams: TEnvParams) => TsconfigPlugin;
91
+
92
+ declare const getReactPluginsPreset: (envParams: TEnvParams, options: {
93
+ minimize?: boolean;
94
+ WebpackBundleAnalyzerOptions?: TAny;
95
+ HtmlWebpackPluginOptions?: Options;
96
+ }) => TPlugins;
97
+
98
+ /**
99
+ * 获取webpack的resolve配置
100
+ * @param userResolve
101
+ * @returns
102
+ */
103
+ declare const getResolve: (resolveConfig: TResolve) => TResolve;
104
+
105
+ declare const getResolveLoader: () => TResolveLoader;
106
+
107
+ declare class Ctx {
108
+ configCtx: ConfigCtx;
109
+ rspackConfig: Configuration;
110
+ devServerConfig: Configuration$1;
111
+ envParams: TEnvParams;
112
+ constructor(configCtx: ConfigCtx);
113
+ updateEnvParams(argv: Partial<TEnvParams>): void;
114
+ updateRspackConfig(config: Configuration): void;
115
+ updateDevServerConfig(config: Configuration$1): void;
116
+ getDoraConfig(): _doracli_type.TDoraConfig;
117
+ geTDoraConfigRspack(): _doracli_type.TDoraConfigWebpack;
118
+ }
119
+
120
+ declare const mergeRspackConfigs: <T extends Partial<Configuration>>(first: T | undefined, second: T | undefined) => Partial<Configuration>;
121
+ /**
122
+ * 合并多个 devServer 配置
123
+ * @param configs
124
+ * @returns
125
+ */
126
+ declare const mergeServerConfig: <T extends Partial<DevServer>>(...configs: (T | undefined)[]) => DevServer;
127
+
128
+ export { Compiler, Ctx, cssLoader, getCssBaseLoader, getDevServer, getDevtool, getEntry, getExternals, getHtmlWebpackPlugin, getMode, getOptimization, getOutput, getReactModulePreset, getReactPluginsPreset, getResolve, getResolveLoader, getTsconfigPlugin, lessLoader, mergeRspackConfigs, mergeServerConfig, postcssLoader, postcssPresetEnv, styleLoader, swcLoader };
129
+ export type { TAction, TBuildResult, TDevtool, TEntry, TEnvParams, TExperiments, TExternals, TMode, TModule, TOptimization, TOutput, TPlugins, TResolve, TResolveLoader };
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@doracli/rspack",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "use rspack",
5
5
  "author": "cclr <18843152354@163.com>",
6
6
  "homepage": "",
7
7
  "license": "MIT",
8
- "main": "lib/cjs/index.js",
9
- "module": "lib/esm/index.js",
8
+ "type": "module",
9
+ "exports": {
10
+ "import": "./lib/esm/index.js",
11
+ "require": "./lib/cjs/index.js"
12
+ },
10
13
  "types": "lib/type/index.d.ts",
11
14
  "directories": {
12
15
  "lib": "lib"
@@ -26,7 +29,23 @@
26
29
  },
27
30
  "dependencies": {
28
31
  "@cclr/lang": "^0.1.28",
29
- "@cclr/utils": "^0.1.28"
32
+ "@cclr/utils": "^0.1.28",
33
+ "@dorabag/file-pro": "^1.0.10",
34
+ "@dorabag/open-browser": "^1.0.10",
35
+ "@doracli/helper": "^0.0.2",
36
+ "@doracli/preset-babel": "^0.0.2",
37
+ "@doracli/type": "^0.0.2",
38
+ "@rspack/core": "^1.5.8",
39
+ "@rspack/dev-server": "^1.1.4",
40
+ "@rspack/plugin-html": "^0.5.8",
41
+ "css-loader": "^7.1.2",
42
+ "less": "^4.4.2",
43
+ "less-loader": "^12.3.0",
44
+ "postcss-loader": "^8.2.0",
45
+ "postcss-preset-env": "^10.4.0",
46
+ "style-loader": "^4.0.0",
47
+ "swc-loader": "^0.2.6",
48
+ "webpack-bundle-analyzer": "^4.10.2"
30
49
  },
31
- "gitHead": "40ab496f25042487a671979074515f3345c96453"
50
+ "gitHead": "912cb44292b64679630a799974d18c22b2e69738"
32
51
  }