@modern-js/app-tools 2.68.17 → 2.68.19
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/builder/generator/createBuilderProviderConfig.js +19 -0
- package/dist/cjs/builder/generator/index.js +15 -1
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +0 -10
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +17 -0
- package/dist/esm/builder/generator/index.js +15 -2
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +1 -11
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +19 -0
- package/dist/esm-node/builder/generator/index.js +15 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -10
- package/package.json +16 -16
|
@@ -21,6 +21,7 @@ __export(createBuilderProviderConfig_exports, {
|
|
|
21
21
|
createBuilderProviderConfig: () => createBuilderProviderConfig
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(createBuilderProviderConfig_exports);
|
|
24
|
+
var import_utils = require("@modern-js/utils");
|
|
24
25
|
var import_createCopyPattern = require("./createCopyPattern");
|
|
25
26
|
function modifyOutputConfig(config, appContext) {
|
|
26
27
|
const defaultCopyPattern = (0, import_createCopyPattern.createUploadPattern)(appContext, config);
|
|
@@ -36,6 +37,7 @@ function modifyOutputConfig(config, appContext) {
|
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
40
|
+
var _resolveConfig_tools;
|
|
39
41
|
const htmlConfig = {
|
|
40
42
|
...resolveConfig.html
|
|
41
43
|
};
|
|
@@ -61,6 +63,23 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
61
63
|
...resolveConfig.output,
|
|
62
64
|
// We need to do this in the app-tools prepare hook because some files will be generated into the dist directory in the analyze process
|
|
63
65
|
cleanDistPath: false
|
|
66
|
+
},
|
|
67
|
+
tools: {
|
|
68
|
+
...resolveConfig.tools,
|
|
69
|
+
devServer: {
|
|
70
|
+
...(_resolveConfig_tools = resolveConfig.tools) === null || _resolveConfig_tools === void 0 ? void 0 : _resolveConfig_tools.devServer,
|
|
71
|
+
compress: {
|
|
72
|
+
filter: (req) => {
|
|
73
|
+
var _resolveConfig_bff;
|
|
74
|
+
const bffPrefix = ((_resolveConfig_bff = resolveConfig.bff) === null || _resolveConfig_bff === void 0 ? void 0 : _resolveConfig_bff.prefix) || import_utils.DEFAULT_API_PREFIX;
|
|
75
|
+
const url = req.url;
|
|
76
|
+
if (url === null || url === void 0 ? void 0 : url.startsWith(bffPrefix)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
64
83
|
}
|
|
65
84
|
};
|
|
66
85
|
modifyOutputConfig(config, appContext);
|
|
@@ -40,7 +40,21 @@ async function generateBuilder(options, bundlerType) {
|
|
|
40
40
|
const { normalizedConfig, appContext } = options;
|
|
41
41
|
const tempBuilderConfig = (0, import_createBuilderProviderConfig.createBuilderProviderConfig)(normalizedConfig, appContext);
|
|
42
42
|
const { environments, builderConfig } = (0, import_getBuilderEnvironments.getBuilderEnvironments)(normalizedConfig, appContext, tempBuilderConfig);
|
|
43
|
-
|
|
43
|
+
if (builderConfig.environments) {
|
|
44
|
+
const mergedEnvironments = {
|
|
45
|
+
...environments
|
|
46
|
+
};
|
|
47
|
+
for (const name in builderConfig.environments) {
|
|
48
|
+
if (environments[name]) {
|
|
49
|
+
mergedEnvironments[name] = (0, import_core.mergeRsbuildConfig)(environments[name], builderConfig.environments[name]);
|
|
50
|
+
} else {
|
|
51
|
+
mergedEnvironments[name] = builderConfig.environments[name];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
builderConfig.environments = mergedEnvironments;
|
|
55
|
+
} else {
|
|
56
|
+
builderConfig.environments = environments;
|
|
57
|
+
}
|
|
44
58
|
const builder = await (0, import_uni_builder.createUniBuilder)({
|
|
45
59
|
cwd: appContext.appDirectory,
|
|
46
60
|
rscClientRuntimePath: `@${appContext.metaName}/runtime/rsc/client`,
|
|
@@ -213,16 +213,6 @@ class RouterPlugin {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
compilation[ROUTE_DEPS_COMPILATION_KEY] = route2Sources;
|
|
216
|
-
const ROUTE_SOURCE_MANIFEST_FILE = "routes-source-manifest.json";
|
|
217
|
-
const routeSourceManifest = {
|
|
218
|
-
route2Sources
|
|
219
|
-
};
|
|
220
|
-
const existed = compilation.getAsset(ROUTE_SOURCE_MANIFEST_FILE);
|
|
221
|
-
if (existed) {
|
|
222
|
-
compilation.updateAsset(ROUTE_SOURCE_MANIFEST_FILE, new RawSource(JSON.stringify(routeSourceManifest, null, 2)), void 0);
|
|
223
|
-
} else {
|
|
224
|
-
compilation.emitAsset(ROUTE_SOURCE_MANIFEST_FILE, new RawSource(JSON.stringify(routeSourceManifest, null, 2)));
|
|
225
|
-
}
|
|
226
216
|
} catch {
|
|
227
217
|
}
|
|
228
218
|
const entryNames = Array.from(compilation.entrypoints.keys());
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
2
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
|
+
import { DEFAULT_API_PREFIX } from "@modern-js/utils";
|
|
4
5
|
import { createUploadPattern } from "./createCopyPattern";
|
|
5
6
|
function modifyOutputConfig(config, appContext) {
|
|
6
7
|
var defaultCopyPattern = createUploadPattern(appContext, config);
|
|
@@ -14,6 +15,7 @@ function modifyOutputConfig(config, appContext) {
|
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
18
|
+
var _resolveConfig_tools;
|
|
17
19
|
var htmlConfig = _object_spread({}, resolveConfig.html);
|
|
18
20
|
if (!htmlConfig.template) {
|
|
19
21
|
htmlConfig.templateByEntries = _object_spread({}, appContext.htmlTemplates, htmlConfig.templateByEntries);
|
|
@@ -29,6 +31,21 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
29
31
|
output: _object_spread_props(_object_spread({}, resolveConfig.output), {
|
|
30
32
|
// We need to do this in the app-tools prepare hook because some files will be generated into the dist directory in the analyze process
|
|
31
33
|
cleanDistPath: false
|
|
34
|
+
}),
|
|
35
|
+
tools: _object_spread_props(_object_spread({}, resolveConfig.tools), {
|
|
36
|
+
devServer: _object_spread_props(_object_spread({}, (_resolveConfig_tools = resolveConfig.tools) === null || _resolveConfig_tools === void 0 ? void 0 : _resolveConfig_tools.devServer), {
|
|
37
|
+
compress: {
|
|
38
|
+
filter: function(req) {
|
|
39
|
+
var _resolveConfig_bff;
|
|
40
|
+
var bffPrefix = ((_resolveConfig_bff = resolveConfig.bff) === null || _resolveConfig_bff === void 0 ? void 0 : _resolveConfig_bff.prefix) || DEFAULT_API_PREFIX;
|
|
41
|
+
var url = req.url;
|
|
42
|
+
if (url === null || url === void 0 ? void 0 : url.startsWith(bffPrefix)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
})
|
|
32
49
|
})
|
|
33
50
|
});
|
|
34
51
|
modifyOutputConfig(config, appContext);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
4
|
import { createUniBuilder } from "@modern-js/uni-builder";
|
|
4
5
|
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
@@ -10,14 +11,26 @@ function generateBuilder(options, bundlerType) {
|
|
|
10
11
|
}
|
|
11
12
|
function _generateBuilder() {
|
|
12
13
|
_generateBuilder = _async_to_generator(function(options, bundlerType) {
|
|
13
|
-
var normalizedConfig, appContext, tempBuilderConfig, _getBuilderEnvironments, environments, builderConfig, builder;
|
|
14
|
+
var normalizedConfig, appContext, tempBuilderConfig, _getBuilderEnvironments, environments, builderConfig, mergedEnvironments, name, builder;
|
|
14
15
|
return _ts_generator(this, function(_state) {
|
|
15
16
|
switch (_state.label) {
|
|
16
17
|
case 0:
|
|
17
18
|
normalizedConfig = options.normalizedConfig, appContext = options.appContext;
|
|
18
19
|
tempBuilderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
|
|
19
20
|
_getBuilderEnvironments = getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig), environments = _getBuilderEnvironments.environments, builderConfig = _getBuilderEnvironments.builderConfig;
|
|
20
|
-
|
|
21
|
+
if (builderConfig.environments) {
|
|
22
|
+
mergedEnvironments = _object_spread({}, environments);
|
|
23
|
+
for (var name2 in builderConfig.environments) {
|
|
24
|
+
if (environments[name2]) {
|
|
25
|
+
mergedEnvironments[name2] = mergeRsbuildConfig(environments[name2], builderConfig.environments[name2]);
|
|
26
|
+
} else {
|
|
27
|
+
mergedEnvironments[name2] = builderConfig.environments[name2];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
builderConfig.environments = mergedEnvironments;
|
|
31
|
+
} else {
|
|
32
|
+
builderConfig.environments = environments;
|
|
33
|
+
}
|
|
21
34
|
return [
|
|
22
35
|
4,
|
|
23
36
|
createUniBuilder({
|
|
@@ -87,7 +87,7 @@ var RouterPlugin = /* @__PURE__ */ function() {
|
|
|
87
87
|
name: PLUGIN_NAME,
|
|
88
88
|
stage: Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
89
89
|
}, /* @__PURE__ */ _async_to_generator(function() {
|
|
90
|
-
var _loop, stats, publicPath, _stats_chunks, chunks, namedChunkGroups, routeAssets, route2Sources, prevManifestAsset, prevManifestStr, prevManifest, asyncEntryNames, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, assets, referenceCssAssets, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, asyncEntryName, syncEntryName, syncEntry, asyncEntry, manifest, getChunkModules, addModuleResources, depsByName, namedGroups, groupNames, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _loop1, _iterator2, _step2,
|
|
90
|
+
var _loop, stats, publicPath, _stats_chunks, chunks, namedChunkGroups, routeAssets, route2Sources, prevManifestAsset, prevManifestStr, prevManifest, asyncEntryNames, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, assets, referenceCssAssets, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, asyncEntryName, syncEntryName, syncEntry, asyncEntry, manifest, getChunkModules, addModuleResources, depsByName, namedGroups, groupNames, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _loop1, _iterator2, _step2, entryNames, entryChunks, orignalEntryIds, entryChunkFiles, entryChunkFileIds, i;
|
|
91
91
|
return _ts_generator(this, function(_state) {
|
|
92
92
|
_loop = function(i2) {
|
|
93
93
|
var entryName = entryNames[i2];
|
|
@@ -371,16 +371,6 @@ var RouterPlugin = /* @__PURE__ */ function() {
|
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
compilation[ROUTE_DEPS_COMPILATION_KEY] = route2Sources;
|
|
374
|
-
ROUTE_SOURCE_MANIFEST_FILE = "routes-source-manifest.json";
|
|
375
|
-
routeSourceManifest = {
|
|
376
|
-
route2Sources
|
|
377
|
-
};
|
|
378
|
-
existed = compilation.getAsset(ROUTE_SOURCE_MANIFEST_FILE);
|
|
379
|
-
if (existed) {
|
|
380
|
-
compilation.updateAsset(ROUTE_SOURCE_MANIFEST_FILE, new RawSource(JSON.stringify(routeSourceManifest, null, 2)), void 0);
|
|
381
|
-
} else {
|
|
382
|
-
compilation.emitAsset(ROUTE_SOURCE_MANIFEST_FILE, new RawSource(JSON.stringify(routeSourceManifest, null, 2)));
|
|
383
|
-
}
|
|
384
374
|
} catch (e) {
|
|
385
375
|
}
|
|
386
376
|
entryNames = Array.from(compilation.entrypoints.keys());
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_API_PREFIX } from "@modern-js/utils";
|
|
1
2
|
import { createUploadPattern } from "./createCopyPattern";
|
|
2
3
|
function modifyOutputConfig(config, appContext) {
|
|
3
4
|
const defaultCopyPattern = createUploadPattern(appContext, config);
|
|
@@ -13,6 +14,7 @@ function modifyOutputConfig(config, appContext) {
|
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
17
|
+
var _resolveConfig_tools;
|
|
16
18
|
const htmlConfig = {
|
|
17
19
|
...resolveConfig.html
|
|
18
20
|
};
|
|
@@ -38,6 +40,23 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
38
40
|
...resolveConfig.output,
|
|
39
41
|
// We need to do this in the app-tools prepare hook because some files will be generated into the dist directory in the analyze process
|
|
40
42
|
cleanDistPath: false
|
|
43
|
+
},
|
|
44
|
+
tools: {
|
|
45
|
+
...resolveConfig.tools,
|
|
46
|
+
devServer: {
|
|
47
|
+
...(_resolveConfig_tools = resolveConfig.tools) === null || _resolveConfig_tools === void 0 ? void 0 : _resolveConfig_tools.devServer,
|
|
48
|
+
compress: {
|
|
49
|
+
filter: (req) => {
|
|
50
|
+
var _resolveConfig_bff;
|
|
51
|
+
const bffPrefix = ((_resolveConfig_bff = resolveConfig.bff) === null || _resolveConfig_bff === void 0 ? void 0 : _resolveConfig_bff.prefix) || DEFAULT_API_PREFIX;
|
|
52
|
+
const url = req.url;
|
|
53
|
+
if (url === null || url === void 0 ? void 0 : url.startsWith(bffPrefix)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
41
60
|
}
|
|
42
61
|
};
|
|
43
62
|
modifyOutputConfig(config, appContext);
|
|
@@ -7,7 +7,21 @@ async function generateBuilder(options, bundlerType) {
|
|
|
7
7
|
const { normalizedConfig, appContext } = options;
|
|
8
8
|
const tempBuilderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
|
|
9
9
|
const { environments, builderConfig } = getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig);
|
|
10
|
-
|
|
10
|
+
if (builderConfig.environments) {
|
|
11
|
+
const mergedEnvironments = {
|
|
12
|
+
...environments
|
|
13
|
+
};
|
|
14
|
+
for (const name in builderConfig.environments) {
|
|
15
|
+
if (environments[name]) {
|
|
16
|
+
mergedEnvironments[name] = mergeRsbuildConfig(environments[name], builderConfig.environments[name]);
|
|
17
|
+
} else {
|
|
18
|
+
mergedEnvironments[name] = builderConfig.environments[name];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
builderConfig.environments = mergedEnvironments;
|
|
22
|
+
} else {
|
|
23
|
+
builderConfig.environments = environments;
|
|
24
|
+
}
|
|
11
25
|
const builder = await createUniBuilder({
|
|
12
26
|
cwd: appContext.appDirectory,
|
|
13
27
|
rscClientRuntimePath: `@${appContext.metaName}/runtime/rsc/client`,
|
|
@@ -189,16 +189,6 @@ class RouterPlugin {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
compilation[ROUTE_DEPS_COMPILATION_KEY] = route2Sources;
|
|
192
|
-
const ROUTE_SOURCE_MANIFEST_FILE = "routes-source-manifest.json";
|
|
193
|
-
const routeSourceManifest = {
|
|
194
|
-
route2Sources
|
|
195
|
-
};
|
|
196
|
-
const existed = compilation.getAsset(ROUTE_SOURCE_MANIFEST_FILE);
|
|
197
|
-
if (existed) {
|
|
198
|
-
compilation.updateAsset(ROUTE_SOURCE_MANIFEST_FILE, new RawSource(JSON.stringify(routeSourceManifest, null, 2)), void 0);
|
|
199
|
-
} else {
|
|
200
|
-
compilation.emitAsset(ROUTE_SOURCE_MANIFEST_FILE, new RawSource(JSON.stringify(routeSourceManifest, null, 2)));
|
|
201
|
-
}
|
|
202
192
|
} catch {
|
|
203
193
|
}
|
|
204
194
|
const entryNames = Array.from(compilation.entrypoints.keys());
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.68.
|
|
18
|
+
"version": "2.68.19",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@babel/parser": "^7.22.15",
|
|
86
86
|
"@babel/traverse": "^7.23.2",
|
|
87
87
|
"@babel/types": "^7.26.0",
|
|
88
|
-
"@rsbuild/core": "1.
|
|
88
|
+
"@rsbuild/core": "1.6.1",
|
|
89
89
|
"@rsbuild/plugin-node-polyfill": "1.4.2",
|
|
90
90
|
"@swc/helpers": "^0.5.17",
|
|
91
91
|
"es-module-lexer": "^1.1.0",
|
|
@@ -96,20 +96,20 @@
|
|
|
96
96
|
"ndepe": "^0.1.12",
|
|
97
97
|
"pkg-types": "^1.3.1",
|
|
98
98
|
"std-env": "^3.7.0",
|
|
99
|
-
"@modern-js/core": "2.68.
|
|
100
|
-
"@modern-js/node-bundle-require": "2.68.
|
|
101
|
-
"@modern-js/plugin": "2.68.
|
|
102
|
-
"@modern-js/plugin-data-loader": "2.68.
|
|
103
|
-
"@modern-js/plugin-i18n": "2.68.
|
|
104
|
-
"@modern-js/plugin-
|
|
105
|
-
"@modern-js/
|
|
106
|
-
"@modern-js/
|
|
107
|
-
"@modern-js/server": "2.68.
|
|
108
|
-
"@modern-js/server-core": "2.68.
|
|
109
|
-
"@modern-js/server-utils": "2.68.
|
|
110
|
-
"@modern-js/types": "2.68.
|
|
111
|
-
"@modern-js/uni-builder": "2.68.
|
|
112
|
-
"@modern-js/utils": "2.68.
|
|
99
|
+
"@modern-js/core": "2.68.19",
|
|
100
|
+
"@modern-js/node-bundle-require": "2.68.19",
|
|
101
|
+
"@modern-js/plugin": "2.68.19",
|
|
102
|
+
"@modern-js/plugin-data-loader": "2.68.19",
|
|
103
|
+
"@modern-js/plugin-i18n": "2.68.19",
|
|
104
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.68.19",
|
|
105
|
+
"@modern-js/plugin-v2": "2.68.19",
|
|
106
|
+
"@modern-js/server": "2.68.19",
|
|
107
|
+
"@modern-js/prod-server": "2.68.19",
|
|
108
|
+
"@modern-js/server-core": "2.68.19",
|
|
109
|
+
"@modern-js/server-utils": "2.68.19",
|
|
110
|
+
"@modern-js/types": "2.68.19",
|
|
111
|
+
"@modern-js/uni-builder": "2.68.19",
|
|
112
|
+
"@modern-js/utils": "2.68.19"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@rsbuild/plugin-webpack-swc": "1.1.2",
|