@bleedingdev/modern-js-builder 3.5.0-ultramodern.6 → 3.5.0-ultramodern.8
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 +2 -0
- package/dist/esm/plugins/environmentBuildCache.mjs +38 -0
- package/dist/esm/shared/parseCommonConfig.mjs +2 -0
- package/dist/esm-node/plugins/environmentBuildCache.mjs +39 -0
- package/dist/esm-node/shared/parseCommonConfig.mjs +2 -0
- 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");
|
|
@@ -141,6 +142,7 @@ async function parseCommonConfig(builderConfig, options) {
|
|
|
141
142
|
(0, rspack21_js_namespaceObject.pluginRspack21)({
|
|
142
143
|
sourceImport
|
|
143
144
|
}),
|
|
145
|
+
(0, environmentBuildCache_js_namespaceObject.pluginEnvironmentBuildCacheIsolation)(),
|
|
144
146
|
(0, globalVars_js_namespaceObject.pluginGlobalVars)(globalVars),
|
|
145
147
|
(0, devtools_js_namespaceObject.pluginDevtool)({
|
|
146
148
|
sourceMap
|
|
@@ -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";
|
|
@@ -108,6 +109,7 @@ async function parseCommonConfig(builderConfig, options) {
|
|
|
108
109
|
pluginRspack21({
|
|
109
110
|
sourceImport
|
|
110
111
|
}),
|
|
112
|
+
pluginEnvironmentBuildCacheIsolation(),
|
|
111
113
|
pluginGlobalVars(globalVars),
|
|
112
114
|
pluginDevtool({
|
|
113
115
|
sourceMap
|
|
@@ -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";
|
|
@@ -109,6 +110,7 @@ async function parseCommonConfig(builderConfig, options) {
|
|
|
109
110
|
pluginRspack21({
|
|
110
111
|
sourceImport
|
|
111
112
|
}),
|
|
113
|
+
pluginEnvironmentBuildCacheIsolation(),
|
|
112
114
|
pluginGlobalVars(globalVars),
|
|
113
115
|
pluginDevtool({
|
|
114
116
|
sourceMap
|
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.8",
|
|
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.8"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@rslib/core": "0.23.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"terser": "^5.48.0",
|
|
70
70
|
"typescript": "^6.0.3",
|
|
71
71
|
"@scripts/rstest-config": "2.66.0",
|
|
72
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.
|
|
72
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.8"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public",
|