@rspack/core 1.0.0-alpha.3 → 1.0.0-alpha.5
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/compiled/browserslist/index.js +17 -17
- package/compiled/enhanced-resolve/index.js +107 -107
- package/compiled/graceful-fs/index.js +8 -8
- package/compiled/json-parse-even-better-errors/index.js +2 -2
- package/compiled/neo-async/index.js +2 -2
- package/compiled/watchpack/index.js +15 -15
- package/compiled/webpack-sources/index.js +76 -76
- package/compiled/zod/index.js +30 -30
- package/compiled/zod-validation-error/index.js +6 -6
- package/dist/Compilation.js +2 -3
- package/dist/ErrorHelpers.d.ts +16 -7
- package/dist/ErrorHelpers.js +34 -33
- package/dist/ExecuteModulePlugin.js +1 -1
- package/dist/FileSystem.js +6 -6
- package/dist/Module.d.ts +1 -2
- package/dist/Module.js +2 -6
- package/dist/MultiCompiler.js +1 -1
- package/dist/NormalModule.js +6 -6
- package/dist/ResolverFactory.d.ts +5 -1
- package/dist/ResolverFactory.js +7 -1
- package/dist/RuntimeGlobals.js +3 -3
- package/dist/Stats.js +4 -4
- package/dist/Template.js +2 -2
- package/dist/Watching.js +2 -2
- package/dist/builtin-plugin/DefinePlugin.js +2 -2
- package/dist/builtin-plugin/EntryPlugin.js +1 -1
- package/dist/builtin-plugin/SplitChunksPlugin.js +2 -2
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +10 -2
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +7 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +2 -2
- package/dist/builtin-plugin/WorkerPlugin.js +5 -1
- package/dist/builtin-plugin/base.js +1 -1
- package/dist/builtin-plugin/css-extract/loader.js +5 -5
- package/dist/builtin-plugin/css-extract/utils.js +3 -3
- package/dist/builtin-plugin/lazy-compilation/backend.d.ts +3 -3
- package/dist/builtin-plugin/lazy-compilation/backend.js +1 -1
- package/dist/config/adapter.d.ts +1 -1
- package/dist/config/adapter.js +27 -16
- package/dist/config/adapterRuleUse.js +1 -1
- package/dist/config/browserslistTargetHandler.js +2 -2
- package/dist/config/defaults.js +11 -10
- package/dist/config/zod.d.ts +119 -12
- package/dist/config/zod.js +43 -40
- package/dist/container/ModuleFederationPlugin.js +2 -2
- package/dist/lib/EntryOptionPlugin.js +2 -2
- package/dist/lib/WebpackError.js +1 -1
- package/dist/loader-runner/index.js +22 -22
- package/dist/loader-runner/loadLoader.js +1 -1
- package/dist/logging/runtime.js +1 -1
- package/dist/node/NodeWatchFileSystem.js +5 -5
- package/dist/node/nodeConsole.js +1 -1
- package/dist/rspack.js +6 -6
- package/dist/rspackOptionsApply.js +3 -3
- package/dist/sharing/ConsumeSharedPlugin.js +1 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +285 -50
- package/dist/stats/DefaultStatsPresetPlugin.js +17 -17
- package/dist/stats/DefaultStatsPrinterPlugin.js +2 -2
- package/dist/stats/statsFactoryUtils.d.ts +24 -10
- package/dist/util/bindingVersionCheck.js +6 -6
- package/dist/util/createHash.js +2 -2
- package/dist/util/fs.js +11 -11
- package/dist/util/identifier.d.ts +65 -62
- package/dist/util/identifier.js +30 -55
- package/package.json +6 -3
package/dist/util/createHash.js
CHANGED
|
@@ -159,11 +159,11 @@ const createHash = algorithm => {
|
|
|
159
159
|
return new BatchedHash(createMd4());
|
|
160
160
|
case "native-md4":
|
|
161
161
|
if (crypto === undefined)
|
|
162
|
-
crypto = require("crypto");
|
|
162
|
+
crypto = require("node:crypto");
|
|
163
163
|
return new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
|
|
164
164
|
default:
|
|
165
165
|
if (crypto === undefined)
|
|
166
|
-
crypto = require("crypto");
|
|
166
|
+
crypto = require("node:crypto");
|
|
167
167
|
return new BulkUpdateDecorator(() => crypto.createHash(algorithm), algorithm);
|
|
168
168
|
}
|
|
169
169
|
};
|
package/dist/util/fs.js
CHANGED
|
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.mkdirp = exports.rmrf = void 0;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
17
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
18
18
|
function rmrf(fs, p, callback) {
|
|
19
19
|
fs.stat(p, (err, stats) => {
|
|
20
20
|
if (err) {
|
|
@@ -34,7 +34,7 @@ function rmrf(fs, p, callback) {
|
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
files.forEach(file => {
|
|
37
|
-
(0,
|
|
37
|
+
(0, node_assert_1.default)(typeof file === "string");
|
|
38
38
|
const fullPath = join(fs, p, file);
|
|
39
39
|
rmrf(fs, fullPath, err => {
|
|
40
40
|
if (err) {
|
|
@@ -59,11 +59,11 @@ const join = (fs, rootPath, filename) => {
|
|
|
59
59
|
if (fs && fs.join) {
|
|
60
60
|
return fs.join(rootPath, filename);
|
|
61
61
|
}
|
|
62
|
-
else if (
|
|
63
|
-
return
|
|
62
|
+
else if (node_path_1.default.posix.isAbsolute(rootPath)) {
|
|
63
|
+
return node_path_1.default.posix.join(rootPath, filename);
|
|
64
64
|
}
|
|
65
|
-
else if (
|
|
66
|
-
return
|
|
65
|
+
else if (node_path_1.default.win32.isAbsolute(rootPath)) {
|
|
66
|
+
return node_path_1.default.win32.join(rootPath, filename);
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
69
|
throw new Error(`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`);
|
|
@@ -73,11 +73,11 @@ const dirname = (fs, absPath) => {
|
|
|
73
73
|
if (fs && fs.dirname) {
|
|
74
74
|
return fs.dirname(absPath);
|
|
75
75
|
}
|
|
76
|
-
else if (
|
|
77
|
-
return
|
|
76
|
+
else if (node_path_1.default.posix.isAbsolute(absPath)) {
|
|
77
|
+
return node_path_1.default.posix.dirname(absPath);
|
|
78
78
|
}
|
|
79
|
-
else if (
|
|
80
|
-
return
|
|
79
|
+
else if (node_path_1.default.win32.isAbsolute(absPath)) {
|
|
80
|
+
return node_path_1.default.win32.dirname(absPath);
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
83
|
throw new Error(`${absPath} is neither a posix nor a windows path, and there is no 'dirname' method defined in the file system`);
|
|
@@ -1,76 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
1
|
+
interface ParsedResource {
|
|
2
|
+
resource: string;
|
|
3
|
+
path: string;
|
|
4
|
+
query: string;
|
|
5
|
+
fragment: string;
|
|
6
|
+
}
|
|
7
|
+
type ParsedResourceWithoutFragment = Omit<ParsedResource, "fragment">;
|
|
8
|
+
export declare const makePathsRelative: {
|
|
9
|
+
(context: string, identifier: string, associatedObjectForCache: object | undefined): string;
|
|
9
10
|
/**
|
|
10
11
|
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
11
12
|
* @returns {function(string, string): string} cached function
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
|
|
14
15
|
/**
|
|
15
16
|
* @param {string} context context used to create relative path
|
|
16
17
|
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
17
18
|
* @returns {function(string): string} cached function
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @param {string} context context used to create relative path
|
|
23
|
-
* @param {string} identifier identifier used to create relative path
|
|
24
|
-
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
25
|
-
* @returns {string} the returned relative path
|
|
26
|
-
*/
|
|
27
|
-
export function makePathsAbsolute(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
|
|
28
|
-
export namespace makePathsAbsolute { }
|
|
29
|
-
/**
|
|
30
|
-
* @param {string} str the path with query and fragment
|
|
31
|
-
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
32
|
-
* @returns {ParsedResource} parsed parts
|
|
33
|
-
*/
|
|
34
|
-
export function parseResource(str: string, associatedObjectForCache?: Object | undefined): ParsedResource;
|
|
35
|
-
export namespace parseResource {
|
|
36
|
-
function bindCache(associatedObjectForCache: any): (str: any) => any;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* @param {string} str the path with query and fragment
|
|
40
|
-
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
41
|
-
* @returns {ParsedResource} parsed parts
|
|
42
|
-
*/
|
|
43
|
-
export function parseResourceWithoutFragment(str: string, associatedObjectForCache?: Object | undefined): ParsedResource;
|
|
44
|
-
export namespace parseResourceWithoutFragment { }
|
|
45
|
-
export function getUndoPath(filename: string, outputPath: string, enforceRelative: boolean): string;
|
|
46
|
-
export type MakeRelativePathsCache = {
|
|
47
|
-
relativePaths?: Map<string, Map<string, string>> | undefined;
|
|
20
|
+
bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
|
|
48
21
|
};
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
22
|
+
export declare const makePathsAbsolute: {
|
|
23
|
+
(context: string, identifier: string, associatedObjectForCache: object | undefined): string;
|
|
24
|
+
/**
|
|
25
|
+
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
26
|
+
* @returns {function(string, string): string} cached function
|
|
27
|
+
*/
|
|
28
|
+
bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} context context used to create relative path
|
|
31
|
+
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
32
|
+
* @returns {function(string): string} cached function
|
|
33
|
+
*/
|
|
34
|
+
bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
|
|
54
35
|
};
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
36
|
+
export declare const contextify: {
|
|
37
|
+
(context: string, identifier: string, associatedObjectForCache: object | undefined): string;
|
|
38
|
+
/**
|
|
39
|
+
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
40
|
+
* @returns {function(string, string): string} cached function
|
|
41
|
+
*/
|
|
42
|
+
bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* @param {string} context context used to create relative path
|
|
45
|
+
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
46
|
+
* @returns {function(string): string} cached function
|
|
47
|
+
*/
|
|
48
|
+
bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
|
|
49
|
+
};
|
|
50
|
+
export declare const absolutify: {
|
|
51
|
+
(context: string, identifier: string, associatedObjectForCache: object | undefined): string;
|
|
52
|
+
/**
|
|
53
|
+
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
54
|
+
* @returns {function(string, string): string} cached function
|
|
55
|
+
*/
|
|
56
|
+
bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} context context used to create relative path
|
|
59
|
+
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
60
|
+
* @returns {function(string): string} cached function
|
|
61
|
+
*/
|
|
62
|
+
bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
|
|
63
|
+
};
|
|
64
|
+
export declare const parseResource: {
|
|
65
|
+
(str: string, associatedObjectForCache?: object): ParsedResource;
|
|
66
|
+
bindCache(associatedObjectForCache: object): (str: string) => ParsedResource;
|
|
67
|
+
};
|
|
68
|
+
export declare const parseResourceWithoutFragment: {
|
|
69
|
+
(str: string, associatedObjectForCache?: object): ParsedResourceWithoutFragment;
|
|
70
|
+
bindCache(associatedObjectForCache: object): (str: string) => ParsedResourceWithoutFragment;
|
|
59
71
|
};
|
|
60
72
|
/**
|
|
61
|
-
* @param {string}
|
|
62
|
-
* @param {string}
|
|
63
|
-
* @param {
|
|
64
|
-
* @returns {string} the
|
|
65
|
-
*/
|
|
66
|
-
export function contextify(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
|
|
67
|
-
export namespace contextify { }
|
|
68
|
-
/**
|
|
69
|
-
* @param {string} context context used to create relative path
|
|
70
|
-
* @param {string} identifier identifier used to create relative path
|
|
71
|
-
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
72
|
-
* @returns {string} the returned relative path
|
|
73
|
+
* @param {string} filename the filename which should be undone
|
|
74
|
+
* @param {string} outputPath the output path that is restored (only relevant when filename contains "..")
|
|
75
|
+
* @param {boolean} enforceRelative true returns ./ for empty paths
|
|
76
|
+
* @returns {string} repeated ../ to leave the directory of the provided filename to be back on output dir
|
|
73
77
|
*/
|
|
74
|
-
export
|
|
75
|
-
export
|
|
76
|
-
import path = require("path");
|
|
78
|
+
export declare const getUndoPath: (filename: string, outputPath: string, enforceRelative: boolean) => string;
|
|
79
|
+
export {};
|
package/dist/util/identifier.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getUndoPath = exports.parseResourceWithoutFragment = exports.parseResource = exports.absolutify = exports.contextify = exports.makePathsAbsolute = exports.makePathsRelative = void 0;
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
6
11
|
const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
|
|
7
12
|
const SEGMENTS_SPLIT_REGEXP = /([|!])/;
|
|
8
13
|
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
|
|
9
|
-
|
|
10
|
-
* @typedef {Object} MakeRelativePathsCache
|
|
11
|
-
* @property {Map<string, Map<string, string>>=} relativePaths
|
|
12
|
-
*/
|
|
13
|
-
// @ts-expect-error
|
|
14
|
-
const relativePathToRequest = relativePath => {
|
|
14
|
+
const relativePathToRequest = (relativePath) => {
|
|
15
15
|
if (relativePath === "")
|
|
16
16
|
return "./.";
|
|
17
17
|
if (relativePath === "..")
|
|
@@ -37,7 +37,7 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
|
|
|
37
37
|
let resource = querySplitPos === -1
|
|
38
38
|
? maybeAbsolutePath
|
|
39
39
|
: maybeAbsolutePath.slice(0, querySplitPos);
|
|
40
|
-
resource = relativePathToRequest(
|
|
40
|
+
resource = relativePathToRequest(node_path_1.default.posix.relative(context, resource));
|
|
41
41
|
return querySplitPos === -1
|
|
42
42
|
? resource
|
|
43
43
|
: resource + maybeAbsolutePath.slice(querySplitPos);
|
|
@@ -47,7 +47,7 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
|
|
|
47
47
|
let resource = querySplitPos === -1
|
|
48
48
|
? maybeAbsolutePath
|
|
49
49
|
: maybeAbsolutePath.slice(0, querySplitPos);
|
|
50
|
-
resource =
|
|
50
|
+
resource = node_path_1.default.win32.relative(context, resource);
|
|
51
51
|
if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) {
|
|
52
52
|
resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"));
|
|
53
53
|
}
|
|
@@ -65,28 +65,19 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
|
|
|
65
65
|
*/
|
|
66
66
|
const requestToAbsolute = (context, relativePath) => {
|
|
67
67
|
if (relativePath.startsWith("./") || relativePath.startsWith("../"))
|
|
68
|
-
return
|
|
68
|
+
return node_path_1.default.join(context, relativePath);
|
|
69
69
|
return relativePath;
|
|
70
70
|
};
|
|
71
|
-
|
|
72
|
-
const makeCacheable = realFn => {
|
|
73
|
-
/** @type {WeakMap<object, Map<string, ParsedResource>>} */
|
|
71
|
+
const makeCacheable = (realFn) => {
|
|
74
72
|
const cache = new WeakMap();
|
|
75
|
-
|
|
76
|
-
const getCache = associatedObjectForCache => {
|
|
73
|
+
const getCache = (associatedObjectForCache) => {
|
|
77
74
|
const entry = cache.get(associatedObjectForCache);
|
|
78
75
|
if (entry !== undefined)
|
|
79
76
|
return entry;
|
|
80
|
-
/** @type {Map<string, ParsedResource>} */
|
|
81
77
|
const map = new Map();
|
|
82
78
|
cache.set(associatedObjectForCache, map);
|
|
83
79
|
return map;
|
|
84
80
|
};
|
|
85
|
-
/**
|
|
86
|
-
* @param {string} str the path with query and fragment
|
|
87
|
-
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
88
|
-
* @returns {ParsedResource} parsed parts
|
|
89
|
-
*/
|
|
90
81
|
const fn = (str, associatedObjectForCache) => {
|
|
91
82
|
if (!associatedObjectForCache)
|
|
92
83
|
return realFn(str);
|
|
@@ -98,11 +89,9 @@ const makeCacheable = realFn => {
|
|
|
98
89
|
cache.set(str, result);
|
|
99
90
|
return result;
|
|
100
91
|
};
|
|
101
|
-
|
|
102
|
-
fn.bindCache = associatedObjectForCache => {
|
|
92
|
+
fn.bindCache = (associatedObjectForCache) => {
|
|
103
93
|
const cache = getCache(associatedObjectForCache);
|
|
104
|
-
|
|
105
|
-
return str => {
|
|
94
|
+
return (str) => {
|
|
106
95
|
const entry = cache.get(str);
|
|
107
96
|
if (entry !== undefined)
|
|
108
97
|
return entry;
|
|
@@ -113,9 +102,7 @@ const makeCacheable = realFn => {
|
|
|
113
102
|
};
|
|
114
103
|
return fn;
|
|
115
104
|
};
|
|
116
|
-
|
|
117
|
-
const makeCacheableWithContext = fn => {
|
|
118
|
-
/** @type {WeakMap<object, Map<string, Map<string, string>>>} */
|
|
105
|
+
const makeCacheableWithContext = (fn) => {
|
|
119
106
|
const cache = new WeakMap();
|
|
120
107
|
/**
|
|
121
108
|
* @param {string} context context used to create relative path
|
|
@@ -126,6 +113,7 @@ const makeCacheableWithContext = fn => {
|
|
|
126
113
|
const cachedFn = (context, identifier, associatedObjectForCache) => {
|
|
127
114
|
if (!associatedObjectForCache)
|
|
128
115
|
return fn(context, identifier);
|
|
116
|
+
/** @type {Map<string, Map<string, string>> | undefined} */
|
|
129
117
|
let innerCache = cache.get(associatedObjectForCache);
|
|
130
118
|
if (innerCache === undefined) {
|
|
131
119
|
innerCache = new Map();
|
|
@@ -152,8 +140,7 @@ const makeCacheableWithContext = fn => {
|
|
|
152
140
|
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
|
|
153
141
|
* @returns {function(string, string): string} cached function
|
|
154
142
|
*/
|
|
155
|
-
cachedFn.bindCache = associatedObjectForCache => {
|
|
156
|
-
// @ts-expect-error
|
|
143
|
+
cachedFn.bindCache = (associatedObjectForCache) => {
|
|
157
144
|
let innerCache;
|
|
158
145
|
if (associatedObjectForCache) {
|
|
159
146
|
innerCache = cache.get(associatedObjectForCache);
|
|
@@ -172,11 +159,10 @@ const makeCacheableWithContext = fn => {
|
|
|
172
159
|
*/
|
|
173
160
|
const boundFn = (context, identifier) => {
|
|
174
161
|
let cachedResult;
|
|
175
|
-
|
|
176
|
-
let innerSubCache = innerCache.get(context);
|
|
162
|
+
let innerSubCache = innerCache?.get(context);
|
|
177
163
|
if (innerSubCache === undefined) {
|
|
178
|
-
|
|
179
|
-
innerCache
|
|
164
|
+
innerSubCache = new Map();
|
|
165
|
+
innerCache?.set(context, innerSubCache);
|
|
180
166
|
}
|
|
181
167
|
else {
|
|
182
168
|
cachedResult = innerSubCache.get(identifier);
|
|
@@ -198,7 +184,6 @@ const makeCacheableWithContext = fn => {
|
|
|
198
184
|
* @returns {function(string): string} cached function
|
|
199
185
|
*/
|
|
200
186
|
cachedFn.bindContextCache = (context, associatedObjectForCache) => {
|
|
201
|
-
// @ts-expect-error
|
|
202
187
|
let innerSubCache;
|
|
203
188
|
if (associatedObjectForCache) {
|
|
204
189
|
let innerCache = cache.get(associatedObjectForCache);
|
|
@@ -218,16 +203,14 @@ const makeCacheableWithContext = fn => {
|
|
|
218
203
|
* @param {string} identifier identifier used to create relative path
|
|
219
204
|
* @returns {string} the returned relative path
|
|
220
205
|
*/
|
|
221
|
-
const boundFn = identifier => {
|
|
222
|
-
|
|
223
|
-
const cachedResult = innerSubCache.get(identifier);
|
|
206
|
+
const boundFn = (identifier) => {
|
|
207
|
+
const cachedResult = innerSubCache?.get(identifier);
|
|
224
208
|
if (cachedResult !== undefined) {
|
|
225
209
|
return cachedResult;
|
|
226
210
|
}
|
|
227
211
|
else {
|
|
228
212
|
const result = fn(context, identifier);
|
|
229
|
-
|
|
230
|
-
innerSubCache.set(identifier, result);
|
|
213
|
+
innerSubCache?.set(identifier, result);
|
|
231
214
|
return result;
|
|
232
215
|
}
|
|
233
216
|
};
|
|
@@ -272,8 +255,7 @@ const _contextify = (context, request) => {
|
|
|
272
255
|
.map(r => absoluteToRequest(context, r))
|
|
273
256
|
.join("!");
|
|
274
257
|
};
|
|
275
|
-
|
|
276
|
-
exports.contextify = contextify;
|
|
258
|
+
exports.contextify = makeCacheableWithContext(_contextify);
|
|
277
259
|
/**
|
|
278
260
|
* @param {string} context absolute context path
|
|
279
261
|
* @param {string} request any request string
|
|
@@ -285,25 +267,19 @@ const _absolutify = (context, request) => {
|
|
|
285
267
|
.map(r => requestToAbsolute(context, r))
|
|
286
268
|
.join("!");
|
|
287
269
|
};
|
|
288
|
-
|
|
289
|
-
exports.absolutify = absolutify;
|
|
270
|
+
exports.absolutify = makeCacheableWithContext(_absolutify);
|
|
290
271
|
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
|
|
291
272
|
const PATH_QUERY_REGEXP = /^((?:\u200b.|[^?\u200b])*)(\?.*)?$/;
|
|
292
|
-
/** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */
|
|
293
|
-
/** @typedef {{ resource: string, path: string, query: string }} ParsedResourceWithoutFragment */
|
|
294
273
|
/**
|
|
295
274
|
* @param {string} str the path with query and fragment
|
|
296
275
|
* @returns {ParsedResource} parsed parts
|
|
297
276
|
*/
|
|
298
|
-
const _parseResource = str => {
|
|
277
|
+
const _parseResource = (str) => {
|
|
299
278
|
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
300
279
|
return {
|
|
301
280
|
resource: str,
|
|
302
|
-
// @ts-expect-error
|
|
303
281
|
path: match[1].replace(/\u200b(.)/g, "$1"),
|
|
304
|
-
// @ts-expect-error
|
|
305
282
|
query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : "",
|
|
306
|
-
// @ts-expect-error
|
|
307
283
|
fragment: match[3] || ""
|
|
308
284
|
};
|
|
309
285
|
};
|
|
@@ -313,13 +289,11 @@ exports.parseResource = makeCacheable(_parseResource);
|
|
|
313
289
|
* @param {string} str the path with query and fragment
|
|
314
290
|
* @returns {ParsedResourceWithoutFragment} parsed parts
|
|
315
291
|
*/
|
|
316
|
-
const _parseResourceWithoutFragment = str => {
|
|
292
|
+
const _parseResourceWithoutFragment = (str) => {
|
|
317
293
|
const match = PATH_QUERY_REGEXP.exec(str);
|
|
318
294
|
return {
|
|
319
295
|
resource: str,
|
|
320
|
-
// @ts-expect-error
|
|
321
296
|
path: match[1].replace(/\u200b(.)/g, "$1"),
|
|
322
|
-
// @ts-expect-error
|
|
323
297
|
query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : ""
|
|
324
298
|
};
|
|
325
299
|
};
|
|
@@ -330,7 +304,7 @@ exports.parseResourceWithoutFragment = makeCacheable(_parseResourceWithoutFragme
|
|
|
330
304
|
* @param {boolean} enforceRelative true returns ./ for empty paths
|
|
331
305
|
* @returns {string} repeated ../ to leave the directory of the provided filename to be back on output dir
|
|
332
306
|
*/
|
|
333
|
-
|
|
307
|
+
const getUndoPath = (filename, outputPath, enforceRelative) => {
|
|
334
308
|
let depth = -1;
|
|
335
309
|
let append = "";
|
|
336
310
|
outputPath = outputPath.replace(/[\\/]$/, "");
|
|
@@ -359,3 +333,4 @@ exports.getUndoPath = (filename, outputPath, enforceRelative) => {
|
|
|
359
333
|
? `./${append}`
|
|
360
334
|
: append;
|
|
361
335
|
};
|
|
336
|
+
exports.getUndoPath = getUndoPath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.5",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "The fast Rust-based web bundler with webpack-compatible API",
|
|
@@ -39,24 +39,27 @@
|
|
|
39
39
|
"@swc/core": "1.4.0",
|
|
40
40
|
"@types/neo-async": "^2.6.6",
|
|
41
41
|
"@types/watchpack": "^2.4.0",
|
|
42
|
+
"@types/webpack-sources": "3.2.3",
|
|
42
43
|
"browserslist": "^4.21.3",
|
|
43
44
|
"cross-env": "^7.0.3",
|
|
44
45
|
"enhanced-resolve": "5.12.0",
|
|
45
46
|
"graceful-fs": "4.2.10",
|
|
47
|
+
"@types/graceful-fs": "4.1.9",
|
|
46
48
|
"json-parse-even-better-errors": "^3.0.0",
|
|
47
49
|
"neo-async": "2.6.2",
|
|
48
50
|
"prebundle": "^1.1.0",
|
|
49
51
|
"tsc-alias": "^1.8.8",
|
|
50
52
|
"watchpack": "^2.4.0",
|
|
51
53
|
"webpack-sources": "3.2.3",
|
|
54
|
+
"webpack-dev-server": "4.13.1",
|
|
52
55
|
"zod": "^3.21.4",
|
|
53
56
|
"zod-validation-error": "1.3.1"
|
|
54
57
|
},
|
|
55
58
|
"dependencies": {
|
|
56
59
|
"@module-federation/runtime-tools": "0.2.3",
|
|
57
60
|
"caniuse-lite": "^1.0.30001616",
|
|
58
|
-
"@rspack/binding": "1.0.0-alpha.
|
|
59
|
-
"@rspack/lite-tapable": "1.0.0-alpha.
|
|
61
|
+
"@rspack/binding": "1.0.0-alpha.5",
|
|
62
|
+
"@rspack/lite-tapable": "1.0.0-alpha.5"
|
|
60
63
|
},
|
|
61
64
|
"peerDependencies": {
|
|
62
65
|
"@swc/helpers": ">=0.5.1"
|