@bleedingdev/modern-js-builder 3.5.0-ultramodern.3 → 3.5.0-ultramodern.30
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/plugins/environmentBuildCache.js +89 -0
- package/dist/cjs/shared/parseCommonConfig.js +14 -1
- package/dist/esm/plugins/environmentBuildCache.mjs +38 -0
- package/dist/esm/shared/parseCommonConfig.mjs +14 -1
- package/dist/esm-node/plugins/environmentBuildCache.mjs +39 -0
- package/dist/esm-node/shared/parseCommonConfig.mjs +14 -1
- package/dist/types/plugins/environmentBuildCache.d.ts +3 -0
- package/package.json +3 -3
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
isolateEnvironmentBuildCacheDirectory: ()=>isolateEnvironmentBuildCacheDirectory,
|
|
41
|
+
pluginEnvironmentBuildCacheIsolation: ()=>pluginEnvironmentBuildCacheIsolation
|
|
42
|
+
});
|
|
43
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
44
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
45
|
+
const DEFAULT_RSPACK_CACHE_DIRECTORY = 'node_modules/.cache/rspack';
|
|
46
|
+
function sanitizeCachePathSegment(value) {
|
|
47
|
+
return value.replace(/[^a-zA-Z0-9._-]+/gu, '_');
|
|
48
|
+
}
|
|
49
|
+
function pathEndsWithSegment(filePath, segment) {
|
|
50
|
+
const normalized = filePath.replace(/[\\/]+$/u, '');
|
|
51
|
+
return normalized.split(/[\\/]+/u).at(-1) === segment;
|
|
52
|
+
}
|
|
53
|
+
function isolateEnvironmentBuildCacheDirectory(cacheDirectory, environmentName) {
|
|
54
|
+
const segment = sanitizeCachePathSegment(environmentName);
|
|
55
|
+
const baseDirectory = cacheDirectory || DEFAULT_RSPACK_CACHE_DIRECTORY;
|
|
56
|
+
return pathEndsWithSegment(baseDirectory, segment) ? baseDirectory : external_node_path_default().join(baseDirectory, segment);
|
|
57
|
+
}
|
|
58
|
+
const pluginEnvironmentBuildCacheIsolation = ()=>({
|
|
59
|
+
name: 'modern-js:environment-build-cache-isolation',
|
|
60
|
+
setup (api) {
|
|
61
|
+
api.modifyEnvironmentConfig({
|
|
62
|
+
order: 'post',
|
|
63
|
+
handler: (config, { name })=>{
|
|
64
|
+
const buildCache = config.performance.buildCache;
|
|
65
|
+
if (false === buildCache || void 0 === buildCache) return;
|
|
66
|
+
const buildCacheConfig = true === buildCache ? {} : buildCache;
|
|
67
|
+
return {
|
|
68
|
+
...config,
|
|
69
|
+
performance: {
|
|
70
|
+
...config.performance,
|
|
71
|
+
buildCache: {
|
|
72
|
+
...buildCacheConfig,
|
|
73
|
+
cacheDirectory: isolateEnvironmentBuildCacheDirectory(buildCacheConfig.cacheDirectory, name)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
exports.isolateEnvironmentBuildCacheDirectory = __webpack_exports__.isolateEnvironmentBuildCacheDirectory;
|
|
82
|
+
exports.pluginEnvironmentBuildCacheIsolation = __webpack_exports__.pluginEnvironmentBuildCacheIsolation;
|
|
83
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
84
|
+
"isolateEnvironmentBuildCacheDirectory",
|
|
85
|
+
"pluginEnvironmentBuildCacheIsolation"
|
|
86
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
87
|
+
Object.defineProperty(exports, '__esModule', {
|
|
88
|
+
value: true
|
|
89
|
+
});
|
|
@@ -38,6 +38,7 @@ const plugin_react_namespaceObject = require("@rsbuild/plugin-react");
|
|
|
38
38
|
const plugin_sass_namespaceObject = require("@rsbuild/plugin-sass");
|
|
39
39
|
const devtools_js_namespaceObject = require("../plugins/devtools.js");
|
|
40
40
|
const emitRouteFile_js_namespaceObject = require("../plugins/emitRouteFile.js");
|
|
41
|
+
const environmentBuildCache_js_namespaceObject = require("../plugins/environmentBuildCache.js");
|
|
41
42
|
const environmentDefaults_js_namespaceObject = require("../plugins/environmentDefaults.js");
|
|
42
43
|
const globalVars_js_namespaceObject = require("../plugins/globalVars.js");
|
|
43
44
|
const htmlMinify_js_namespaceObject = require("../plugins/htmlMinify.js");
|
|
@@ -48,6 +49,17 @@ const external_tsgo_js_namespaceObject = require("./tsgo.js");
|
|
|
48
49
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
49
50
|
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
50
51
|
const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
|
|
52
|
+
const DEFAULT_CSS_MINIFIER_OPTIONS = {
|
|
53
|
+
minimizerOptions: {
|
|
54
|
+
preset: [
|
|
55
|
+
'default',
|
|
56
|
+
{
|
|
57
|
+
calc: false,
|
|
58
|
+
mergeLonghand: false
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
};
|
|
51
63
|
const isLooseCssModules = (path)=>{
|
|
52
64
|
if (external_utils_js_namespaceObject.NODE_MODULES_REGEX.test(path)) return CSS_MODULES_REGEX.test(path);
|
|
53
65
|
return !GLOBAL_CSS_REGEX.test(path);
|
|
@@ -141,6 +153,7 @@ async function parseCommonConfig(builderConfig, options) {
|
|
|
141
153
|
(0, rspack21_js_namespaceObject.pluginRspack21)({
|
|
142
154
|
sourceImport
|
|
143
155
|
}),
|
|
156
|
+
(0, environmentBuildCache_js_namespaceObject.pluginEnvironmentBuildCacheIsolation)(),
|
|
144
157
|
(0, globalVars_js_namespaceObject.pluginGlobalVars)(globalVars),
|
|
145
158
|
(0, devtools_js_namespaceObject.pluginDevtool)({
|
|
146
159
|
sourceMap
|
|
@@ -206,7 +219,7 @@ async function parseCommonConfig(builderConfig, options) {
|
|
|
206
219
|
};
|
|
207
220
|
}
|
|
208
221
|
rsbuildPlugins.push((0, plugin_css_minimizer_namespaceObject.pluginCssMinimizer)({
|
|
209
|
-
pluginOptions: minifyCss
|
|
222
|
+
pluginOptions: minifyCss ?? DEFAULT_CSS_MINIFIER_OPTIONS
|
|
210
223
|
}));
|
|
211
224
|
if (enableAssetManifest) {
|
|
212
225
|
const { pluginManifest } = await import("../plugins/manifest.js");
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import node_path from "node:path";
|
|
2
|
+
const DEFAULT_RSPACK_CACHE_DIRECTORY = 'node_modules/.cache/rspack';
|
|
3
|
+
function sanitizeCachePathSegment(value) {
|
|
4
|
+
return value.replace(/[^a-zA-Z0-9._-]+/gu, '_');
|
|
5
|
+
}
|
|
6
|
+
function pathEndsWithSegment(filePath, segment) {
|
|
7
|
+
const normalized = filePath.replace(/[\\/]+$/u, '');
|
|
8
|
+
return normalized.split(/[\\/]+/u).at(-1) === segment;
|
|
9
|
+
}
|
|
10
|
+
function isolateEnvironmentBuildCacheDirectory(cacheDirectory, environmentName) {
|
|
11
|
+
const segment = sanitizeCachePathSegment(environmentName);
|
|
12
|
+
const baseDirectory = cacheDirectory || DEFAULT_RSPACK_CACHE_DIRECTORY;
|
|
13
|
+
return pathEndsWithSegment(baseDirectory, segment) ? baseDirectory : node_path.join(baseDirectory, segment);
|
|
14
|
+
}
|
|
15
|
+
const pluginEnvironmentBuildCacheIsolation = ()=>({
|
|
16
|
+
name: 'modern-js:environment-build-cache-isolation',
|
|
17
|
+
setup (api) {
|
|
18
|
+
api.modifyEnvironmentConfig({
|
|
19
|
+
order: 'post',
|
|
20
|
+
handler: (config, { name })=>{
|
|
21
|
+
const buildCache = config.performance.buildCache;
|
|
22
|
+
if (false === buildCache || void 0 === buildCache) return;
|
|
23
|
+
const buildCacheConfig = true === buildCache ? {} : buildCache;
|
|
24
|
+
return {
|
|
25
|
+
...config,
|
|
26
|
+
performance: {
|
|
27
|
+
...config.performance,
|
|
28
|
+
buildCache: {
|
|
29
|
+
...buildCacheConfig,
|
|
30
|
+
cacheDirectory: isolateEnvironmentBuildCacheDirectory(buildCacheConfig.cacheDirectory, name)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export { isolateEnvironmentBuildCacheDirectory, pluginEnvironmentBuildCacheIsolation };
|
|
@@ -5,6 +5,7 @@ import { pluginReact } from "@rsbuild/plugin-react";
|
|
|
5
5
|
import { pluginSass } from "@rsbuild/plugin-sass";
|
|
6
6
|
import { pluginDevtool } from "../plugins/devtools.mjs";
|
|
7
7
|
import { pluginEmitRouteFile } from "../plugins/emitRouteFile.mjs";
|
|
8
|
+
import { pluginEnvironmentBuildCacheIsolation } from "../plugins/environmentBuildCache.mjs";
|
|
8
9
|
import { pluginEnvironmentDefaults } from "../plugins/environmentDefaults.mjs";
|
|
9
10
|
import { pluginGlobalVars } from "../plugins/globalVars.mjs";
|
|
10
11
|
import { pluginHtmlMinifierTerser } from "../plugins/htmlMinify.mjs";
|
|
@@ -15,6 +16,17 @@ import { withTsgoDefaults } from "./tsgo.mjs";
|
|
|
15
16
|
import { NODE_MODULES_REGEX } from "./utils.mjs";
|
|
16
17
|
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
17
18
|
const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
|
|
19
|
+
const DEFAULT_CSS_MINIFIER_OPTIONS = {
|
|
20
|
+
minimizerOptions: {
|
|
21
|
+
preset: [
|
|
22
|
+
'default',
|
|
23
|
+
{
|
|
24
|
+
calc: false,
|
|
25
|
+
mergeLonghand: false
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
};
|
|
18
30
|
const isLooseCssModules = (path)=>{
|
|
19
31
|
if (NODE_MODULES_REGEX.test(path)) return CSS_MODULES_REGEX.test(path);
|
|
20
32
|
return !GLOBAL_CSS_REGEX.test(path);
|
|
@@ -108,6 +120,7 @@ async function parseCommonConfig(builderConfig, options) {
|
|
|
108
120
|
pluginRspack21({
|
|
109
121
|
sourceImport
|
|
110
122
|
}),
|
|
123
|
+
pluginEnvironmentBuildCacheIsolation(),
|
|
111
124
|
pluginGlobalVars(globalVars),
|
|
112
125
|
pluginDevtool({
|
|
113
126
|
sourceMap
|
|
@@ -173,7 +186,7 @@ async function parseCommonConfig(builderConfig, options) {
|
|
|
173
186
|
};
|
|
174
187
|
}
|
|
175
188
|
rsbuildPlugins.push(pluginCssMinimizer({
|
|
176
|
-
pluginOptions: minifyCss
|
|
189
|
+
pluginOptions: minifyCss ?? DEFAULT_CSS_MINIFIER_OPTIONS
|
|
177
190
|
}));
|
|
178
191
|
if (enableAssetManifest) {
|
|
179
192
|
const { pluginManifest } = await import("../plugins/manifest.mjs");
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
const DEFAULT_RSPACK_CACHE_DIRECTORY = 'node_modules/.cache/rspack';
|
|
4
|
+
function sanitizeCachePathSegment(value) {
|
|
5
|
+
return value.replace(/[^a-zA-Z0-9._-]+/gu, '_');
|
|
6
|
+
}
|
|
7
|
+
function pathEndsWithSegment(filePath, segment) {
|
|
8
|
+
const normalized = filePath.replace(/[\\/]+$/u, '');
|
|
9
|
+
return normalized.split(/[\\/]+/u).at(-1) === segment;
|
|
10
|
+
}
|
|
11
|
+
function isolateEnvironmentBuildCacheDirectory(cacheDirectory, environmentName) {
|
|
12
|
+
const segment = sanitizeCachePathSegment(environmentName);
|
|
13
|
+
const baseDirectory = cacheDirectory || DEFAULT_RSPACK_CACHE_DIRECTORY;
|
|
14
|
+
return pathEndsWithSegment(baseDirectory, segment) ? baseDirectory : node_path.join(baseDirectory, segment);
|
|
15
|
+
}
|
|
16
|
+
const pluginEnvironmentBuildCacheIsolation = ()=>({
|
|
17
|
+
name: 'modern-js:environment-build-cache-isolation',
|
|
18
|
+
setup (api) {
|
|
19
|
+
api.modifyEnvironmentConfig({
|
|
20
|
+
order: 'post',
|
|
21
|
+
handler: (config, { name })=>{
|
|
22
|
+
const buildCache = config.performance.buildCache;
|
|
23
|
+
if (false === buildCache || void 0 === buildCache) return;
|
|
24
|
+
const buildCacheConfig = true === buildCache ? {} : buildCache;
|
|
25
|
+
return {
|
|
26
|
+
...config,
|
|
27
|
+
performance: {
|
|
28
|
+
...config.performance,
|
|
29
|
+
buildCache: {
|
|
30
|
+
...buildCacheConfig,
|
|
31
|
+
cacheDirectory: isolateEnvironmentBuildCacheDirectory(buildCacheConfig.cacheDirectory, name)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export { isolateEnvironmentBuildCacheDirectory, pluginEnvironmentBuildCacheIsolation };
|
|
@@ -6,6 +6,7 @@ import { pluginReact } from "@rsbuild/plugin-react";
|
|
|
6
6
|
import { pluginSass } from "@rsbuild/plugin-sass";
|
|
7
7
|
import { pluginDevtool } from "../plugins/devtools.mjs";
|
|
8
8
|
import { pluginEmitRouteFile } from "../plugins/emitRouteFile.mjs";
|
|
9
|
+
import { pluginEnvironmentBuildCacheIsolation } from "../plugins/environmentBuildCache.mjs";
|
|
9
10
|
import { pluginEnvironmentDefaults } from "../plugins/environmentDefaults.mjs";
|
|
10
11
|
import { pluginGlobalVars } from "../plugins/globalVars.mjs";
|
|
11
12
|
import { pluginHtmlMinifierTerser } from "../plugins/htmlMinify.mjs";
|
|
@@ -16,6 +17,17 @@ import { withTsgoDefaults } from "./tsgo.mjs";
|
|
|
16
17
|
import { NODE_MODULES_REGEX } from "./utils.mjs";
|
|
17
18
|
const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
|
|
18
19
|
const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
|
|
20
|
+
const DEFAULT_CSS_MINIFIER_OPTIONS = {
|
|
21
|
+
minimizerOptions: {
|
|
22
|
+
preset: [
|
|
23
|
+
'default',
|
|
24
|
+
{
|
|
25
|
+
calc: false,
|
|
26
|
+
mergeLonghand: false
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
};
|
|
19
31
|
const isLooseCssModules = (path)=>{
|
|
20
32
|
if (NODE_MODULES_REGEX.test(path)) return CSS_MODULES_REGEX.test(path);
|
|
21
33
|
return !GLOBAL_CSS_REGEX.test(path);
|
|
@@ -109,6 +121,7 @@ async function parseCommonConfig(builderConfig, options) {
|
|
|
109
121
|
pluginRspack21({
|
|
110
122
|
sourceImport
|
|
111
123
|
}),
|
|
124
|
+
pluginEnvironmentBuildCacheIsolation(),
|
|
112
125
|
pluginGlobalVars(globalVars),
|
|
113
126
|
pluginDevtool({
|
|
114
127
|
sourceMap
|
|
@@ -174,7 +187,7 @@ async function parseCommonConfig(builderConfig, options) {
|
|
|
174
187
|
};
|
|
175
188
|
}
|
|
176
189
|
rsbuildPlugins.push(pluginCssMinimizer({
|
|
177
|
-
pluginOptions: minifyCss
|
|
190
|
+
pluginOptions: minifyCss ?? DEFAULT_CSS_MINIFIER_OPTIONS
|
|
178
191
|
}));
|
|
179
192
|
if (enableAssetManifest) {
|
|
180
193
|
const { pluginManifest } = await import("../plugins/manifest.mjs");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bleedingdev/modern-js-builder",
|
|
3
|
-
"version": "3.5.0-ultramodern.
|
|
3
|
+
"version": "3.5.0-ultramodern.30",
|
|
4
4
|
"description": "A builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"rsbuild-plugin-rsc": "0.1.1",
|
|
60
60
|
"rspack-manifest-plugin": "5.2.2",
|
|
61
61
|
"ts-deepmerge": "8.0.0",
|
|
62
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.
|
|
62
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.30"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@rslib/core": "0.23.1",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"react": "^19.2.7",
|
|
69
69
|
"terser": "^5.48.0",
|
|
70
70
|
"typescript": "^6.0.3",
|
|
71
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.
|
|
71
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.30",
|
|
72
72
|
"@scripts/rstest-config": "2.66.0"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|