@modern-js/app-tools 2.45.0 → 2.45.1-alpha.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/cjs/analyze/nestedRoutes.js +1 -1
- package/dist/cjs/analyze/templates.js +0 -2
- package/dist/cjs/builder/builder-rspack/index.js +1 -2
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +2 -0
- package/dist/cjs/builder/builder-webpack/index.js +3 -4
- package/dist/cjs/builder/generator/createBuilderOptions.js +2 -3
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +1 -0
- package/dist/cjs/builder/generator/index.js +9 -8
- package/dist/cjs/builder/index.js +2 -10
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +1 -3
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +3 -3
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +4 -4
- package/dist/cjs/commands/dev.js +0 -1
- package/dist/cjs/config/default.js +12 -12
- package/dist/cjs/initialize/index.js +1 -1
- package/dist/esm/analyze/nestedRoutes.js +1 -1
- package/dist/esm/analyze/templates.js +1 -1
- package/dist/esm/builder/builder-rspack/index.js +1 -2
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +2 -0
- package/dist/esm/builder/builder-webpack/index.js +5 -6
- package/dist/esm/builder/generator/createBuilderOptions.js +2 -3
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +1 -0
- package/dist/esm/builder/generator/index.js +14 -12
- package/dist/esm/builder/index.js +5 -30
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +1 -3
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +1 -1
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +3 -3
- package/dist/esm/commands/dev.js +0 -1
- package/dist/esm/config/default.js +20 -15
- package/dist/esm/initialize/index.js +1 -1
- package/dist/esm-node/analyze/nestedRoutes.js +1 -1
- package/dist/esm-node/analyze/templates.js +0 -2
- package/dist/esm-node/builder/builder-rspack/index.js +1 -2
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +2 -0
- package/dist/esm-node/builder/builder-webpack/index.js +3 -4
- package/dist/esm-node/builder/generator/createBuilderOptions.js +2 -3
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +1 -0
- package/dist/esm-node/builder/generator/index.js +9 -8
- package/dist/esm-node/builder/index.js +2 -10
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +1 -3
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +1 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +3 -3
- package/dist/esm-node/commands/dev.js +0 -1
- package/dist/esm-node/config/default.js +12 -12
- package/dist/esm-node/initialize/index.js +1 -1
- package/dist/types/analyze/generateCode.d.ts +2 -2
- package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -3
- package/dist/types/builder/builder-rspack/index.d.ts +1 -1
- package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -3
- package/dist/types/builder/builder-webpack/createCopyPattern.d.ts +2 -12
- package/dist/types/builder/builder-webpack/index.d.ts +1 -3
- package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -2
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +1 -1
- package/dist/types/builder/generator/getBuilderTargets.d.ts +2 -2
- package/dist/types/builder/generator/index.d.ts +4 -6
- package/dist/types/builder/index.d.ts +1 -1
- package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +2 -3
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +3 -3
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +3 -3
- package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +1 -3
- package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +1 -3
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +3 -5
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +1 -2
- package/dist/types/builder/shared/types.d.ts +0 -7
- package/dist/types/commands/inspect.d.ts +1 -8
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/config/initialize/inits.d.ts +1 -1
- package/dist/types/defineConfig.d.ts +1 -1
- package/dist/types/types/config/dev.d.ts +2 -2
- package/dist/types/types/config/experiments.d.ts +2 -2
- package/dist/types/types/config/html.d.ts +3 -5
- package/dist/types/types/config/index.d.ts +15 -31
- package/dist/types/types/config/output.d.ts +3 -10
- package/dist/types/types/config/performance.d.ts +3 -6
- package/dist/types/types/config/security.d.ts +2 -7
- package/dist/types/types/config/source.d.ts +2 -7
- package/dist/types/types/config/tools.d.ts +11 -13
- package/dist/types/types/hooks.d.ts +2 -3
- package/dist/types/types/index.d.ts +5 -14
- package/dist/types/types/legacyConfig/output.d.ts +1 -1
- package/dist/types/types/legacyConfig/tools.d.ts +2 -2
- package/package.json +10 -20
@@ -143,7 +143,7 @@ const walk = async (dirname, rootDir, alias, entryName, isMainEntry, oldVersion)
|
|
143
143
|
const items = await import_utils.fs.readdir(dirname);
|
144
144
|
for (const item of items) {
|
145
145
|
const itemPath = path.join(dirname, item);
|
146
|
-
const itemPathWithAlias = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
146
|
+
const itemPathWithAlias = getPathWithoutExt((0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name));
|
147
147
|
const extname = path.extname(item);
|
148
148
|
const itemWithoutExt = item.slice(0, -extname.length);
|
149
149
|
const isDirectory2 = (await import_utils.fs.stat(itemPath)).isDirectory();
|
@@ -21,11 +21,10 @@ __export(builder_rspack_exports, {
|
|
21
21
|
createRspackBuilderForModern: () => createRspackBuilderForModern
|
22
22
|
});
|
23
23
|
module.exports = __toCommonJS(builder_rspack_exports);
|
24
|
-
var import_builder_rspack_provider = require("@modern-js/builder-rspack-provider");
|
25
24
|
var import_generator = require("../generator");
|
26
25
|
var import_adapterCopy = require("./adapterCopy");
|
27
26
|
async function createRspackBuilderForModern(options) {
|
28
|
-
const builder = await (0, import_generator.generateBuilder)(options,
|
27
|
+
const builder = await (0, import_generator.generateBuilder)(options, "rspack");
|
29
28
|
builder.addPlugins([
|
30
29
|
(0, import_adapterCopy.builderPluginAdpaterCopy)(options)
|
31
30
|
]);
|
@@ -51,6 +51,8 @@ function createPublicPattern(appContext, config, chain) {
|
|
51
51
|
function createUploadPattern(appContext, config) {
|
52
52
|
const { uploadDir } = (0, import_shared.createCopyInfo)(appContext, config);
|
53
53
|
return {
|
54
|
+
// rspack copy info structure is inconsistent with webpack, it only used in webpack mode
|
55
|
+
// @ts-expect-error
|
54
56
|
info,
|
55
57
|
from: "**/*",
|
56
58
|
to: "upload",
|
@@ -31,17 +31,16 @@ __export(builder_webpack_exports, {
|
|
31
31
|
createWebpackBuilderForModern: () => createWebpackBuilderForModern
|
32
32
|
});
|
33
33
|
module.exports = __toCommonJS(builder_webpack_exports);
|
34
|
-
var import_builder_webpack_provider = require("@modern-js/builder-webpack-provider");
|
35
34
|
var import_generator = require("../generator");
|
36
35
|
var import_adapterModern = require("./adapterModern");
|
37
36
|
async function createWebpackBuilderForModern(options) {
|
38
|
-
const builder = await (0, import_generator.generateBuilder)(options,
|
37
|
+
const builder = await (0, import_generator.generateBuilder)(options, "webpack");
|
39
38
|
const { normalizedConfig } = options;
|
40
39
|
if (normalizedConfig.tools.esbuild) {
|
41
40
|
const { esbuild: esbuildOptions } = normalizedConfig.tools;
|
42
|
-
const {
|
41
|
+
const { pluginEsbuild } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-esbuild")));
|
43
42
|
builder.addPlugins([
|
44
|
-
|
43
|
+
pluginEsbuild(esbuildOptions)
|
45
44
|
]);
|
46
45
|
}
|
47
46
|
builder.addPlugins([
|
@@ -40,9 +40,8 @@ function createBuilderOptions(target, appContext) {
|
|
40
40
|
return {
|
41
41
|
cwd: appContext.appDirectory,
|
42
42
|
target,
|
43
|
-
|
44
|
-
entry: entries
|
45
|
-
framework: appContext.metaName
|
43
|
+
frameworkConfigPath: appContext.configFile || void 0,
|
44
|
+
entry: entries
|
46
45
|
};
|
47
46
|
}
|
48
47
|
// Annotate the CommonJS export names for ESM import in node:
|
@@ -31,19 +31,20 @@ __export(generator_exports, {
|
|
31
31
|
generateBuilder: () => generateBuilder
|
32
32
|
});
|
33
33
|
module.exports = __toCommonJS(generator_exports);
|
34
|
-
var
|
34
|
+
var import_uni_builder = require("@modern-js/uni-builder");
|
35
35
|
var import_createBuilderProviderConfig = require("./createBuilderProviderConfig");
|
36
36
|
var import_getBuilderTargets = require("./getBuilderTargets");
|
37
37
|
var import_createBuilderOptions = require("./createBuilderOptions");
|
38
|
-
async function generateBuilder(options,
|
38
|
+
async function generateBuilder(options, bundlerType) {
|
39
39
|
const { normalizedConfig, appContext } = options;
|
40
40
|
const builderConfig = (0, import_createBuilderProviderConfig.createBuilderProviderConfig)(normalizedConfig, appContext);
|
41
|
-
const provider = generateProvider({
|
42
|
-
builderConfig
|
43
|
-
});
|
44
41
|
const target = (0, import_getBuilderTargets.getBuilderTargets)(normalizedConfig);
|
45
42
|
const builderOptions = (0, import_createBuilderOptions.createBuilderOptions)(target, appContext);
|
46
|
-
const builder = await (0,
|
43
|
+
const builder = await (0, import_uni_builder.createUniBuilder)({
|
44
|
+
...builderOptions,
|
45
|
+
bundlerType,
|
46
|
+
config: builderConfig
|
47
|
+
});
|
47
48
|
await applyBuilderPlugins(builder, options);
|
48
49
|
return builder;
|
49
50
|
}
|
@@ -56,9 +57,9 @@ async function applyBuilderPlugins(builder, options) {
|
|
56
57
|
]);
|
57
58
|
const { normalizedConfig } = options;
|
58
59
|
if (!normalizedConfig.output.disableNodePolyfill) {
|
59
|
-
const {
|
60
|
+
const { pluginNodePolyfill } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-node-polyfill")));
|
60
61
|
builder.addPlugins([
|
61
|
-
|
62
|
+
pluginNodePolyfill()
|
62
63
|
]);
|
63
64
|
}
|
64
65
|
}
|
@@ -31,18 +31,10 @@ __export(builder_exports, {
|
|
31
31
|
createBuilderGenerator: () => createBuilderGenerator
|
32
32
|
});
|
33
33
|
module.exports = __toCommonJS(builder_exports);
|
34
|
-
var import_utils = require("@modern-js/utils");
|
35
34
|
async function createBuilderGenerator(bundler) {
|
36
35
|
if (bundler === "rspack") {
|
37
|
-
|
38
|
-
|
39
|
-
const { getRspackVersion } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-rspack-provider")));
|
40
|
-
const version = await getRspackVersion();
|
41
|
-
import_utils.logger.info(`Using Rspack v${version}`);
|
42
|
-
return createRspackBuilderForModern;
|
43
|
-
} catch (_) {
|
44
|
-
throw new Error("Failed to use Rspack, please check if you have `@modern-js/builder-rspack-provider` installed");
|
45
|
-
}
|
36
|
+
const { createRspackBuilderForModern } = await Promise.resolve().then(() => __toESM(require("./builder-rspack")));
|
37
|
+
return createRspackBuilderForModern;
|
46
38
|
}
|
47
39
|
const { createWebpackBuilderForModern } = await Promise.resolve().then(() => __toESM(require("./builder-webpack")));
|
48
40
|
return createWebpackBuilderForModern;
|
@@ -42,15 +42,13 @@ const builderPluginAdapterBasic = () => ({
|
|
42
42
|
chain.name("service-worker");
|
43
43
|
} else if (target === "web-worker") {
|
44
44
|
chain.name("worker");
|
45
|
-
} else if (target === "modern-web") {
|
46
|
-
chain.name("modern");
|
47
45
|
} else {
|
48
46
|
chain.name("client");
|
49
47
|
}
|
50
48
|
if (target === "node" || target === "service-worker") {
|
51
49
|
applyNodeCompat(target, chain);
|
52
50
|
}
|
53
|
-
if (target === "web"
|
51
|
+
if (target === "web") {
|
54
52
|
const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
55
53
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
56
54
|
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
@@ -21,7 +21,7 @@ __export(adapterHtml_exports, {
|
|
21
21
|
builderPluginAdapterHtml: () => builderPluginAdapterHtml
|
22
22
|
});
|
23
23
|
module.exports = __toCommonJS(adapterHtml_exports);
|
24
|
-
var
|
24
|
+
var import_shared = require("@rsbuild/shared");
|
25
25
|
var import_utils = require("@modern-js/utils");
|
26
26
|
var import_lodash = require("@modern-js/utils/lodash");
|
27
27
|
var import_bundlerPlugins = require("../bundlerPlugins");
|
@@ -30,7 +30,7 @@ const builderPluginAdapterHtml = (options) => ({
|
|
30
30
|
setup(api) {
|
31
31
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, target, HtmlPlugin: HtmlBundlerPlugin }) => {
|
32
32
|
const builderConfig = api.getNormalizedConfig();
|
33
|
-
if (!(0,
|
33
|
+
if (!(0, import_shared.isHtmlDisabled)(builderConfig, target)) {
|
34
34
|
applyBottomHtmlPlugin({
|
35
35
|
api,
|
36
36
|
options,
|
@@ -51,7 +51,7 @@ async function injectAssetPrefix({ chain }) {
|
|
51
51
|
const assetPrefix = (0, import_utils.removeTailSlash)(chain.output.get("publicPath") || "");
|
52
52
|
const code = `window.__assetPrefix__ = '${assetPrefix}';`;
|
53
53
|
entryNames.forEach((entryName) => {
|
54
|
-
entries[entryName].prepend((0,
|
54
|
+
entries[entryName].prepend((0, import_shared.createVirtualModule)(code));
|
55
55
|
});
|
56
56
|
}
|
57
57
|
function applyBottomHtmlPlugin({ api, chain, options, CHAIN_ID, HtmlBundlerPlugin }) {
|
@@ -32,7 +32,7 @@ __export(adapterSSR_exports, {
|
|
32
32
|
});
|
33
33
|
module.exports = __toCommonJS(adapterSSR_exports);
|
34
34
|
var path = __toESM(require("path"));
|
35
|
-
var
|
35
|
+
var import_shared = require("@rsbuild/shared");
|
36
36
|
var import_utils = require("@modern-js/utils");
|
37
37
|
var import_bundlerPlugins = require("../bundlerPlugins");
|
38
38
|
var import_utils2 = require("../../../analyze/utils");
|
@@ -40,9 +40,9 @@ const builderPluginAdapterSSR = (options) => ({
|
|
40
40
|
name: "builder-plugin-adapter-modern-ssr",
|
41
41
|
setup(api) {
|
42
42
|
const { normalizedConfig } = options;
|
43
|
-
api.
|
43
|
+
api.modifyRsbuildConfig((config) => {
|
44
44
|
if (isStreamingSSR(normalizedConfig)) {
|
45
|
-
return (0,
|
45
|
+
return (0, import_shared.mergeRsbuildConfig)(config, {
|
46
46
|
html: {
|
47
47
|
inject: "body"
|
48
48
|
}
|
@@ -68,7 +68,7 @@ const builderPluginAdapterSSR = (options) => ({
|
|
68
68
|
appNormalizedConfig: normalizedConfig2
|
69
69
|
});
|
70
70
|
}
|
71
|
-
if (!(0,
|
71
|
+
if (!(0, import_shared.isHtmlDisabled)(builderConfig, target)) {
|
72
72
|
applyAsyncChunkHtmlPlugin({
|
73
73
|
chain,
|
74
74
|
modernConfig: options.normalizedConfig,
|
package/dist/cjs/commands/dev.js
CHANGED
@@ -22,25 +22,29 @@ __export(default_exports, {
|
|
22
22
|
createLegacyDefaultConfig: () => createLegacyDefaultConfig
|
23
23
|
});
|
24
24
|
module.exports = __toCommonJS(default_exports);
|
25
|
-
var import_builder_webpack_provider = require("@modern-js/builder-webpack-provider");
|
26
25
|
var import_utils = require("@modern-js/utils");
|
27
26
|
var import_env = require("../utils/env");
|
28
|
-
function createDefaultConfig(appContext
|
29
|
-
const defaultBuilderConfig = (0, import_builder_webpack_provider.createDefaultConfig)();
|
27
|
+
function createDefaultConfig(appContext) {
|
30
28
|
const dev = {
|
31
|
-
...defaultBuilderConfig.dev,
|
32
29
|
// `dev.port` should not have a default value
|
33
30
|
// because we will use `server.port` by default
|
34
31
|
port: void 0
|
35
32
|
};
|
36
33
|
const output = {
|
37
|
-
|
34
|
+
distPath: {
|
35
|
+
root: "dist",
|
36
|
+
html: "html",
|
37
|
+
js: "static/js",
|
38
|
+
css: "static/css",
|
39
|
+
server: "bundles",
|
40
|
+
worker: "worker"
|
41
|
+
},
|
42
|
+
cleanDistPath: true,
|
38
43
|
disableNodePolyfill: true,
|
39
44
|
enableInlineRouteManifests: true,
|
40
45
|
disableInlineRouteManifests: false
|
41
46
|
};
|
42
47
|
const source = {
|
43
|
-
...defaultBuilderConfig.source,
|
44
48
|
entries: void 0,
|
45
49
|
mainEntryName: import_utils.MAIN_ENTRY_NAME,
|
46
50
|
enableAsyncEntry: false,
|
@@ -56,8 +60,8 @@ function createDefaultConfig(appContext, bundler) {
|
|
56
60
|
}
|
57
61
|
};
|
58
62
|
const html = {
|
59
|
-
...defaultBuilderConfig.html,
|
60
63
|
title: "",
|
64
|
+
mountId: "root",
|
61
65
|
meta: {
|
62
66
|
charset: {
|
63
67
|
charset: "utf-8"
|
@@ -82,7 +86,7 @@ function createDefaultConfig(appContext, bundler) {
|
|
82
86
|
baseUrl: "/",
|
83
87
|
port: 8080
|
84
88
|
};
|
85
|
-
const
|
89
|
+
const tools = {
|
86
90
|
tsChecker: {
|
87
91
|
issue: {
|
88
92
|
include: [
|
@@ -93,10 +97,6 @@ function createDefaultConfig(appContext, bundler) {
|
|
93
97
|
}
|
94
98
|
}
|
95
99
|
};
|
96
|
-
const tools = bundler === "webpack" ? {
|
97
|
-
...defaultBuilderConfig.tools,
|
98
|
-
...defaultTsCheckerConfig
|
99
|
-
} : defaultTsCheckerConfig;
|
100
100
|
return {
|
101
101
|
source,
|
102
102
|
output,
|
@@ -41,7 +41,7 @@ var initialize_default = ({ bundler }) => ({
|
|
41
41
|
...appContext,
|
42
42
|
bundlerType: bundler
|
43
43
|
});
|
44
|
-
return (0, import_config.checkIsLegacyConfig)(userConfig) ? (0, import_config.createLegacyDefaultConfig)(appContext) : (0, import_config.createDefaultConfig)(appContext
|
44
|
+
return (0, import_config.checkIsLegacyConfig)(userConfig) ? (0, import_config.createLegacyDefaultConfig)(appContext) : (0, import_config.createDefaultConfig)(appContext);
|
45
45
|
};
|
46
46
|
return {
|
47
47
|
config,
|
@@ -150,7 +150,7 @@ var walk = function() {
|
|
150
150
|
];
|
151
151
|
item = _step.value;
|
152
152
|
itemPath = path.join(dirname, item);
|
153
|
-
itemPathWithAlias = replaceWithAlias(alias.basename, itemPath, alias.name);
|
153
|
+
itemPathWithAlias = getPathWithoutExt(replaceWithAlias(alias.basename, itemPath, alias.name));
|
154
154
|
extname = path.extname(item);
|
155
155
|
itemWithoutExt = item.slice(0, -extname.length);
|
156
156
|
return [
|
@@ -21,7 +21,7 @@ var renderFunction = function(param) {
|
|
21
21
|
}).join("\n"), "\n ]\n })(").concat(fileSystemRoutes2 ? "" : "App", ")\n\n\n if(!AppWrapper.init && typeof appInit !== 'undefined') {\n AppWrapper.init = appInit;\n }\n\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper, () => ".concat(bootstrap, ");") : "".concat(bootstrap, ";"), "\n }\n\n return AppWrapper\n");
|
22
22
|
};
|
23
23
|
var html = function(partials) {
|
24
|
-
return "\n<!DOCTYPE html>\n<html>\n<head>\n
|
24
|
+
return "\n<!DOCTYPE html>\n<html>\n<head>\n\n ".concat(partials.top.join("\n"), "\n\n ").concat(partials.head.join("\n"), '\n\n</head>\n\n<body>\n <div id="<%= mountId %>"><!--<?- html ?>--></div>\n ').concat(partials.body.join("\n"), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
|
25
25
|
};
|
26
26
|
var routesForServer = function(param) {
|
27
27
|
var routes = param.routes;
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import { builderRspackProvider } from "@modern-js/builder-rspack-provider";
|
4
3
|
import { generateBuilder } from "../generator";
|
5
4
|
import { builderPluginAdpaterCopy } from "./adapterCopy";
|
6
5
|
function createRspackBuilderForModern(options) {
|
@@ -14,7 +13,7 @@ function _createRspackBuilderForModern() {
|
|
14
13
|
case 0:
|
15
14
|
return [
|
16
15
|
4,
|
17
|
-
generateBuilder(options,
|
16
|
+
generateBuilder(options, "rspack")
|
18
17
|
];
|
19
18
|
case 1:
|
20
19
|
builder = _state.sent();
|
@@ -29,6 +29,8 @@ function createPublicPattern(appContext, config, chain) {
|
|
29
29
|
function createUploadPattern(appContext, config) {
|
30
30
|
var uploadDir = createCopyInfo(appContext, config).uploadDir;
|
31
31
|
return {
|
32
|
+
// rspack copy info structure is inconsistent with webpack, it only used in webpack mode
|
33
|
+
// @ts-expect-error
|
32
34
|
info,
|
33
35
|
from: "**/*",
|
34
36
|
to: "upload",
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import { builderWebpackProvider } from "@modern-js/builder-webpack-provider";
|
4
3
|
import { generateBuilder } from "../generator";
|
5
4
|
import { builderPluginAdapterModern } from "./adapterModern";
|
6
5
|
function createWebpackBuilderForModern(options) {
|
@@ -8,13 +7,13 @@ function createWebpackBuilderForModern(options) {
|
|
8
7
|
}
|
9
8
|
function _createWebpackBuilderForModern() {
|
10
9
|
_createWebpackBuilderForModern = _async_to_generator(function(options) {
|
11
|
-
var builder, normalizedConfig, _normalizedConfig_tools, esbuildOptions,
|
10
|
+
var builder, normalizedConfig, _normalizedConfig_tools, esbuildOptions, pluginEsbuild;
|
12
11
|
return _ts_generator(this, function(_state) {
|
13
12
|
switch (_state.label) {
|
14
13
|
case 0:
|
15
14
|
return [
|
16
15
|
4,
|
17
|
-
generateBuilder(options,
|
16
|
+
generateBuilder(options, "webpack")
|
18
17
|
];
|
19
18
|
case 1:
|
20
19
|
builder = _state.sent();
|
@@ -27,12 +26,12 @@ function _createWebpackBuilderForModern() {
|
|
27
26
|
_normalizedConfig_tools = normalizedConfig.tools, esbuildOptions = _normalizedConfig_tools.esbuild;
|
28
27
|
return [
|
29
28
|
4,
|
30
|
-
import("@
|
29
|
+
import("@rsbuild/plugin-esbuild")
|
31
30
|
];
|
32
31
|
case 2:
|
33
|
-
|
32
|
+
pluginEsbuild = _state.sent().pluginEsbuild;
|
34
33
|
builder.addPlugins([
|
35
|
-
|
34
|
+
pluginEsbuild(esbuildOptions)
|
36
35
|
]);
|
37
36
|
_state.label = 3;
|
38
37
|
case 3:
|
@@ -34,9 +34,8 @@ function createBuilderOptions(target, appContext) {
|
|
34
34
|
return {
|
35
35
|
cwd: appContext.appDirectory,
|
36
36
|
target,
|
37
|
-
|
38
|
-
entry: entries
|
39
|
-
framework: appContext.metaName
|
37
|
+
frameworkConfigPath: appContext.configFile || void 0,
|
38
|
+
entry: entries
|
40
39
|
};
|
41
40
|
}
|
42
41
|
export {
|
@@ -19,6 +19,7 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
19
19
|
htmlConfig.templateByEntries = _object_spread({}, appContext.htmlTemplates, htmlConfig.templateByEntries);
|
20
20
|
}
|
21
21
|
var config = _object_spread_props(_object_spread({}, resolveConfig), {
|
22
|
+
plugins: [],
|
22
23
|
dev: _object_spread_props(_object_spread({}, resolveConfig.dev), {
|
23
24
|
port: appContext.port
|
24
25
|
}),
|
@@ -1,28 +1,30 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
3
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
2
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import {
|
5
|
+
import { createUniBuilder } from "@modern-js/uni-builder";
|
4
6
|
import { createBuilderProviderConfig } from "./createBuilderProviderConfig";
|
5
7
|
import { getBuilderTargets } from "./getBuilderTargets";
|
6
8
|
import { createBuilderOptions } from "./createBuilderOptions";
|
7
|
-
function generateBuilder(options,
|
9
|
+
function generateBuilder(options, bundlerType) {
|
8
10
|
return _generateBuilder.apply(this, arguments);
|
9
11
|
}
|
10
12
|
function _generateBuilder() {
|
11
|
-
_generateBuilder = _async_to_generator(function(options,
|
12
|
-
var normalizedConfig, appContext, builderConfig,
|
13
|
+
_generateBuilder = _async_to_generator(function(options, bundlerType) {
|
14
|
+
var normalizedConfig, appContext, builderConfig, target, builderOptions, builder;
|
13
15
|
return _ts_generator(this, function(_state) {
|
14
16
|
switch (_state.label) {
|
15
17
|
case 0:
|
16
18
|
normalizedConfig = options.normalizedConfig, appContext = options.appContext;
|
17
19
|
builderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
|
18
|
-
provider = generateProvider({
|
19
|
-
builderConfig
|
20
|
-
});
|
21
20
|
target = getBuilderTargets(normalizedConfig);
|
22
21
|
builderOptions = createBuilderOptions(target, appContext);
|
23
22
|
return [
|
24
23
|
4,
|
25
|
-
|
24
|
+
createUniBuilder(_object_spread_props(_object_spread({}, builderOptions), {
|
25
|
+
bundlerType,
|
26
|
+
config: builderConfig
|
27
|
+
}))
|
26
28
|
];
|
27
29
|
case 1:
|
28
30
|
builder = _state.sent();
|
@@ -46,7 +48,7 @@ function applyBuilderPlugins(builder, options) {
|
|
46
48
|
}
|
47
49
|
function _applyBuilderPlugins() {
|
48
50
|
_applyBuilderPlugins = _async_to_generator(function(builder, options) {
|
49
|
-
var _ref, builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, normalizedConfig,
|
51
|
+
var _ref, builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, normalizedConfig, pluginNodePolyfill;
|
50
52
|
return _ts_generator(this, function(_state) {
|
51
53
|
switch (_state.label) {
|
52
54
|
case 0:
|
@@ -69,12 +71,12 @@ function _applyBuilderPlugins() {
|
|
69
71
|
];
|
70
72
|
return [
|
71
73
|
4,
|
72
|
-
import("@
|
74
|
+
import("@rsbuild/plugin-node-polyfill")
|
73
75
|
];
|
74
76
|
case 2:
|
75
|
-
|
77
|
+
pluginNodePolyfill = _state.sent().pluginNodePolyfill;
|
76
78
|
builder.addPlugins([
|
77
|
-
|
79
|
+
pluginNodePolyfill()
|
78
80
|
]);
|
79
81
|
_state.label = 3;
|
80
82
|
case 3:
|
@@ -1,60 +1,35 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import { logger } from "@modern-js/utils";
|
4
3
|
function createBuilderGenerator(bundler) {
|
5
4
|
return _createBuilderGenerator.apply(this, arguments);
|
6
5
|
}
|
7
6
|
function _createBuilderGenerator() {
|
8
7
|
_createBuilderGenerator = _async_to_generator(function(bundler) {
|
9
|
-
var createRspackBuilderForModern,
|
8
|
+
var createRspackBuilderForModern, createWebpackBuilderForModern;
|
10
9
|
return _ts_generator(this, function(_state) {
|
11
10
|
switch (_state.label) {
|
12
11
|
case 0:
|
13
12
|
if (!(bundler === "rspack"))
|
14
13
|
return [
|
15
14
|
3,
|
16
|
-
|
15
|
+
2
|
17
16
|
];
|
18
|
-
_state.label = 1;
|
19
|
-
case 1:
|
20
|
-
_state.trys.push([
|
21
|
-
1,
|
22
|
-
5,
|
23
|
-
,
|
24
|
-
6
|
25
|
-
]);
|
26
17
|
return [
|
27
18
|
4,
|
28
19
|
import("./builder-rspack")
|
29
20
|
];
|
30
|
-
case
|
21
|
+
case 1:
|
31
22
|
createRspackBuilderForModern = _state.sent().createRspackBuilderForModern;
|
32
|
-
return [
|
33
|
-
4,
|
34
|
-
import("@modern-js/builder-rspack-provider")
|
35
|
-
];
|
36
|
-
case 3:
|
37
|
-
getRspackVersion = _state.sent().getRspackVersion;
|
38
|
-
return [
|
39
|
-
4,
|
40
|
-
getRspackVersion()
|
41
|
-
];
|
42
|
-
case 4:
|
43
|
-
version = _state.sent();
|
44
|
-
logger.info("Using Rspack v".concat(version));
|
45
23
|
return [
|
46
24
|
2,
|
47
25
|
createRspackBuilderForModern
|
48
26
|
];
|
49
|
-
case
|
50
|
-
_ = _state.sent();
|
51
|
-
throw new Error("Failed to use Rspack, please check if you have `@modern-js/builder-rspack-provider` installed");
|
52
|
-
case 6:
|
27
|
+
case 2:
|
53
28
|
return [
|
54
29
|
4,
|
55
30
|
import("./builder-webpack")
|
56
31
|
];
|
57
|
-
case
|
32
|
+
case 3:
|
58
33
|
createWebpackBuilderForModern = _state.sent().createWebpackBuilderForModern;
|
59
34
|
return [
|
60
35
|
2,
|
@@ -11,15 +11,13 @@ var builderPluginAdapterBasic = function() {
|
|
11
11
|
chain.name("service-worker");
|
12
12
|
} else if (target === "web-worker") {
|
13
13
|
chain.name("worker");
|
14
|
-
} else if (target === "modern-web") {
|
15
|
-
chain.name("modern");
|
16
14
|
} else {
|
17
15
|
chain.name("client");
|
18
16
|
}
|
19
17
|
if (target === "node" || target === "service-worker") {
|
20
18
|
applyNodeCompat(target, chain);
|
21
19
|
}
|
22
|
-
if (target === "web"
|
20
|
+
if (target === "web") {
|
23
21
|
var bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
24
22
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
25
23
|
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
@@ -2,7 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
5
|
-
import { isHtmlDisabled, createVirtualModule } from "@
|
5
|
+
import { isHtmlDisabled, createVirtualModule } from "@rsbuild/shared";
|
6
6
|
import { MAIN_ENTRY_NAME, getEntryOptions, removeTailSlash } from "@modern-js/utils";
|
7
7
|
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
8
8
|
import { BottomTemplatePlugin } from "../bundlerPlugins";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
3
|
import * as path from "path";
|
4
|
-
import { isHtmlDisabled,
|
4
|
+
import { isHtmlDisabled, mergeRsbuildConfig } from "@rsbuild/shared";
|
5
5
|
import { isSSR, fs } from "@modern-js/utils";
|
6
6
|
import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
|
7
7
|
import { getServerCombinedModueFile } from "../../../analyze/utils";
|
@@ -10,9 +10,9 @@ var builderPluginAdapterSSR = function(options) {
|
|
10
10
|
name: "builder-plugin-adapter-modern-ssr",
|
11
11
|
setup: function setup(api) {
|
12
12
|
var normalizedConfig = options.normalizedConfig;
|
13
|
-
api.
|
13
|
+
api.modifyRsbuildConfig(function(config) {
|
14
14
|
if (isStreamingSSR(normalizedConfig)) {
|
15
|
-
return
|
15
|
+
return mergeRsbuildConfig(config, {
|
16
16
|
html: {
|
17
17
|
inject: "body"
|
18
18
|
}
|