@rspack/core 0.0.10 → 0.0.12
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/bundle.js +1 -1
- package/dist/chunk_group.d.ts +7 -0
- package/dist/chunk_group.d.ts.map +1 -0
- package/dist/chunk_group.js +33 -0
- package/dist/chunk_group.js.map +1 -0
- package/dist/compilation.d.ts +15 -3
- package/dist/compilation.d.ts.map +1 -1
- package/dist/compilation.js +25 -4
- package/dist/compilation.js.map +1 -1
- package/dist/compiler.d.ts +3 -1
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +13 -19
- package/dist/compiler.js.map +1 -1
- package/dist/config/builtins.d.ts.map +1 -1
- package/dist/config/builtins.js.map +1 -1
- package/dist/config/cache.d.ts +17 -0
- package/dist/config/cache.d.ts.map +1 -0
- package/dist/config/cache.js +34 -0
- package/dist/config/cache.js.map +1 -0
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +7 -3
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/devServer.d.ts +11 -0
- package/dist/config/devServer.d.ts.map +1 -1
- package/dist/config/entry.d.ts +17 -2
- package/dist/config/entry.d.ts.map +1 -1
- package/dist/config/entry.js +32 -5
- package/dist/config/entry.js.map +1 -1
- package/dist/config/index.d.ts +8 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +8 -2
- package/dist/config/index.js.map +1 -1
- package/dist/config/module.d.ts +43 -30
- package/dist/config/module.d.ts.map +1 -1
- package/dist/config/module.js +201 -50
- package/dist/config/module.js.map +1 -1
- package/dist/config/output.d.ts +4 -0
- package/dist/config/output.d.ts.map +1 -1
- package/dist/config/output.js.map +1 -1
- package/dist/config/resolve.d.ts +1 -1
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +2 -2
- package/dist/config/resolve.js.map +1 -1
- package/dist/config/snapshot.d.ts +10 -0
- package/dist/config/snapshot.d.ts.map +1 -0
- package/dist/config/snapshot.js +21 -0
- package/dist/config/snapshot.js.map +1 -0
- package/dist/dynamic_js.xxxx.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.xxxx.js +1 -0
- package/dist/stats.d.ts +3 -1
- package/dist/stats.d.ts.map +1 -1
- package/dist/stats.js +2 -1
- package/dist/stats.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +11 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +7 -7
package/dist/config/entry.d.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
export declare type
|
|
2
|
-
export
|
|
1
|
+
export declare type EntryRuntime = false | string;
|
|
2
|
+
export interface EntryDescription {
|
|
3
|
+
import: EntryItem;
|
|
4
|
+
runtime?: EntryRuntime;
|
|
5
|
+
}
|
|
6
|
+
export interface ResolvedEntryItem {
|
|
7
|
+
import: string[];
|
|
8
|
+
runtime?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare type EntryItem = string[] | string;
|
|
11
|
+
export declare type EntryUnnamed = EntryItem;
|
|
12
|
+
export declare type Entry = EntryStatic;
|
|
13
|
+
export interface EntryObject {
|
|
14
|
+
[k: string]: EntryItem | EntryDescription;
|
|
15
|
+
}
|
|
16
|
+
export declare type EntryStatic = EntryObject | EntryUnnamed;
|
|
17
|
+
export declare type ResolvedEntry = Record<string, ResolvedEntryItem>;
|
|
3
18
|
interface ResolveEntryContext {
|
|
4
19
|
context: string;
|
|
5
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/config/entry.ts"],"names":[],"mappings":"AAEA,oBAAY,KAAK,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/config/entry.ts"],"names":[],"mappings":"AAEA,oBAAY,YAAY,GAAG,KAAK,GAAG,MAAM,CAAC;AAC1C,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,YAAY,CAAC;CACvB;AACD,MAAM,WAAW,iBAAiB;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AACD,oBAAY,SAAS,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;AAC1C,oBAAY,YAAY,GAAG,SAAS,CAAC;AACrC,oBAAY,KAAK,GAAG,WAAW,CAAC;AAEhC,MAAM,WAAW,WAAW;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,gBAAgB,CAAC;CAC1C;AACD,oBAAY,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC;AAErD,oBAAY,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAE9D,UAAU,mBAAmB;IAC5B,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,KAAK,EACd,OAAO,EAAE,mBAAmB,GAC1B,aAAa,CA4Cf"}
|
package/dist/config/entry.js
CHANGED
|
@@ -8,26 +8,45 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
function resolveEntryOptions(options, context) {
|
|
9
9
|
if (typeof options === "undefined" || options === null) {
|
|
10
10
|
return {
|
|
11
|
-
main:
|
|
11
|
+
main: normalizeEntryItem("main", {
|
|
12
|
+
import: [path_1.default.resolve(context.context, "src", "index.js")]
|
|
13
|
+
})
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
16
|
else if (typeof options === "string") {
|
|
15
17
|
return {
|
|
16
|
-
main:
|
|
18
|
+
main: normalizeEntryItem("main", {
|
|
19
|
+
import: [options]
|
|
20
|
+
})
|
|
17
21
|
};
|
|
18
22
|
}
|
|
19
23
|
else if (Array.isArray(options)) {
|
|
20
24
|
return {
|
|
21
|
-
main:
|
|
25
|
+
main: normalizeEntryItem("main", {
|
|
26
|
+
import: [...options]
|
|
27
|
+
})
|
|
22
28
|
};
|
|
23
29
|
}
|
|
24
30
|
else if (typeof options === "object") {
|
|
25
31
|
return Object.fromEntries(Object.entries({ ...options }).map(([key, value]) => {
|
|
26
32
|
if (Array.isArray(value)) {
|
|
27
|
-
return [
|
|
33
|
+
return [
|
|
34
|
+
key,
|
|
35
|
+
normalizeEntryItem(key, {
|
|
36
|
+
import: [...value]
|
|
37
|
+
})
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
else if (typeof value === "object") {
|
|
41
|
+
return [key, normalizeEntryItem(key, value)];
|
|
28
42
|
}
|
|
29
43
|
else {
|
|
30
|
-
return [
|
|
44
|
+
return [
|
|
45
|
+
key,
|
|
46
|
+
normalizeEntryItem(key, {
|
|
47
|
+
import: [value]
|
|
48
|
+
})
|
|
49
|
+
];
|
|
31
50
|
}
|
|
32
51
|
}));
|
|
33
52
|
}
|
|
@@ -36,4 +55,12 @@ function resolveEntryOptions(options, context) {
|
|
|
36
55
|
}
|
|
37
56
|
}
|
|
38
57
|
exports.resolveEntryOptions = resolveEntryOptions;
|
|
58
|
+
function normalizeEntryItem(entryName, entryItem) {
|
|
59
|
+
return {
|
|
60
|
+
import: Array.isArray(entryItem.import)
|
|
61
|
+
? entryItem.import
|
|
62
|
+
: [entryItem.import],
|
|
63
|
+
runtime: entryItem.runtime === false ? undefined : entryItem.runtime
|
|
64
|
+
};
|
|
65
|
+
}
|
|
39
66
|
//# sourceMappingURL=entry.js.map
|
package/dist/config/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../src/config/entry.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../src/config/entry.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AA0BxB,SAAgB,mBAAmB,CACl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,CAAC;qBACf,CAAC;iBACF,CAAC;aACF;QACF,CAAC,CAAC,CACF,CAAC;KACF;SAAM;QACN,OAAO,EAAE,CAAC;KACV;AACF,CAAC;AA/CD,kDA+CC;AAED,SAAS,kBAAkB,CAC1B,SAAiB,EACjB,SAA2B;IAE3B,OAAO;QACN,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;YACtC,CAAC,CAAC,SAAS,CAAC,MAAM;YAClB,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;QACrB,OAAO,EAAE,SAAS,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO;KACpE,CAAC;AACH,CAAC"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -3,12 +3,14 @@ import type { Dev } from "./devServer";
|
|
|
3
3
|
import type { Entry, ResolvedEntry } from "./entry";
|
|
4
4
|
import type { External, ExternalType, ResolvedExternal, ResolvedExternalType } from "./external";
|
|
5
5
|
import type { Mode, ResolvedMode } from "./mode";
|
|
6
|
-
import type { Module, ResolvedModule, LoaderContext } from "./module";
|
|
6
|
+
import type { Module, ResolvedModule, LoaderContext, Loader, SourceMap } from "./module";
|
|
7
7
|
import type { Plugin } from "./plugin";
|
|
8
8
|
import type { ResolvedTarget, Target } from "./target";
|
|
9
9
|
import type { Output, ResolvedOutput } from "./output";
|
|
10
10
|
import type { Resolve, ResolvedResolve } from "./resolve";
|
|
11
11
|
import type { Builtins, ResolvedBuiltins } from "./builtins";
|
|
12
|
+
import type { Snapshot, ResolvedSnapshot } from "./snapshot";
|
|
13
|
+
import type { Cache, ResolvedCache } from "./cache";
|
|
12
14
|
import { Devtool, ResolvedDevtool } from "./devtool";
|
|
13
15
|
import { InfrastructureLogging } from "./RspackOptions";
|
|
14
16
|
import { ResolvedStatsOptions, StatsOptions } from "./stats";
|
|
@@ -30,6 +32,8 @@ export interface RspackOptions {
|
|
|
30
32
|
devtool?: Devtool;
|
|
31
33
|
infrastructureLogging?: InfrastructureLogging;
|
|
32
34
|
stats?: StatsOptions;
|
|
35
|
+
snapshot?: Snapshot;
|
|
36
|
+
cache?: Cache;
|
|
33
37
|
}
|
|
34
38
|
export interface RspackOptionsNormalized {
|
|
35
39
|
name?: string;
|
|
@@ -48,9 +52,11 @@ export interface RspackOptionsNormalized {
|
|
|
48
52
|
devtool: ResolvedDevtool;
|
|
49
53
|
infrastructureLogging: InfrastructureLogging;
|
|
50
54
|
stats: ResolvedStatsOptions;
|
|
55
|
+
snapshot: ResolvedSnapshot;
|
|
56
|
+
cache: ResolvedCache;
|
|
51
57
|
}
|
|
52
58
|
export declare function getNormalizedRspackOptions(config: RspackOptions): RspackOptionsNormalized;
|
|
53
|
-
export type { Plugin, LoaderContext };
|
|
59
|
+
export type { Plugin, LoaderContext, Loader, SourceMap };
|
|
54
60
|
export type { WebSocketServerOptions, Dev } from "./devServer";
|
|
55
61
|
export { resolveWatchOption } from "./watch";
|
|
56
62
|
export type { StatsOptions } from "./stats";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,KAAK,EACX,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,e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CzB;AAKD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -8,9 +8,11 @@ const output_1 = require("./output");
|
|
|
8
8
|
const module_1 = require("./module");
|
|
9
9
|
const builtins_1 = require("./builtins");
|
|
10
10
|
const resolve_1 = require("./resolve");
|
|
11
|
+
const snapshot_1 = require("./snapshot");
|
|
12
|
+
const cache_1 = require("./cache");
|
|
11
13
|
const stats_1 = require("./stats");
|
|
12
14
|
function getNormalizedRspackOptions(config) {
|
|
13
|
-
var _a, _b, _c, _d, _e;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14
16
|
const context = (_a = config.context) !== null && _a !== void 0 ? _a : process.cwd();
|
|
15
17
|
const mode = (_b = config.mode) !== null && _b !== void 0 ? _b : "production";
|
|
16
18
|
const entry = (0, entry_1.resolveEntryOptions)(config.entry, {
|
|
@@ -27,6 +29,8 @@ function getNormalizedRspackOptions(config) {
|
|
|
27
29
|
const module = (0, module_1.resolveModuleOptions)(config.module, { devtool, context });
|
|
28
30
|
const stats = (0, stats_1.resolveStatsOptions)(config.stats);
|
|
29
31
|
const devServer = config.devServer;
|
|
32
|
+
const snapshot = (0, snapshot_1.resolveSnapshotOptions)(config.snapshot);
|
|
33
|
+
const cache = (0, cache_1.resolveCacheOptions)((_f = config.cache) !== null && _f !== void 0 ? _f : (mode === "production" ? false : true));
|
|
30
34
|
return {
|
|
31
35
|
...config,
|
|
32
36
|
context,
|
|
@@ -43,7 +47,9 @@ function getNormalizedRspackOptions(config) {
|
|
|
43
47
|
resolve,
|
|
44
48
|
devtool,
|
|
45
49
|
infrastructureLogging: cloneObject(config.infrastructureLogging),
|
|
46
|
-
stats
|
|
50
|
+
stats,
|
|
51
|
+
snapshot,
|
|
52
|
+
cache
|
|
47
53
|
};
|
|
48
54
|
}
|
|
49
55
|
exports.getNormalizedRspackOptions = getNormalizedRspackOptions;
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;AAGA,mCAA8C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;AAGA,mCAA8C;AAsB9C,uCAA4E;AAC5E,qCAAgD;AAChD,qCAAgD;AAChD,qCAAgD;AAChD,yCAAoD;AACpD,uCAAkD;AAClD,yCAAoD;AACpD,mCAA8C;AAE9C,mCAIiB;AA4CjB,SAAgB,0BAA0B,CACzC,MAAqB;;IAErB,MAAM,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAChD,MAAM,IAAI,GAAG,MAAA,MAAM,CAAC,IAAI,mCAAI,YAAY,CAAC;IACzC,MAAM,KAAK,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC,KAAK,EAAE;QAC/C,OAAO;KACP,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,IAAA,6BAAoB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,IAAA,6BAAoB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC;IACzC,MAAM,aAAa,GAAG,MAAA,MAAM,CAAC,aAAa,mCAAI,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAA,iCAAsB,EAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IACxE,MAAM,OAAO,GAAG,IAAA,+BAAqB,EAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAClE,MAAM,OAAO,GAAG,IAAA,+BAAqB,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,IAAA,6BAAoB,EAAC,MAAM,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACzE,MAAM,KAAK,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACnC,MAAM,QAAQ,GAAG,IAAA,iCAAsB,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,IAAA,2BAAmB,EAChC,MAAA,MAAM,CAAC,KAAK,mCAAI,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CACtD,CAAC;IAEF,OAAO;QACN,GAAG,MAAM;QACT,OAAO;QACP,IAAI;QACJ,SAAS;QACT,KAAK;QACL,MAAM;QACN,MAAM;QACN,SAAS;QACT,aAAa;QACb,OAAO;QACP,QAAQ;QACR,MAAM;QACN,OAAO;QACP,OAAO;QACP,qBAAqB,EAAE,WAAW,CAAC,MAAM,CAAC,qBAAqB,CAAC;QAChE,KAAK;QACL,QAAQ;QACR,KAAK;KACL,CAAC;AACH,CAAC;AA5CD,gEA4CC;AAED,SAAS,WAAW,CAAC,KAAsC;IAC1D,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;AACrB,CAAC;AAGD,iCAA6C;AAApC,2GAAA,kBAAkB,OAAA"}
|
package/dist/config/module.d.ts
CHANGED
|
@@ -1,56 +1,50 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { RawModuleRuleUse, RawModuleRule } from "@rspack/binding";
|
|
2
|
+
import type { RawModuleRuleUse, RawModuleRule, RawModuleOptions } from "@rspack/binding";
|
|
3
3
|
import { ResolvedContext } from "./context";
|
|
4
4
|
import { ResolvedDevtool } from "./devtool";
|
|
5
|
+
export declare type Condition = string | RegExp;
|
|
5
6
|
export interface ModuleRule {
|
|
6
7
|
name?: string;
|
|
7
|
-
test?:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
test?: Condition;
|
|
9
|
+
include?: Condition | Condition[];
|
|
10
|
+
exclude?: Condition | Condition[];
|
|
11
|
+
resource?: Condition;
|
|
12
|
+
resourceQuery?: Condition;
|
|
13
|
+
use?: ModuleRuleUse[];
|
|
11
14
|
type?: RawModuleRule["type"];
|
|
12
15
|
}
|
|
13
16
|
export interface Module {
|
|
14
17
|
rules?: ModuleRule[];
|
|
15
|
-
parser?:
|
|
16
|
-
dataUrlCondition?: {
|
|
17
|
-
maxSize?: number;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
18
|
+
parser?: RawModuleOptions["parser"];
|
|
20
19
|
}
|
|
21
20
|
interface ResolvedModuleRule {
|
|
22
21
|
test?: RawModuleRule["test"];
|
|
22
|
+
include?: RawModuleRule["include"];
|
|
23
|
+
exclude?: RawModuleRule["exclude"];
|
|
23
24
|
resource?: RawModuleRule["resource"];
|
|
24
25
|
resourceQuery?: RawModuleRule["resourceQuery"];
|
|
25
|
-
|
|
26
|
+
use?: RawModuleRuleUse[];
|
|
26
27
|
type?: RawModuleRule["type"];
|
|
27
28
|
}
|
|
28
29
|
export interface ResolvedModule {
|
|
29
30
|
rules: ResolvedModuleRule[];
|
|
30
|
-
parser?:
|
|
31
|
-
dataUrlCondition: {
|
|
32
|
-
maxSize: number;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
31
|
+
parser?: RawModuleOptions["parser"];
|
|
35
32
|
}
|
|
36
33
|
interface LoaderContextInternal {
|
|
37
34
|
source: number[];
|
|
38
|
-
sourceMap: string | null;
|
|
35
|
+
sourceMap: string | undefined | null;
|
|
36
|
+
additionalData: AdditionalData | undefined | null;
|
|
39
37
|
resource: string;
|
|
40
38
|
resourcePath: string;
|
|
41
39
|
resourceQuery: string | null;
|
|
42
40
|
resourceFragment: string | null;
|
|
41
|
+
cacheable: boolean;
|
|
43
42
|
}
|
|
44
|
-
interface
|
|
45
|
-
content: Buffer |
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
source: {
|
|
50
|
-
getCode(): string;
|
|
51
|
-
getBuffer(): Buffer;
|
|
52
|
-
};
|
|
53
|
-
useSourceMap: boolean;
|
|
43
|
+
export interface LoaderContext extends Pick<LoaderContextInternal, "resource" | "resourcePath" | "resourceQuery" | "resourceFragment"> {
|
|
44
|
+
async(): (err: Error | null, content: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => void;
|
|
45
|
+
callback(err: Error | null, content: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData): void;
|
|
46
|
+
cacheable(cacheable: boolean): void;
|
|
47
|
+
sourceMap: boolean;
|
|
54
48
|
rootContext: string;
|
|
55
49
|
context: string;
|
|
56
50
|
getOptions: () => unknown;
|
|
@@ -59,9 +53,28 @@ export interface ComposeJsUseOptions {
|
|
|
59
53
|
devtool: ResolvedDevtool;
|
|
60
54
|
context: ResolvedContext;
|
|
61
55
|
}
|
|
62
|
-
interface
|
|
63
|
-
|
|
56
|
+
export interface SourceMap {
|
|
57
|
+
version: number;
|
|
58
|
+
sources: string[];
|
|
59
|
+
mappings: string;
|
|
60
|
+
file?: string;
|
|
61
|
+
sourceRoot?: string;
|
|
62
|
+
sourcesContent?: string[];
|
|
63
|
+
names?: string[];
|
|
64
|
+
}
|
|
65
|
+
export interface AdditionalData {
|
|
66
|
+
[index: string]: any;
|
|
67
|
+
}
|
|
68
|
+
export interface LoaderResult {
|
|
69
|
+
cacheable: boolean;
|
|
70
|
+
content: string | Buffer;
|
|
71
|
+
sourceMap?: string | SourceMap;
|
|
72
|
+
additionalData?: AdditionalData;
|
|
73
|
+
}
|
|
74
|
+
export interface Loader {
|
|
75
|
+
(this: LoaderContext, content: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData): void;
|
|
64
76
|
displayName?: string;
|
|
77
|
+
raw?: boolean;
|
|
65
78
|
}
|
|
66
79
|
declare type BuiltinLoader = string;
|
|
67
80
|
declare type ModuleRuleUse = {
|
|
@@ -69,7 +82,7 @@ declare type ModuleRuleUse = {
|
|
|
69
82
|
options?: unknown;
|
|
70
83
|
name?: string;
|
|
71
84
|
} | {
|
|
72
|
-
loader:
|
|
85
|
+
loader: Loader;
|
|
73
86
|
options?: unknown;
|
|
74
87
|
name?: string;
|
|
75
88
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/config/module.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/config/module.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,aAAa,EAEb,gBAAgB,EAChB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAkB,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5D,oBAAY,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC,MAAM,WAAW,UAAU;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IAClC,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,GAAG,CAAC,EAAE,aAAa,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC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,GAC7B,IAAI,CAAC;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;CACd;AAED,aAAK,aAAa,GAAG,MAAM,CAAC;AAE5B,aAAK,aAAa,GACf;IACA,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACb,GACD;IACA,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEL,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,aAAa,EAAE,EACrB,OAAO,EAAE,mBAAmB,GAC1B,gBAAgB,EAAE,CAEpB;AAsED,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,MAAW,EACnB,OAAO,EAAE,mBAAmB,GAC1B,cAAc,CAuChB"}
|
package/dist/config/module.js
CHANGED
|
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.resolveModuleOptions = exports.createRawModuleRuleUses = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const utils_1 = require("../utils");
|
|
9
10
|
const devtool_1 = require("./devtool");
|
|
10
11
|
const toBuffer = (bufLike) => {
|
|
11
12
|
if (Buffer.isBuffer(bufLike)) {
|
|
@@ -22,61 +23,166 @@ function composeJsUse(uses, options) {
|
|
|
22
23
|
}
|
|
23
24
|
async function loader(data) {
|
|
24
25
|
const payload = JSON.parse(data.toString("utf-8"));
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
resourceQuery: payload.resourceQuery,
|
|
30
|
-
resource: payload.resource,
|
|
31
|
-
resourceFragment: payload.resourceFragment
|
|
32
|
-
};
|
|
33
|
-
let sourceBuffer = Buffer.from(loaderContextInternal.source);
|
|
34
|
-
let meta = Buffer.from("");
|
|
26
|
+
let cacheable = payload.cacheable;
|
|
27
|
+
let content = Buffer.from(payload.source);
|
|
28
|
+
let sourceMap = payload.sourceMap;
|
|
29
|
+
let additionalData;
|
|
35
30
|
// Loader is executed from right to left
|
|
36
31
|
for (const use of uses) {
|
|
37
|
-
(0,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
(0, assert_1.default)("loader" in use);
|
|
33
|
+
let loaderResult;
|
|
34
|
+
const p = new Promise((resolve, reject) => {
|
|
35
|
+
let isDone = false;
|
|
36
|
+
// Whether a `callback` or `async` is called
|
|
37
|
+
let isSync = true;
|
|
38
|
+
let isError = false; // internal error
|
|
39
|
+
let reportedError = false;
|
|
40
|
+
function callback(err, content, sourceMap, additionalData) {
|
|
41
|
+
if (isDone) {
|
|
42
|
+
if (reportedError)
|
|
43
|
+
return; // ignore
|
|
44
|
+
err = new Error("callback(): The callback was already called.");
|
|
45
|
+
}
|
|
46
|
+
isSync = false;
|
|
47
|
+
isDone = true;
|
|
48
|
+
if (err) {
|
|
49
|
+
isError = true;
|
|
50
|
+
reject(err);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
resolve({
|
|
54
|
+
cacheable,
|
|
55
|
+
content,
|
|
56
|
+
sourceMap,
|
|
57
|
+
additionalData
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const loaderContext = {
|
|
61
|
+
sourceMap: (0, devtool_1.isUseSourceMap)(options.devtool),
|
|
62
|
+
resourcePath: payload.resourcePath,
|
|
63
|
+
resource: payload.resource,
|
|
64
|
+
// Return an empty string if there is no query or fragment
|
|
65
|
+
resourceQuery: payload.resourceQuery || "",
|
|
66
|
+
resourceFragment: payload.resourceFragment || "",
|
|
67
|
+
getOptions() {
|
|
68
|
+
return use.options;
|
|
69
|
+
},
|
|
70
|
+
cacheable(value) {
|
|
71
|
+
cacheable = value;
|
|
52
72
|
},
|
|
53
|
-
|
|
54
|
-
|
|
73
|
+
async() {
|
|
74
|
+
if (isDone) {
|
|
75
|
+
if (reportedError)
|
|
76
|
+
return; // ignore
|
|
77
|
+
reject(new Error("async(): The callback was already called."));
|
|
78
|
+
}
|
|
79
|
+
isSync = false;
|
|
80
|
+
return callback;
|
|
81
|
+
},
|
|
82
|
+
callback,
|
|
83
|
+
rootContext: options.context,
|
|
84
|
+
context: path_1.default.dirname(payload.resourcePath)
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* support loader as string
|
|
88
|
+
*/
|
|
89
|
+
if (typeof use.loader === "string") {
|
|
90
|
+
try {
|
|
91
|
+
let loaderPath = require.resolve(use.loader, {
|
|
92
|
+
paths: [options.context]
|
|
93
|
+
});
|
|
94
|
+
use.loader = require(loaderPath);
|
|
55
95
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
96
|
+
catch (err) {
|
|
97
|
+
reject(err);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
let result = undefined;
|
|
102
|
+
try {
|
|
103
|
+
result = use.loader.apply(loaderContext, [
|
|
104
|
+
use.loader.raw ? Buffer.from(content) : content.toString("utf-8"),
|
|
105
|
+
sourceMap,
|
|
106
|
+
additionalData
|
|
107
|
+
]);
|
|
108
|
+
if (isSync) {
|
|
109
|
+
isDone = true;
|
|
110
|
+
if (result === undefined) {
|
|
111
|
+
resolve({
|
|
112
|
+
content,
|
|
113
|
+
sourceMap,
|
|
114
|
+
additionalData,
|
|
115
|
+
cacheable
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if ((0, utils_1.isPromiseLike)(result)) {
|
|
120
|
+
return result.then(function (result) {
|
|
121
|
+
resolve({
|
|
122
|
+
content: result,
|
|
123
|
+
sourceMap,
|
|
124
|
+
additionalData,
|
|
125
|
+
cacheable
|
|
126
|
+
});
|
|
127
|
+
}, reject);
|
|
128
|
+
}
|
|
129
|
+
return resolve({
|
|
130
|
+
content: result,
|
|
131
|
+
sourceMap,
|
|
132
|
+
additionalData,
|
|
133
|
+
cacheable
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
if (isError) {
|
|
139
|
+
reject(err);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (isDone) {
|
|
143
|
+
// loader is already "done", so we cannot use the callback function
|
|
144
|
+
// for better debugging we print the error on the console
|
|
145
|
+
if (typeof err === "object" && err.stack)
|
|
146
|
+
console.error(err.stack);
|
|
147
|
+
else
|
|
148
|
+
console.error(err);
|
|
149
|
+
reject(err);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
isDone = true;
|
|
153
|
+
reportedError = true;
|
|
154
|
+
reject(err);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
if ((loaderResult = await p)) {
|
|
158
|
+
additionalData =
|
|
159
|
+
(typeof loaderResult.additionalData === "string"
|
|
160
|
+
? JSON.parse(loaderResult.additionalData)
|
|
161
|
+
: loaderResult.additionalData) || additionalData;
|
|
162
|
+
content = loaderResult.content || content;
|
|
163
|
+
sourceMap = loaderResult.sourceMap || sourceMap;
|
|
164
|
+
cacheable = loaderResult.cacheable || cacheable;
|
|
69
165
|
}
|
|
70
166
|
}
|
|
71
167
|
const loaderResultPayload = {
|
|
72
|
-
|
|
73
|
-
|
|
168
|
+
cacheable: cacheable,
|
|
169
|
+
content: [...toBuffer(content)],
|
|
170
|
+
sourceMap: !(0, utils_1.isNil)(sourceMap)
|
|
171
|
+
? [
|
|
172
|
+
...toBuffer(typeof sourceMap === "string"
|
|
173
|
+
? sourceMap
|
|
174
|
+
: JSON.stringify(sourceMap))
|
|
175
|
+
]
|
|
176
|
+
: sourceMap,
|
|
177
|
+
additionalData: !(0, utils_1.isNil)(additionalData)
|
|
178
|
+
? [...toBuffer(JSON.stringify(additionalData))]
|
|
179
|
+
: additionalData
|
|
74
180
|
};
|
|
75
181
|
return Buffer.from(JSON.stringify(loaderResultPayload), "utf-8");
|
|
76
182
|
}
|
|
77
183
|
loader.displayName = `NodeLoaderAdapter(${uses
|
|
78
184
|
.map(item => {
|
|
79
|
-
(0,
|
|
185
|
+
(0, assert_1.default)("loader" in item);
|
|
80
186
|
return item.loader.displayName || item.loader.name || "unknown-loader";
|
|
81
187
|
})
|
|
82
188
|
.join(" -> ")})`;
|
|
@@ -106,7 +212,7 @@ function createRawModuleRuleUsesImpl(uses, options) {
|
|
|
106
212
|
}
|
|
107
213
|
function createNativeUse(use) {
|
|
108
214
|
var _a;
|
|
109
|
-
(0,
|
|
215
|
+
(0, assert_1.default)("builtinLoader" in use);
|
|
110
216
|
if (use.builtinLoader === "sass-loader") {
|
|
111
217
|
((_a = use.options) !== null && _a !== void 0 ? _a : (use.options = {})).__exePath = require.resolve(`@tmp-sass-embedded/${process.platform}-${process.arch}/dart-sass-embedded/dart-sass-embedded${process.platform === "win32" ? ".bat" : ""}`);
|
|
112
218
|
}
|
|
@@ -115,13 +221,58 @@ function createNativeUse(use) {
|
|
|
115
221
|
options: JSON.stringify(use.options)
|
|
116
222
|
};
|
|
117
223
|
}
|
|
224
|
+
function resolveModuleRuleCondition(condition) {
|
|
225
|
+
if (typeof condition === "string") {
|
|
226
|
+
return {
|
|
227
|
+
type: "string",
|
|
228
|
+
matcher: condition
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
if (condition instanceof RegExp) {
|
|
232
|
+
return {
|
|
233
|
+
type: "regexp",
|
|
234
|
+
matcher: condition.source
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
throw new Error(`Unsupported condition type ${typeof condition}, value: ${condition}`);
|
|
238
|
+
}
|
|
239
|
+
function resolveModuleRuleConditions(conditions) {
|
|
240
|
+
return conditions.map(resolveModuleRuleCondition);
|
|
241
|
+
}
|
|
118
242
|
function resolveModuleOptions(module = {}, options) {
|
|
119
243
|
var _a;
|
|
120
|
-
const rules = ((_a = module.rules) !== null && _a !== void 0 ? _a : []).map(rule =>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
244
|
+
const rules = ((_a = module.rules) !== null && _a !== void 0 ? _a : []).map(rule => {
|
|
245
|
+
// FIXME: use error handler instead of throwing
|
|
246
|
+
if (rule === null || rule === void 0 ? void 0 : rule.loader) {
|
|
247
|
+
throw new Error("`Rule.loader` is not supported, use `Rule.use` instead");
|
|
248
|
+
}
|
|
249
|
+
if (rule === null || rule === void 0 ? void 0 : rule.uses) {
|
|
250
|
+
throw new Error("`Rule.uses` is deprecated for aligning with webpack, use `Rule.use` instead");
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
...rule,
|
|
254
|
+
test: (0, utils_1.isNil)(rule.test) ? null : resolveModuleRuleCondition(rule.test),
|
|
255
|
+
include: (0, utils_1.isNil)(rule.include)
|
|
256
|
+
? null
|
|
257
|
+
: Array.isArray(rule.include)
|
|
258
|
+
? resolveModuleRuleConditions(rule.include)
|
|
259
|
+
: [resolveModuleRuleCondition(rule.include)],
|
|
260
|
+
exclude: (0, utils_1.isNil)(rule.exclude)
|
|
261
|
+
? null
|
|
262
|
+
: Array.isArray(rule.exclude)
|
|
263
|
+
? resolveModuleRuleConditions(rule.exclude)
|
|
264
|
+
: [resolveModuleRuleCondition(rule.exclude)],
|
|
265
|
+
resource: (0, utils_1.isNil)(rule.resource)
|
|
266
|
+
? null
|
|
267
|
+
: resolveModuleRuleCondition(rule.resource),
|
|
268
|
+
resourceQuery: (0, utils_1.isNil)(rule.resourceQuery)
|
|
269
|
+
? null
|
|
270
|
+
: resolveModuleRuleCondition(rule.resourceQuery),
|
|
271
|
+
use: createRawModuleRuleUses(rule.use || [], options)
|
|
272
|
+
};
|
|
273
|
+
});
|
|
124
274
|
return {
|
|
275
|
+
parser: module.parser,
|
|
125
276
|
rules
|
|
126
277
|
};
|
|
127
278
|
}
|