@rspack/core 0.6.5 → 0.7.0-beta.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/Chunk.d.ts +1 -1
- package/dist/Chunk.js +1 -1
- package/dist/ChunkGroup.d.ts +2 -0
- package/dist/ChunkGroup.js +4 -0
- package/dist/Compilation.d.ts +46 -65
- package/dist/Compilation.js +128 -222
- package/dist/Compiler.d.ts +75 -44
- package/dist/Compiler.js +325 -278
- package/dist/ContextModuleFactory.d.ts +7 -3
- package/dist/ContextModuleFactory.js +2 -2
- package/dist/Entrypoint.d.ts +1 -1
- package/dist/Entrypoint.js +1 -1
- package/dist/ExecuteModulePlugin.js +1 -1
- package/dist/Module.d.ts +11 -0
- package/dist/Module.js +2 -2
- package/dist/MultiCompiler.d.ts +10 -25
- package/dist/MultiCompiler.js +3 -3
- package/dist/MultiStats.d.ts +1 -1
- package/dist/NormalModuleFactory.d.ts +1 -1
- package/dist/Stats.d.ts +2 -2
- package/dist/Watching.d.ts +0 -9
- package/dist/Watching.js +12 -2
- package/dist/builtin-loader/swc/index.d.ts +6 -6
- package/dist/builtin-loader/swc/index.js +3 -3
- package/dist/builtin-loader/swc/types.d.ts +2 -2
- package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/BannerPlugin.d.ts +2 -2
- package/dist/builtin-plugin/BannerPlugin.js +1 -1
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DynamicEntryPlugin.js +1 -1
- package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EntryPlugin.js +1 -1
- package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +2 -2
- package/dist/builtin-plugin/HtmlRspackPlugin.js +2 -2
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
- package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +1 -1
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
- package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +15 -0
- package/dist/builtin-plugin/SizeLimitsPlugin.js +9 -0
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SplitChunksPlugin.d.ts +2 -2
- package/dist/builtin-plugin/SplitChunksPlugin.js +4 -4
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
- package/dist/builtin-plugin/WorkerPlugin.d.ts +2 -2
- package/dist/builtin-plugin/base.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/index.d.ts +5 -4
- package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/loader.js +2 -2
- package/dist/builtin-plugin/index.d.ts +44 -43
- package/dist/builtin-plugin/index.js +44 -43
- package/dist/config/adapter.d.ts +2 -2
- package/dist/config/adapter.js +6 -5
- package/dist/config/adapterRuleUse.d.ts +2 -1
- package/dist/config/adapterRuleUse.js +2 -2
- package/dist/config/defaults.js +21 -4
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -2
- package/dist/config/normalization.d.ts +2 -2
- package/dist/config/normalization.js +1 -0
- package/dist/config/zod.d.ts +317 -189
- package/dist/config/zod.js +23 -29
- package/dist/container/ContainerPlugin.d.ts +1 -1
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/container/ContainerReferencePlugin.js +1 -1
- package/dist/container/ModuleFederationPlugin.js +1 -1
- package/dist/container/ModuleFederationPluginV1.d.ts +1 -1
- package/dist/container/ModuleFederationPluginV1.js +1 -1
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
- package/dist/exports.d.ts +36 -30
- package/dist/exports.js +36 -28
- package/dist/fileSystem.d.ts +12 -8
- package/dist/fileSystem.js +25 -48
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lite-tapable/index.d.ts +6 -0
- package/dist/lite-tapable/index.js +107 -1
- package/dist/loader-runner/index.js +13 -13
- package/dist/logging/Logger.d.ts +1 -1
- package/dist/logging/createConsoleLogger.js +0 -14
- package/dist/node/NodeEnvironmentPlugin.d.ts +1 -1
- package/dist/node/NodeEnvironmentPlugin.js +1 -1
- package/dist/node/nodeConsole.js +0 -4
- package/dist/rspack.d.ts +4 -13
- package/dist/rspack.js +8 -8
- package/dist/rspackOptionsApply.d.ts +1 -10
- package/dist/rspackOptionsApply.js +17 -5
- package/dist/sharing/ConsumeSharedPlugin.d.ts +1 -1
- package/dist/sharing/ConsumeSharedPlugin.js +1 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +2 -2
- package/dist/stats/StatsFactory.d.ts +2 -2
- package/dist/stats/StatsFactory.js +0 -9
- package/dist/stats/StatsPrinter.d.ts +1 -1
- package/dist/stats/statsFactoryUtils.d.ts +1 -1
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/fs.d.ts +64 -0
- package/dist/util/fs.js +122 -0
- package/dist/util/index.d.ts +2 -1
- package/dist/util/index.js +16 -11
- package/dist/util/source.d.ts +18 -0
- package/dist/util/source.js +66 -0
- package/package.json +6 -5
- package/dist/util/createSource.d.ts +0 -5
- package/dist/util/createSource.js +0 -65
package/dist/util/fs.js
CHANGED
|
@@ -1,2 +1,124 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The following code is modified based on
|
|
4
|
+
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/fs.js
|
|
5
|
+
*
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
* Author Tobias Koppers @sokra
|
|
8
|
+
* Copyright (c) JS Foundation and other contributors
|
|
9
|
+
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.mkdirp = exports.rmrf = void 0;
|
|
16
|
+
const assert_1 = __importDefault(require("assert"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
function rmrf(fs, p, callback) {
|
|
19
|
+
fs.stat(p, (err, stats) => {
|
|
20
|
+
if (err) {
|
|
21
|
+
if (err.code === "ENOENT") {
|
|
22
|
+
return callback();
|
|
23
|
+
}
|
|
24
|
+
return callback(err);
|
|
25
|
+
}
|
|
26
|
+
if (stats.isDirectory()) {
|
|
27
|
+
fs.readdir(p, (err, files) => {
|
|
28
|
+
if (err) {
|
|
29
|
+
return callback(err);
|
|
30
|
+
}
|
|
31
|
+
let count = files.length;
|
|
32
|
+
if (count === 0) {
|
|
33
|
+
fs.rmdir(p, callback);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
files.forEach(file => {
|
|
37
|
+
(0, assert_1.default)(typeof file === "string");
|
|
38
|
+
const fullPath = join(fs, p, file);
|
|
39
|
+
rmrf(fs, fullPath, err => {
|
|
40
|
+
if (err) {
|
|
41
|
+
return callback(err);
|
|
42
|
+
}
|
|
43
|
+
count--;
|
|
44
|
+
if (count === 0) {
|
|
45
|
+
fs.rmdir(p, callback);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
fs.unlink(p, callback);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.rmrf = rmrf;
|
|
58
|
+
const join = (fs, rootPath, filename) => {
|
|
59
|
+
if (fs && fs.join) {
|
|
60
|
+
return fs.join(rootPath, filename);
|
|
61
|
+
}
|
|
62
|
+
else if (path_1.default.posix.isAbsolute(rootPath)) {
|
|
63
|
+
return path_1.default.posix.join(rootPath, filename);
|
|
64
|
+
}
|
|
65
|
+
else if (path_1.default.win32.isAbsolute(rootPath)) {
|
|
66
|
+
return path_1.default.win32.join(rootPath, filename);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error(`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const dirname = (fs, absPath) => {
|
|
73
|
+
if (fs && fs.dirname) {
|
|
74
|
+
return fs.dirname(absPath);
|
|
75
|
+
}
|
|
76
|
+
else if (path_1.default.posix.isAbsolute(absPath)) {
|
|
77
|
+
return path_1.default.posix.dirname(absPath);
|
|
78
|
+
}
|
|
79
|
+
else if (path_1.default.win32.isAbsolute(absPath)) {
|
|
80
|
+
return path_1.default.win32.dirname(absPath);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw new Error(`${absPath} is neither a posix nor a windows path, and there is no 'dirname' method defined in the file system`);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const mkdirp = (fs, p, callback) => {
|
|
87
|
+
fs.mkdir(p, err => {
|
|
88
|
+
if (err) {
|
|
89
|
+
if (err.code === "ENOENT") {
|
|
90
|
+
const dir = dirname(fs, p);
|
|
91
|
+
if (dir === p) {
|
|
92
|
+
callback(err);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
(0, exports.mkdirp)(fs, dir, err => {
|
|
96
|
+
if (err) {
|
|
97
|
+
callback(err);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
fs.mkdir(p, err => {
|
|
101
|
+
if (err) {
|
|
102
|
+
if (err.code === "EEXIST") {
|
|
103
|
+
callback();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
callback(err);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
callback();
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
else if (err.code === "EEXIST") {
|
|
115
|
+
callback();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
callback(err);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
callback();
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
exports.mkdirp = mkdirp;
|
package/dist/util/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const toObject: (input: string | Buffer | object) => object;
|
|
|
11
11
|
export declare function serializeObject(map: string | object | undefined | null): Buffer | undefined;
|
|
12
12
|
export declare function isPromiseLike(value: unknown): value is Promise<any>;
|
|
13
13
|
export declare function isJsStatsError(err: any): err is JsStatsError;
|
|
14
|
-
export declare function concatErrorMsgAndStack(err: Error | JsStatsError): string;
|
|
14
|
+
export declare function concatErrorMsgAndStack(err: Error | JsStatsError | string): string;
|
|
15
15
|
export declare function indent(str: string, prefix: string): string;
|
|
16
16
|
export declare function stringifyLoaderObject(o: LoaderObject): string;
|
|
17
17
|
export declare function asArray<T>(item: T[]): T[];
|
|
@@ -19,3 +19,4 @@ export declare function asArray<T>(item: readonly T[]): readonly T[];
|
|
|
19
19
|
export declare function asArray<T>(item: T): T[];
|
|
20
20
|
export declare function toJsAssetInfo(info?: AssetInfo): JsAssetInfo;
|
|
21
21
|
export declare const deprecatedWarn: (content: string, enable?: boolean) => void;
|
|
22
|
+
export declare const unsupported: (name: string, issue?: string) => never;
|
package/dist/util/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deprecatedWarn = exports.toJsAssetInfo = exports.asArray = exports.stringifyLoaderObject = exports.indent = exports.concatErrorMsgAndStack = exports.isJsStatsError = exports.isPromiseLike = exports.serializeObject = exports.toObject = exports.toBuffer = exports.isNil = exports.mapValues = void 0;
|
|
3
|
+
exports.unsupported = exports.deprecatedWarn = exports.toJsAssetInfo = exports.asArray = exports.stringifyLoaderObject = exports.indent = exports.concatErrorMsgAndStack = exports.isJsStatsError = exports.isPromiseLike = exports.serializeObject = exports.toObject = exports.toBuffer = exports.isNil = exports.mapValues = void 0;
|
|
4
4
|
function mapValues(record, fn) {
|
|
5
5
|
return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, fn(value)]));
|
|
6
6
|
}
|
|
@@ -60,16 +60,13 @@ function isJsStatsError(err) {
|
|
|
60
60
|
}
|
|
61
61
|
exports.isJsStatsError = isJsStatsError;
|
|
62
62
|
function concatErrorMsgAndStack(err) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
? `${err.stack}`
|
|
71
|
-
: `${err.message}\n${err.stack}`
|
|
72
|
-
: `${err.message}`;
|
|
63
|
+
if (typeof err === "string") {
|
|
64
|
+
return err;
|
|
65
|
+
}
|
|
66
|
+
if ("stack" in err) {
|
|
67
|
+
return err.stack || err.message;
|
|
68
|
+
}
|
|
69
|
+
return err.message;
|
|
73
70
|
}
|
|
74
71
|
exports.concatErrorMsgAndStack = concatErrorMsgAndStack;
|
|
75
72
|
function indent(str, prefix) {
|
|
@@ -116,3 +113,11 @@ const deprecatedWarn = (content, enable = getDeprecationStatus()) => {
|
|
|
116
113
|
}
|
|
117
114
|
};
|
|
118
115
|
exports.deprecatedWarn = deprecatedWarn;
|
|
116
|
+
const unsupported = (name, issue) => {
|
|
117
|
+
let s = `${name} is not supported by rspack.`;
|
|
118
|
+
if (issue) {
|
|
119
|
+
s += ` Please refer to issue ${issue} for more information.`;
|
|
120
|
+
}
|
|
121
|
+
throw new Error(s);
|
|
122
|
+
};
|
|
123
|
+
exports.unsupported = unsupported;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { JsCompatSource } from "@rspack/binding";
|
|
3
|
+
import { Source } from "webpack-sources";
|
|
4
|
+
declare class JsSource extends Source {
|
|
5
|
+
static __from_binding(source: JsCompatSource): Source;
|
|
6
|
+
static __to_binding(source: Source): {
|
|
7
|
+
source: Buffer;
|
|
8
|
+
isRaw: boolean;
|
|
9
|
+
isBuffer: boolean;
|
|
10
|
+
map?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
source: Buffer;
|
|
13
|
+
map: Buffer;
|
|
14
|
+
isRaw: boolean;
|
|
15
|
+
isBuffer: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export { JsSource };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsSource = void 0;
|
|
4
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
class JsSource extends webpack_sources_1.Source {
|
|
7
|
+
static __from_binding(source) {
|
|
8
|
+
if (source.isRaw) {
|
|
9
|
+
return new webpack_sources_1.RawSource(
|
|
10
|
+
// @ts-expect-error: webpack-sources can accept buffer as source, see: https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/RawSource.js#L12
|
|
11
|
+
source.isBuffer ? source.source : source.source.toString("utf-8"));
|
|
12
|
+
}
|
|
13
|
+
if (!source.map) {
|
|
14
|
+
return new webpack_sources_1.RawSource(source.source.toString("utf-8"));
|
|
15
|
+
}
|
|
16
|
+
return new webpack_sources_1.CompatSource({
|
|
17
|
+
source() {
|
|
18
|
+
return source.source.toString("utf-8");
|
|
19
|
+
},
|
|
20
|
+
buffer() {
|
|
21
|
+
return source.source;
|
|
22
|
+
},
|
|
23
|
+
map(_) {
|
|
24
|
+
if (source.map) {
|
|
25
|
+
return JSON.parse(source.map.toString("utf-8"));
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
static __to_binding(source) {
|
|
32
|
+
var _a, _b, _c;
|
|
33
|
+
const sourceSource = source.source();
|
|
34
|
+
const isBuffer = Buffer.isBuffer(sourceSource);
|
|
35
|
+
if (source instanceof webpack_sources_1.RawSource) {
|
|
36
|
+
return {
|
|
37
|
+
source: source.buffer(),
|
|
38
|
+
isRaw: true,
|
|
39
|
+
isBuffer
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const buffer = (_b = (_a = source.buffer) === null || _a === void 0 ? void 0 : _a.call(source)) !== null && _b !== void 0 ? _b : (isBuffer
|
|
43
|
+
? sourceSource
|
|
44
|
+
: sourceSource instanceof ArrayBuffer
|
|
45
|
+
? arrayBufferToBuffer(sourceSource)
|
|
46
|
+
: Buffer.from(sourceSource));
|
|
47
|
+
const map = JSON.stringify((_c = source.map) === null || _c === void 0 ? void 0 : _c.call(source, {
|
|
48
|
+
columns: true
|
|
49
|
+
}));
|
|
50
|
+
return {
|
|
51
|
+
source: buffer,
|
|
52
|
+
map: (0, index_1.isNil)(map) ? map : Buffer.from(map),
|
|
53
|
+
isRaw: false,
|
|
54
|
+
isBuffer
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.JsSource = JsSource;
|
|
59
|
+
function arrayBufferToBuffer(ab) {
|
|
60
|
+
const buf = Buffer.alloc(ab.byteLength);
|
|
61
|
+
const view = new Uint8Array(ab);
|
|
62
|
+
for (let i = 0; i < buf.length; ++i) {
|
|
63
|
+
buf[i] = view[i];
|
|
64
|
+
}
|
|
65
|
+
return buf;
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-beta.0",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Fast Rust-based Web Bundler",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"pug-loader": "^2.4.0",
|
|
62
62
|
"react-relay": "^16.0.0",
|
|
63
63
|
"sass": "1.56.2",
|
|
64
|
-
"sass-loader": "
|
|
64
|
+
"sass-loader": "14.2.1",
|
|
65
65
|
"source-map": "^0.7.4",
|
|
66
66
|
"source-map-loader": "^5.0.0",
|
|
67
67
|
"styled-components": "^6.0.8",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"watchpack": "^2.4.0",
|
|
72
72
|
"zod": "^3.21.4",
|
|
73
73
|
"zod-validation-error": "1.3.1",
|
|
74
|
-
"@rspack/core": "0.
|
|
75
|
-
"@rspack/plugin-minify": "^0.
|
|
74
|
+
"@rspack/core": "0.7.0-beta.0",
|
|
75
|
+
"@rspack/plugin-minify": "^0.7.0-beta.0"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@module-federation/runtime-tools": "0.1.6",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"enhanced-resolve": "5.12.0",
|
|
81
81
|
"tapable": "2.2.1",
|
|
82
82
|
"webpack-sources": "3.2.3",
|
|
83
|
-
"@rspack/binding": "0.
|
|
83
|
+
"@rspack/binding": "0.7.0-beta.0"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@swc/helpers": ">=0.5.1"
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
"build": "prebundle && tsc -b ./tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
95
95
|
"build:force": "prebundle && tsc -b ./tsconfig.build.json --force && tsc-alias -p tsconfig.build.json",
|
|
96
96
|
"dev": "prebundle && tsc -w",
|
|
97
|
+
"doc-coverage": "node scripts/check-documentation-coverage.mjs",
|
|
97
98
|
"api-extractor": "api-extractor run --verbose",
|
|
98
99
|
"api-extractor:ci": "api-extractor run --verbose || diff temp/api.md etc/api.md"
|
|
99
100
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { JsCompatSource } from "@rspack/binding";
|
|
2
|
-
import { Source } from "webpack-sources";
|
|
3
|
-
declare function createSourceFromRaw(source: JsCompatSource): Source;
|
|
4
|
-
declare function createRawFromSource(source: Source): JsCompatSource;
|
|
5
|
-
export { createSourceFromRaw, createRawFromSource };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRawFromSource = exports.createSourceFromRaw = void 0;
|
|
4
|
-
const webpack_sources_1 = require("webpack-sources");
|
|
5
|
-
const index_1 = require("./index");
|
|
6
|
-
function createSourceFromRaw(source) {
|
|
7
|
-
if (source.isRaw) {
|
|
8
|
-
return new webpack_sources_1.RawSource(
|
|
9
|
-
// @ts-expect-error: webpack-sources can accept buffer as source, see: https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/RawSource.js#L12
|
|
10
|
-
source.isBuffer ? source.source : source.source.toString("utf-8"));
|
|
11
|
-
}
|
|
12
|
-
if (!source.map) {
|
|
13
|
-
return new webpack_sources_1.RawSource(source.source.toString("utf-8"));
|
|
14
|
-
}
|
|
15
|
-
return new webpack_sources_1.CompatSource({
|
|
16
|
-
source() {
|
|
17
|
-
return source.source.toString("utf-8");
|
|
18
|
-
},
|
|
19
|
-
buffer() {
|
|
20
|
-
return source.source;
|
|
21
|
-
},
|
|
22
|
-
map(_) {
|
|
23
|
-
if (source.map) {
|
|
24
|
-
return JSON.parse(source.map.toString("utf-8"));
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
exports.createSourceFromRaw = createSourceFromRaw;
|
|
31
|
-
function createRawFromSource(source) {
|
|
32
|
-
var _a, _b, _c;
|
|
33
|
-
const sourceSource = source.source();
|
|
34
|
-
const isBuffer = Buffer.isBuffer(sourceSource);
|
|
35
|
-
if (source instanceof webpack_sources_1.RawSource) {
|
|
36
|
-
return {
|
|
37
|
-
source: source.buffer(),
|
|
38
|
-
isRaw: true,
|
|
39
|
-
isBuffer
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
const buffer = (_b = (_a = source.buffer) === null || _a === void 0 ? void 0 : _a.call(source)) !== null && _b !== void 0 ? _b : (isBuffer
|
|
43
|
-
? sourceSource
|
|
44
|
-
: sourceSource instanceof ArrayBuffer
|
|
45
|
-
? arrayBufferToBuffer(sourceSource)
|
|
46
|
-
: Buffer.from(sourceSource));
|
|
47
|
-
const map = JSON.stringify((_c = source.map) === null || _c === void 0 ? void 0 : _c.call(source, {
|
|
48
|
-
columns: true
|
|
49
|
-
}));
|
|
50
|
-
return {
|
|
51
|
-
source: buffer,
|
|
52
|
-
map: (0, index_1.isNil)(map) ? map : Buffer.from(map),
|
|
53
|
-
isRaw: false,
|
|
54
|
-
isBuffer
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
exports.createRawFromSource = createRawFromSource;
|
|
58
|
-
function arrayBufferToBuffer(ab) {
|
|
59
|
-
const buf = Buffer.alloc(ab.byteLength);
|
|
60
|
-
const view = new Uint8Array(ab);
|
|
61
|
-
for (let i = 0; i < buf.length; ++i) {
|
|
62
|
-
buf[i] = view[i];
|
|
63
|
-
}
|
|
64
|
-
return buf;
|
|
65
|
-
}
|