@modern-js/uni-builder 0.0.0-nightly-20240101170614 → 0.0.0-nightly-20240103170618
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/rspack/index.d.ts +2 -10
- package/dist/rspack/index.js +9 -0
- package/dist/shared/compatLegacyPlugin.d.ts +5 -0
- package/dist/shared/compatLegacyPlugin.js +82 -0
- package/dist/types.d.ts +46 -1
- package/dist/webpack/index.d.ts +2 -5
- package/dist/webpack/index.js +9 -0
- package/package.json +23 -22
package/dist/rspack/index.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { RsbuildConfig, RsbuildPlugin, RsbuildInstance } from '@rsbuild/core';
|
|
2
|
-
import type { UniBuilderConfig, CreateUniBuilderOptions, CreateBuilderCommonOptions } from '../types';
|
|
3
|
-
import type { StartDevServerOptions, UniBuilderStartServerResult } from '../shared/devServer';
|
|
2
|
+
import type { UniBuilderConfig, CreateUniBuilderOptions, CreateBuilderCommonOptions, OverridesUniBuilderInstance } from '../types';
|
|
4
3
|
export declare function parseConfig(uniBuilderConfig: UniBuilderConfig, options: CreateBuilderCommonOptions): Promise<{
|
|
5
4
|
rsbuildConfig: RsbuildConfig;
|
|
6
5
|
rsbuildPlugins: RsbuildPlugin[];
|
|
7
6
|
}>;
|
|
8
|
-
export type UniBuilderInstance = Omit<RsbuildInstance,
|
|
9
|
-
/**
|
|
10
|
-
* should be used in conjunction with the upper-layer framework:
|
|
11
|
-
*
|
|
12
|
-
* missing route.json (required in modern server)
|
|
13
|
-
*/
|
|
14
|
-
startDevServer: (options: StartDevServerOptions) => Promise<UniBuilderStartServerResult>;
|
|
15
|
-
};
|
|
7
|
+
export type UniBuilderInstance = Omit<RsbuildInstance, keyof OverridesUniBuilderInstance> & OverridesUniBuilderInstance;
|
|
16
8
|
export declare function createRspackBuilder(options: CreateUniBuilderOptions): Promise<UniBuilderInstance>;
|
package/dist/rspack/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(rspack_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(rspack_exports);
|
|
35
35
|
var import_core = require("@rsbuild/core");
|
|
36
36
|
var import_parseCommonConfig = require("../shared/parseCommonConfig");
|
|
37
|
+
var import_compatLegacyPlugin = require("../shared/compatLegacyPlugin");
|
|
37
38
|
async function parseConfig(uniBuilderConfig, options) {
|
|
38
39
|
var _uniBuilderConfig_output, _uniBuilderConfig_tools, _uniBuilderConfig_tools1;
|
|
39
40
|
const { rsbuildConfig, rsbuildPlugins } = await (0, import_parseCommonConfig.parseCommonConfig)(uniBuilderConfig, options);
|
|
@@ -71,6 +72,14 @@ async function createRspackBuilder(options) {
|
|
|
71
72
|
rsbuild.addPlugins(rsbuildPlugins);
|
|
72
73
|
return {
|
|
73
74
|
...rsbuild,
|
|
75
|
+
addPlugins: (plugins, options2) => {
|
|
76
|
+
const warpedPlugins = plugins.map((plugin) => {
|
|
77
|
+
return (0, import_compatLegacyPlugin.compatLegacyPlugin)(plugin, {
|
|
78
|
+
cwd
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
rsbuild.addPlugins(warpedPlugins, options2);
|
|
82
|
+
},
|
|
74
83
|
startDevServer: async (options2 = {}) => {
|
|
75
84
|
const { startDevServer } = await Promise.resolve().then(() => __toESM(require("../shared/devServer")));
|
|
76
85
|
return startDevServer(rsbuild, options2, config);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var compatLegacyPlugin_exports = {};
|
|
20
|
+
__export(compatLegacyPlugin_exports, {
|
|
21
|
+
compatLegacyPlugin: () => compatLegacyPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(compatLegacyPlugin_exports);
|
|
24
|
+
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
function addDeprecatedWarning(pluginName, name, newName) {
|
|
27
|
+
import_shared.logger.warn(`Plugin(${pluginName})'s api '${name}' is deprecated${newName ? `, please use '${newName}' instead.` : "."}`);
|
|
28
|
+
}
|
|
29
|
+
function compatLegacyPlugin(plugin, extraInfo) {
|
|
30
|
+
return {
|
|
31
|
+
...plugin,
|
|
32
|
+
setup: (api) => {
|
|
33
|
+
const builderContext = new Proxy(api.context, {
|
|
34
|
+
get(target, prop) {
|
|
35
|
+
switch (prop) {
|
|
36
|
+
case "target":
|
|
37
|
+
addDeprecatedWarning(plugin.name, "context.target", "context.targets");
|
|
38
|
+
return target.targets;
|
|
39
|
+
case "srcPath":
|
|
40
|
+
addDeprecatedWarning(plugin.name, "context.srcPath");
|
|
41
|
+
return (0, import_path.join)(extraInfo.cwd, "src");
|
|
42
|
+
case "framework":
|
|
43
|
+
addDeprecatedWarning(plugin.name, "context.framework");
|
|
44
|
+
return "";
|
|
45
|
+
default: {
|
|
46
|
+
if (prop in target) {
|
|
47
|
+
return target[prop];
|
|
48
|
+
} else {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
set(_target, prop) {
|
|
55
|
+
import_shared.logger.error(`Context is readonly, you can not assign to the "context.${prop}" prop.`);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const legacyAPI = {
|
|
60
|
+
...api,
|
|
61
|
+
context: builderContext,
|
|
62
|
+
getBuilderConfig: () => {
|
|
63
|
+
addDeprecatedWarning(plugin.name, "getBuilderConfig", "getRsbuildConfig");
|
|
64
|
+
return api.getRsbuildConfig();
|
|
65
|
+
},
|
|
66
|
+
modifyBuilderConfig: (fn) => {
|
|
67
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
|
|
68
|
+
addDeprecatedWarning(plugin.name, "modifyBuilderConfig", "modifyRsbuildConfig");
|
|
69
|
+
return fn(config, {
|
|
70
|
+
mergeBuilderConfig: mergeRsbuildConfig
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return plugin.setup(legacyAPI);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
compatLegacyPlugin
|
|
82
|
+
});
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NodeEnv, MetaOptions, ServerConfig, ScriptInject, RsbuildTarget, ChainedConfig, ChainedConfigWithUtils, InlineChunkTest, DevConfig, RequestHandler, RsbuildEntry } from '@rsbuild/shared';
|
|
1
|
+
import type { NodeEnv, MetaOptions, ServerConfig, ScriptInject, RsbuildTarget, ChainedConfig, ChainedConfigWithUtils, InlineChunkTest, DevConfig, RequestHandler, RsbuildEntry, PromiseOrNot, RsbuildPluginAPI } from '@rsbuild/shared';
|
|
2
2
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
3
3
|
import type { PluginAssetsRetryOptions } from '@rsbuild/plugin-assets-retry';
|
|
4
4
|
import type { PluginStyledComponentsOptions } from '@rsbuild/plugin-styled-components';
|
|
@@ -12,6 +12,7 @@ import type { PluginCheckSyntaxOptions } from '@rsbuild/plugin-check-syntax';
|
|
|
12
12
|
import type { PluginPugOptions } from '@rsbuild/plugin-pug';
|
|
13
13
|
import type { PluginBabelOptions } from '@rsbuild/plugin-babel';
|
|
14
14
|
import type { AliasOption } from '@modern-js/utils';
|
|
15
|
+
import type { StartDevServerOptions, UniBuilderStartServerResult } from './shared/devServer';
|
|
15
16
|
export type CreateBuilderCommonOptions = {
|
|
16
17
|
entry?: RsbuildEntry;
|
|
17
18
|
frameworkConfigPath?: string;
|
|
@@ -238,6 +239,49 @@ export type SriOptions = {
|
|
|
238
239
|
enabled?: 'auto' | true | false;
|
|
239
240
|
hashLoading?: 'eager' | 'lazy';
|
|
240
241
|
};
|
|
242
|
+
export type OverridesUniBuilderInstance = {
|
|
243
|
+
addPlugins: (plugins: UniBuilderPlugin[], options?: {
|
|
244
|
+
before?: string;
|
|
245
|
+
}) => void;
|
|
246
|
+
/**
|
|
247
|
+
* should be used in conjunction with the upper-layer framework:
|
|
248
|
+
*
|
|
249
|
+
* missing route.json (required in modern server)
|
|
250
|
+
*/
|
|
251
|
+
startDevServer: (options: StartDevServerOptions) => Promise<UniBuilderStartServerResult>;
|
|
252
|
+
};
|
|
253
|
+
export type UniBuilderContext = RsbuildPluginAPI['context'] & {
|
|
254
|
+
target: RsbuildPluginAPI['context']['targets'];
|
|
255
|
+
framework: string;
|
|
256
|
+
srcPath: string;
|
|
257
|
+
entry: Record<string, string | string[]>;
|
|
258
|
+
};
|
|
259
|
+
export type UniBuilderPluginAPI = {
|
|
260
|
+
[key in keyof RsbuildPluginAPI]: RsbuildPluginAPI[key];
|
|
261
|
+
} & {
|
|
262
|
+
/** The following APIs only type incompatibility */
|
|
263
|
+
onBeforeCreateCompiler: (fn: any) => void;
|
|
264
|
+
onAfterCreateCompiler: (fn: any) => void;
|
|
265
|
+
onBeforeBuild: (fn: any) => void;
|
|
266
|
+
modifyBundlerChain: (fn: any) => void;
|
|
267
|
+
getNormalizedConfig: () => any;
|
|
268
|
+
/** The following APIs need to be compatible */
|
|
269
|
+
context: UniBuilderContext;
|
|
270
|
+
getBuilderConfig: () => Readonly<any>;
|
|
271
|
+
modifyBuilderConfig: (fn: (config: any, utils: {
|
|
272
|
+
mergeBuilderConfig: <T>(...configs: T[]) => T;
|
|
273
|
+
}) => PromiseOrNot<any | void>) => void;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* compat legacy modern.js builder plugin
|
|
277
|
+
*/
|
|
278
|
+
export type UniBuilderPlugin = {
|
|
279
|
+
name: string;
|
|
280
|
+
setup: (api: UniBuilderPluginAPI) => PromiseOrNot<void>;
|
|
281
|
+
pre?: string[];
|
|
282
|
+
post?: string[];
|
|
283
|
+
remove?: string[];
|
|
284
|
+
};
|
|
241
285
|
export type UniBuilderConfig = {
|
|
242
286
|
dev?: RsbuildConfig['dev'];
|
|
243
287
|
html?: RsbuildConfig['html'];
|
|
@@ -246,4 +290,5 @@ export type UniBuilderConfig = {
|
|
|
246
290
|
security?: RsbuildConfig['security'];
|
|
247
291
|
tools?: RsbuildConfig['tools'];
|
|
248
292
|
source?: Omit<NonNullable<RsbuildConfig['source']>, 'alias'>;
|
|
293
|
+
plugins?: RsbuildConfig['plugins'];
|
|
249
294
|
} & UniBuilderExtraConfig;
|
package/dist/webpack/index.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { type RsbuildConfig, type RsbuildPlugin, type RsbuildInstance } from '@rsbuild/core';
|
|
2
2
|
import type { RsbuildProvider } from '@rsbuild/shared';
|
|
3
|
-
import type { UniBuilderConfig, CreateUniBuilderOptions, CreateBuilderCommonOptions } from '../types';
|
|
4
|
-
import type { StartDevServerOptions, UniBuilderStartServerResult } from '../shared/devServer';
|
|
3
|
+
import type { UniBuilderConfig, CreateUniBuilderOptions, CreateBuilderCommonOptions, OverridesUniBuilderInstance } from '../types';
|
|
5
4
|
export declare function parseConfig(uniBuilderConfig: UniBuilderConfig, options: CreateBuilderCommonOptions): Promise<{
|
|
6
5
|
rsbuildConfig: RsbuildConfig;
|
|
7
6
|
rsbuildPlugins: RsbuildPlugin[];
|
|
8
7
|
}>;
|
|
9
|
-
export type UniBuilderWebpackInstance = Omit<RsbuildInstance<RsbuildProvider<'webpack'>>,
|
|
10
|
-
startDevServer: (options: StartDevServerOptions) => Promise<UniBuilderStartServerResult>;
|
|
11
|
-
};
|
|
8
|
+
export type UniBuilderWebpackInstance = Omit<RsbuildInstance<RsbuildProvider<'webpack'>>, keyof OverridesUniBuilderInstance> & OverridesUniBuilderInstance;
|
|
12
9
|
export declare function createWebpackBuilder(options: CreateUniBuilderOptions): Promise<UniBuilderWebpackInstance>;
|
package/dist/webpack/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(webpack_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(webpack_exports);
|
|
35
35
|
var import_core = require("@rsbuild/core");
|
|
36
36
|
var import_parseCommonConfig = require("../shared/parseCommonConfig");
|
|
37
|
+
var import_compatLegacyPlugin = require("../shared/compatLegacyPlugin");
|
|
37
38
|
var import_moduleScopes = require("./plugins/moduleScopes");
|
|
38
39
|
var import_babel = require("./plugins/babel");
|
|
39
40
|
var import_react = require("./plugins/react");
|
|
@@ -94,6 +95,14 @@ async function createWebpackBuilder(options) {
|
|
|
94
95
|
]);
|
|
95
96
|
return {
|
|
96
97
|
...rsbuild,
|
|
98
|
+
addPlugins: (plugins, options2) => {
|
|
99
|
+
const warpedPlugins = plugins.map((plugin) => {
|
|
100
|
+
return (0, import_compatLegacyPlugin.compatLegacyPlugin)(plugin, {
|
|
101
|
+
cwd
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
rsbuild.addPlugins(warpedPlugins, options2);
|
|
105
|
+
},
|
|
97
106
|
startDevServer: async (options2 = {}) => {
|
|
98
107
|
const { startDevServer } = await Promise.resolve().then(() => __toESM(require("../shared/devServer")));
|
|
99
108
|
return startDevServer(rsbuild, options2, config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/uni-builder",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20240103170618",
|
|
4
4
|
"description": "Unified builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
"@babel/preset-react": "^7.22.15",
|
|
27
27
|
"@babel/types": "^7.23.0",
|
|
28
28
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
|
|
29
|
-
"@rsbuild/babel-preset": "0.2.
|
|
30
|
-
"@rsbuild/core": "0.2.
|
|
31
|
-
"@rsbuild/plugin-assets-retry": "0.2.
|
|
32
|
-
"@rsbuild/plugin-babel": "0.2.
|
|
33
|
-
"@rsbuild/plugin-check-syntax": "0.2.
|
|
34
|
-
"@rsbuild/plugin-css-minimizer": "0.2.
|
|
35
|
-
"@rsbuild/plugin-pug": "0.2.
|
|
36
|
-
"@rsbuild/plugin-react": "0.2.
|
|
37
|
-
"@rsbuild/plugin-rem": "0.2.
|
|
38
|
-
"@rsbuild/plugin-source-build": "0.2.
|
|
39
|
-
"@rsbuild/plugin-styled-components": "0.2.
|
|
40
|
-
"@rsbuild/plugin-svgr": "0.2.
|
|
41
|
-
"@rsbuild/plugin-type-check": "0.2.
|
|
42
|
-
"@rsbuild/shared": "0.2.
|
|
43
|
-
"@rsbuild/webpack": "0.2.
|
|
29
|
+
"@rsbuild/babel-preset": "0.2.15",
|
|
30
|
+
"@rsbuild/core": "0.2.15",
|
|
31
|
+
"@rsbuild/plugin-assets-retry": "0.2.15",
|
|
32
|
+
"@rsbuild/plugin-babel": "0.2.15",
|
|
33
|
+
"@rsbuild/plugin-check-syntax": "0.2.15",
|
|
34
|
+
"@rsbuild/plugin-css-minimizer": "0.2.15",
|
|
35
|
+
"@rsbuild/plugin-pug": "0.2.15",
|
|
36
|
+
"@rsbuild/plugin-react": "0.2.15",
|
|
37
|
+
"@rsbuild/plugin-rem": "0.2.15",
|
|
38
|
+
"@rsbuild/plugin-source-build": "0.2.15",
|
|
39
|
+
"@rsbuild/plugin-styled-components": "0.2.15",
|
|
40
|
+
"@rsbuild/plugin-svgr": "0.2.15",
|
|
41
|
+
"@rsbuild/plugin-type-check": "0.2.15",
|
|
42
|
+
"@rsbuild/shared": "0.2.15",
|
|
43
|
+
"@rsbuild/webpack": "0.2.15",
|
|
44
44
|
"@swc/helpers": "0.5.3",
|
|
45
45
|
"babel-loader": "9.1.3",
|
|
46
46
|
"babel-plugin-import": "1.13.5",
|
|
@@ -62,18 +62,19 @@
|
|
|
62
62
|
"webpack": "^5.89.0",
|
|
63
63
|
"webpack-manifest-plugin": "5.0.0",
|
|
64
64
|
"webpack-subresource-integrity": "5.1.0",
|
|
65
|
-
"@modern-js/
|
|
66
|
-
"@modern-js/
|
|
67
|
-
"@modern-js/
|
|
65
|
+
"@modern-js/utils": "0.0.0-nightly-20240103170618",
|
|
66
|
+
"@modern-js/server": "0.0.0-nightly-20240103170618",
|
|
67
|
+
"@modern-js/prod-server": "0.0.0-nightly-20240103170618"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@rsbuild/plugin-swc": "0.2.
|
|
70
|
+
"@rsbuild/plugin-swc": "0.2.15",
|
|
71
71
|
"@types/lodash": "^4.14.202",
|
|
72
72
|
"react": "^18.2.0",
|
|
73
73
|
"react-dom": "^18.2.0",
|
|
74
74
|
"typescript": "^5.3.0",
|
|
75
|
-
"@
|
|
76
|
-
"@scripts/
|
|
75
|
+
"@modern-js/builder-plugin-node-polyfill": "0.0.0-nightly-20240103170618",
|
|
76
|
+
"@scripts/build": "0.0.0-nightly-20240103170618",
|
|
77
|
+
"@scripts/vitest-config": "0.0.0-nightly-20240103170618"
|
|
77
78
|
},
|
|
78
79
|
"publishConfig": {
|
|
79
80
|
"access": "public",
|