@rspack/core 0.0.15 → 0.0.16
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/ResolverFactory.d.ts +49 -0
- package/dist/ResolverFactory.d.ts.map +1 -0
- package/dist/ResolverFactory.js +117 -0
- package/dist/ResolverFactory.js.map +1 -0
- package/dist/compilation.d.ts +7 -3
- package/dist/compilation.d.ts.map +1 -1
- package/dist/compilation.js +18 -12
- package/dist/compilation.js.map +1 -1
- package/dist/compiler.d.ts +3 -0
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +3 -0
- package/dist/compiler.js.map +1 -1
- package/dist/config/cache.d.ts.map +1 -1
- package/dist/config/cache.js +3 -4
- package/dist/config/cache.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +105 -4
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/devtool.d.ts +1 -0
- package/dist/config/devtool.d.ts.map +1 -1
- package/dist/config/devtool.js +5 -1
- package/dist/config/devtool.js.map +1 -1
- package/dist/config/index.d.ts +10 -7
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +10 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/module.d.ts +38 -3
- package/dist/config/module.d.ts.map +1 -1
- package/dist/config/module.js +209 -47
- package/dist/config/module.js.map +1 -1
- package/dist/config/node.d.ts +9 -0
- package/dist/config/node.d.ts.map +1 -0
- package/dist/config/node.js +15 -0
- package/dist/config/node.js.map +1 -0
- package/dist/config/optimization.d.ts +5 -0
- package/dist/config/optimization.d.ts.map +1 -1
- package/dist/config/optimization.js +3 -1
- package/dist/config/optimization.js.map +1 -1
- package/dist/config/plugin.d.ts +1 -1
- package/dist/config/plugin.d.ts.map +1 -1
- package/dist/config/target.js +1 -1
- package/dist/config/target.js.map +1 -1
- package/dist/node/NodeEnvironmentPlugin.d.ts +27 -0
- package/dist/node/NodeEnvironmentPlugin.d.ts.map +1 -0
- package/dist/node/NodeEnvironmentPlugin.js +54 -0
- package/dist/node/NodeEnvironmentPlugin.js.map +1 -0
- package/dist/rspack.d.ts.map +1 -1
- package/dist/rspack.js +6 -15
- package/dist/rspack.js.map +1 -1
- package/dist/rspackOptionsApply.d.ts.map +1 -1
- package/dist/rspackOptionsApply.js +29 -0
- package/dist/rspackOptionsApply.js.map +1 -1
- package/dist/stats.d.ts +1 -0
- package/dist/stats.d.ts.map +1 -1
- package/dist/stats.js +3 -0
- package/dist/stats.js.map +1 -1
- package/dist/util/cleverMerge.d.ts +79 -0
- package/dist/util/cleverMerge.d.ts.map +1 -0
- package/dist/util/cleverMerge.js +531 -0
- package/dist/util/cleverMerge.js.map +1 -0
- package/dist/util/createHash.d.ts +7 -0
- package/dist/util/createHash.d.ts.map +1 -0
- package/dist/util/createHash.js +166 -0
- package/dist/util/createHash.js.map +1 -0
- package/dist/util/createSource.d.ts +6 -0
- package/dist/util/createSource.d.ts.map +1 -0
- package/dist/util/createSource.js +48 -0
- package/dist/util/createSource.js.map +1 -0
- package/dist/util/hash/BatchedHash.d.ts +16 -0
- package/dist/util/hash/BatchedHash.d.ts.map +1 -0
- package/dist/util/hash/BatchedHash.js +61 -0
- package/dist/util/hash/BatchedHash.js.map +1 -0
- package/dist/util/hash/index.d.ts +19 -0
- package/dist/util/hash/index.d.ts.map +1 -0
- package/dist/util/hash/index.js +28 -0
- package/dist/util/hash/index.js.map +1 -0
- package/dist/util/hash/md4.d.ts +3 -0
- package/dist/util/hash/md4.d.ts.map +1 -0
- package/dist/util/hash/md4.js +13 -0
- package/dist/util/hash/md4.js.map +1 -0
- package/dist/util/hash/wasm-hash.d.ts +7 -0
- package/dist/util/hash/wasm-hash.d.ts.map +1 -0
- package/dist/util/hash/wasm-hash.js +162 -0
- package/dist/util/hash/wasm-hash.js.map +1 -0
- package/dist/util/hash/xxhash64.d.ts +3 -0
- package/dist/util/hash/xxhash64.d.ts.map +1 -0
- package/dist/util/hash/xxhash64.js +13 -0
- package/dist/util/hash/xxhash64.js.map +1 -0
- package/dist/util/identifier.d.ts +77 -0
- package/dist/util/identifier.d.ts.map +1 -0
- package/dist/util/identifier.js +345 -0
- package/dist/util/identifier.js.map +1 -0
- package/dist/util/index.d.ts +6 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js +18 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/memoize.d.ts +2 -0
- package/dist/util/memoize.d.ts.map +1 -0
- package/dist/util/memoize.js +22 -0
- package/dist/util/memoize.js.map +1 -0
- package/package.json +25 -13
- package/dist/bundle.js +0 -1
- package/dist/dd.js +0 -1
- package/dist/dynamic_js.xxxx.js +0 -1
- package/dist/main.js +0 -1
- package/dist/main.xxxx.js +0 -1
- package/dist/runtime.js +0 -1
- package/dist/web/polyfillBuiltins.d.ts +0 -5
- package/dist/web/polyfillBuiltins.d.ts.map +0 -1
- package/dist/web/polyfillBuiltins.js +0 -43
- package/dist/web/polyfillBuiltins.js.map +0 -1
package/dist/config/devtool.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUseSourceMap = exports.resolveDevtoolOptions = void 0;
|
|
3
|
+
exports.isUseSimpleSourceMap = exports.isUseSourceMap = exports.resolveDevtoolOptions = void 0;
|
|
4
4
|
function resolveDevtoolOptions(devtool = false) {
|
|
5
5
|
return devtool === false ? "" : devtool;
|
|
6
6
|
}
|
|
@@ -10,4 +10,8 @@ function isUseSourceMap(devtool) {
|
|
|
10
10
|
(devtool.includes("module") || !devtool.includes("cheap")));
|
|
11
11
|
}
|
|
12
12
|
exports.isUseSourceMap = isUseSourceMap;
|
|
13
|
+
function isUseSimpleSourceMap(devtool) {
|
|
14
|
+
return devtool.includes("source-map") && !isUseSourceMap(devtool);
|
|
15
|
+
}
|
|
16
|
+
exports.isUseSimpleSourceMap = isUseSimpleSourceMap;
|
|
13
17
|
//# sourceMappingURL=devtool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtool.js","sourceRoot":"","sources":["../../src/config/devtool.ts"],"names":[],"mappings":";;;AA6BA,SAAgB,qBAAqB,CACpC,UAAmB,KAAK;IAExB,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACzC,CAAC;AAJD,sDAIC;AAED,SAAgB,cAAc,CAAC,OAAwB;IACtD,OAAO,CACN,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC9B,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAC1D,CAAC;AACH,CAAC;AALD,wCAKC"}
|
|
1
|
+
{"version":3,"file":"devtool.js","sourceRoot":"","sources":["../../src/config/devtool.ts"],"names":[],"mappings":";;;AA6BA,SAAgB,qBAAqB,CACpC,UAAmB,KAAK;IAExB,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACzC,CAAC;AAJD,sDAIC;AAED,SAAgB,cAAc,CAAC,OAAwB;IACtD,OAAO,CACN,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC9B,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAC1D,CAAC;AACH,CAAC;AALD,wCAKC;AAED,SAAgB,oBAAoB,CAAC,OAAwB;IAC5D,OAAO,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC;AAFD,oDAEC"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ 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, Loader, SourceMap } from "./module";
|
|
7
|
-
import type {
|
|
6
|
+
import type { Module, ResolvedModule, LoaderContext, Loader, SourceMap, GetCompiler } from "./module";
|
|
7
|
+
import type { PluginInstance } 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";
|
|
@@ -15,13 +15,14 @@ import { Devtool, ResolvedDevtool } from "./devtool";
|
|
|
15
15
|
import { InfrastructureLogging } from "./RspackOptions";
|
|
16
16
|
import { ResolvedStatsOptions, StatsOptions } from "./stats";
|
|
17
17
|
import { Optimization, ResolvedOptimization } from "./optimization";
|
|
18
|
-
import { RawExperiments } from "@rspack/binding";
|
|
18
|
+
import { RawExperiments, RawNodeOption } from "@rspack/binding";
|
|
19
|
+
import { NodeOptions } from "./node";
|
|
19
20
|
export declare type Configuration = RspackOptions;
|
|
20
21
|
export interface RspackOptions {
|
|
21
22
|
name?: string;
|
|
22
23
|
entry?: Entry;
|
|
23
24
|
context?: Context;
|
|
24
|
-
plugins?:
|
|
25
|
+
plugins?: PluginInstance[];
|
|
25
26
|
devServer?: Dev;
|
|
26
27
|
module?: Module;
|
|
27
28
|
target?: Target;
|
|
@@ -38,12 +39,13 @@ export interface RspackOptions {
|
|
|
38
39
|
cache?: Cache;
|
|
39
40
|
optimization?: Optimization;
|
|
40
41
|
experiments?: RawExperiments;
|
|
42
|
+
node?: NodeOptions;
|
|
41
43
|
}
|
|
42
44
|
export interface RspackOptionsNormalized {
|
|
43
45
|
name?: string;
|
|
44
46
|
entry: ResolvedEntry;
|
|
45
47
|
context: ResolvedContext;
|
|
46
|
-
plugins:
|
|
48
|
+
plugins: PluginInstance[];
|
|
47
49
|
devServer?: Dev;
|
|
48
50
|
module: ResolvedModule;
|
|
49
51
|
target: ResolvedTarget;
|
|
@@ -60,9 +62,10 @@ export interface RspackOptionsNormalized {
|
|
|
60
62
|
cache: ResolvedCache;
|
|
61
63
|
optimization?: ResolvedOptimization;
|
|
62
64
|
experiments: RawExperiments;
|
|
65
|
+
node: RawNodeOption;
|
|
63
66
|
}
|
|
64
|
-
export declare function getNormalizedRspackOptions(config: RspackOptions): RspackOptionsNormalized;
|
|
65
|
-
export type { Plugin, LoaderContext, Loader, SourceMap };
|
|
67
|
+
export declare function getNormalizedRspackOptions(config: RspackOptions, getCompiler: GetCompiler): RspackOptionsNormalized;
|
|
68
|
+
export type { PluginInstance as Plugin, LoaderContext, Loader, SourceMap };
|
|
66
69
|
export type { WebSocketServerOptions, Dev } from "./devServer";
|
|
67
70
|
export { resolveWatchOption } from "./watch";
|
|
68
71
|
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,EACX,MAAM,EACN,cAAc,EACd,aAAa,EACb,MAAM,EACN,SAAS,EACT,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAA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QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,eAAe,CAAC;IACzB,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,KAAK,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,WAAW,EAAE,cAAc,CAAC;IAC5B,IAAI,EAAE,aAAa,CAAC;CACpB;AAED,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,WAAW,GACtB,uBAAuB,CA0DzB;AAKD,YAAY,EAAE,cAAc,IAAI,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC3E,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
|
@@ -13,7 +13,8 @@ const cache_1 = require("./cache");
|
|
|
13
13
|
const stats_1 = require("./stats");
|
|
14
14
|
const optimization_1 = require("./optimization");
|
|
15
15
|
const experiments_1 = require("./experiments");
|
|
16
|
-
|
|
16
|
+
const node_1 = require("./node");
|
|
17
|
+
function getNormalizedRspackOptions(config, getCompiler) {
|
|
17
18
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
19
|
const context = (_a = config.context) !== null && _a !== void 0 ? _a : process.cwd();
|
|
19
20
|
const mode = (_b = config.mode) !== null && _b !== void 0 ? _b : "production";
|
|
@@ -31,13 +32,18 @@ function getNormalizedRspackOptions(config) {
|
|
|
31
32
|
});
|
|
32
33
|
const resolve = (0, resolve_1.resolveResolveOptions)(config.resolve, { target });
|
|
33
34
|
const devtool = (0, devtool_1.resolveDevtoolOptions)(config.devtool);
|
|
34
|
-
const module = (0, module_1.resolveModuleOptions)(config.module, {
|
|
35
|
+
const module = (0, module_1.resolveModuleOptions)(config.module, {
|
|
36
|
+
devtool,
|
|
37
|
+
context,
|
|
38
|
+
getCompiler
|
|
39
|
+
});
|
|
35
40
|
const stats = (0, stats_1.resolveStatsOptions)(config.stats);
|
|
36
41
|
const devServer = config.devServer;
|
|
37
42
|
const snapshot = (0, snapshot_1.resolveSnapshotOptions)(config.snapshot);
|
|
38
43
|
const cache = (0, cache_1.resolveCacheOptions)((_f = config.cache) !== null && _f !== void 0 ? _f : (mode === "production" ? false : true));
|
|
39
44
|
const optimization = (0, optimization_1.resolveOptimizationOptions)((_g = config.optimization) !== null && _g !== void 0 ? _g : {}, mode);
|
|
40
45
|
const experiments = (0, experiments_1.resolveExperiments)(config.experiments);
|
|
46
|
+
const node = (0, node_1.resolveNode)(config.node);
|
|
41
47
|
return {
|
|
42
48
|
...config,
|
|
43
49
|
context,
|
|
@@ -58,7 +64,8 @@ function getNormalizedRspackOptions(config) {
|
|
|
58
64
|
snapshot,
|
|
59
65
|
cache,
|
|
60
66
|
optimization,
|
|
61
|
-
experiments
|
|
67
|
+
experiments,
|
|
68
|
+
node
|
|
62
69
|
};
|
|
63
70
|
}
|
|
64
71
|
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;AAuB9C,uCAA4E;AAC5E,qCAAgD;AAChD,qCAAgD;AAChD,qCAAgD;AAChD,yCAAoD;AACpD,uCAAkD;AAClD,yCAAoD;AACpD,mCAA8C;AAE9C,mCAIiB;AACjB,iDAIwB;AAExB,+CAAmD;AACnD,iCAAkD;AAkDlD,SAAgB,0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AAG,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;IACF,MAAM,YAAY,GAAG,IAAA,yCAA0B,EAC9C,MAAA,MAAM,CAAC,YAAY,mCAAI,EAAE,EACzB,IAAI,CACJ,CAAC;IACF,MAAM,WAAW,GAAG,IAAA,gCAAkB,EAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,IAAA,kBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEtC,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;QACL,YAAY;QACZ,WAAW;QACX,IAAI;KACJ,CAAC;AACH,CAAC;AA7DD,gEA6DC;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,7 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { RawModuleRuleUse, RawModuleRule, RawModuleOptions } from "@rspack/binding";
|
|
2
|
+
import type { RawModuleRuleUse, RawModuleRule, RawModuleOptions, JsAssetInfo } from "@rspack/binding";
|
|
3
|
+
import { ResolveRequest } from "enhanced-resolve";
|
|
4
|
+
import { Compiler } from "../compiler";
|
|
5
|
+
import { Logger } from "../logging/Logger";
|
|
6
|
+
import { ResolveOptions } from "../ResolverFactory";
|
|
7
|
+
import Hash from "../util/hash";
|
|
3
8
|
import { ResolvedContext } from "./context";
|
|
4
9
|
import { ResolvedDevtool } from "./devtool";
|
|
10
|
+
import { ResolvedMode } from "./mode";
|
|
5
11
|
export declare type Condition = string | RegExp;
|
|
6
12
|
export interface ModuleRule {
|
|
7
13
|
name?: string;
|
|
@@ -39,19 +45,45 @@ interface LoaderContextInternal {
|
|
|
39
45
|
resourceQuery: string | null;
|
|
40
46
|
resourceFragment: string | null;
|
|
41
47
|
cacheable: boolean;
|
|
48
|
+
buildDependencies: string[];
|
|
42
49
|
}
|
|
43
50
|
export interface LoaderContext extends Pick<LoaderContextInternal, "resource" | "resourcePath" | "resourceQuery" | "resourceFragment"> {
|
|
51
|
+
version: 2;
|
|
44
52
|
async(): (err: Error | null, content: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => void;
|
|
45
53
|
callback(err: Error | null, content: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData): void;
|
|
46
54
|
cacheable(cacheable: boolean): void;
|
|
47
55
|
sourceMap: boolean;
|
|
48
56
|
rootContext: string;
|
|
49
57
|
context: string;
|
|
50
|
-
|
|
58
|
+
loaderIndex: number;
|
|
59
|
+
mode: ResolvedMode;
|
|
60
|
+
hot?: boolean;
|
|
61
|
+
getOptions(schema?: any): unknown;
|
|
62
|
+
resolve(context: string, request: string, callback: (arg0: null | Error, arg1?: string | false, arg2?: ResolveRequest) => void): void;
|
|
63
|
+
getResolve(options: ResolveOptions): (context: any, request: any, callback: any) => Promise<any>;
|
|
64
|
+
getLogger(name: string): Logger;
|
|
65
|
+
emitError(error: Error): void;
|
|
66
|
+
emitWarning(warning: Error): void;
|
|
67
|
+
emitFile(name: string, content: string | Buffer, sourceMap?: string, assetInfo?: JsAssetInfo): void;
|
|
68
|
+
addDependency(file: string): void;
|
|
69
|
+
addContextDependency(context: string): void;
|
|
70
|
+
addMissingDependency(missing: string): void;
|
|
71
|
+
clearDependencies(): void;
|
|
72
|
+
addBuildDependency(file: string): void;
|
|
73
|
+
fs: any;
|
|
74
|
+
utils: {
|
|
75
|
+
absolutify: (context: string, request: string) => string;
|
|
76
|
+
contextify: (context: string, request: string) => string;
|
|
77
|
+
createHash: (algorithm?: string) => Hash;
|
|
78
|
+
};
|
|
79
|
+
query: unknown;
|
|
80
|
+
data: unknown;
|
|
51
81
|
}
|
|
82
|
+
export declare type GetCompiler = () => Compiler;
|
|
52
83
|
export interface ComposeJsUseOptions {
|
|
53
84
|
devtool: ResolvedDevtool;
|
|
54
85
|
context: ResolvedContext;
|
|
86
|
+
getCompiler: GetCompiler;
|
|
55
87
|
}
|
|
56
88
|
export interface SourceMap {
|
|
57
89
|
version: number;
|
|
@@ -67,6 +99,7 @@ export interface AdditionalData {
|
|
|
67
99
|
}
|
|
68
100
|
export interface LoaderResult {
|
|
69
101
|
cacheable: boolean;
|
|
102
|
+
buildDependencies?: string[];
|
|
70
103
|
content: string | Buffer;
|
|
71
104
|
sourceMap?: string | SourceMap;
|
|
72
105
|
additionalData?: AdditionalData;
|
|
@@ -82,9 +115,11 @@ declare type ModuleRuleUse = {
|
|
|
82
115
|
options?: unknown;
|
|
83
116
|
name?: string;
|
|
84
117
|
} | {
|
|
85
|
-
loader: Loader;
|
|
118
|
+
loader: Loader | string;
|
|
86
119
|
options?: unknown;
|
|
87
120
|
name?: string;
|
|
121
|
+
query?: string;
|
|
122
|
+
data?: unknown;
|
|
88
123
|
};
|
|
89
124
|
export declare function createRawModuleRuleUses(uses: ModuleRuleUse[], options: ComposeJsUseOptions): RawModuleRuleUse[];
|
|
90
125
|
export declare function resolveModuleOptions(module: Module, options: ComposeJsUseOptions): ResolvedModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/config/module.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACX,gBAAgB,EA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AChC;AAmZD,MAAM,WAAW,MAAM;IACtB,CACC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,EAC9B,cAAc,CAAC,EAAE,cAAc,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;IAEA,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CACd,CAAC;AAEL,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,aAAa,EAAE,EACrB,OAAO,EAAE,mBAAmB,GAC1B,gBAAgB,EAAE,CAGpB;AAuED,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,MAAW,EACnB,OAAO,EAAE,mBAAmB,GAC1B,cAAc,CAuChB"}
|
package/dist/config/module.js
CHANGED
|
@@ -6,7 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.resolveModuleOptions = exports.createRawModuleRuleUses = void 0;
|
|
7
7
|
const assert_1 = __importDefault(require("assert"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const
|
|
9
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
10
|
+
const util_1 = require("../util");
|
|
11
|
+
const createHash_1 = require("../util/createHash");
|
|
12
|
+
const identifier_1 = require("../util/identifier");
|
|
13
|
+
const memoize_1 = require("../util/memoize");
|
|
10
14
|
const devtool_1 = require("./devtool");
|
|
11
15
|
const toBuffer = (bufLike) => {
|
|
12
16
|
if (Buffer.isBuffer(bufLike)) {
|
|
@@ -17,19 +21,26 @@ const toBuffer = (bufLike) => {
|
|
|
17
21
|
}
|
|
18
22
|
throw new Error("Buffer or string expected");
|
|
19
23
|
};
|
|
20
|
-
function composeJsUse(uses, options) {
|
|
24
|
+
function composeJsUse(uses, options, allUses) {
|
|
21
25
|
if (!uses.length) {
|
|
22
26
|
return null;
|
|
23
27
|
}
|
|
24
28
|
async function loader(data) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let
|
|
29
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
|
+
const compiler = options.getCompiler();
|
|
31
|
+
const resolver = compiler.resolverFactory.get("normal");
|
|
32
|
+
const moduleContext = path_1.default.dirname(data.resourcePath);
|
|
33
|
+
let cacheable = data.cacheable;
|
|
34
|
+
let buildDependencies = data.buildDependencies;
|
|
35
|
+
let content = data.content;
|
|
36
|
+
let sourceMap = (_a = data.sourceMap) === null || _a === void 0 ? void 0 : _a.toString("utf-8");
|
|
37
|
+
let additionalData = data.additionalData
|
|
38
|
+
? JSON.parse(data.additionalData.toString("utf-8"))
|
|
39
|
+
: undefined;
|
|
30
40
|
// Loader is executed from right to left
|
|
31
41
|
for (const use of uses) {
|
|
32
42
|
(0, assert_1.default)("loader" in use);
|
|
43
|
+
const loaderIndex = allUses.indexOf(use);
|
|
33
44
|
let loaderResult;
|
|
34
45
|
const p = new Promise((resolve, reject) => {
|
|
35
46
|
let isDone = false;
|
|
@@ -57,15 +68,100 @@ function composeJsUse(uses, options) {
|
|
|
57
68
|
additionalData
|
|
58
69
|
});
|
|
59
70
|
}
|
|
71
|
+
const getResolveContext = () => {
|
|
72
|
+
return {
|
|
73
|
+
fileDependencies: {
|
|
74
|
+
add: d => loaderContext.addDependency(d)
|
|
75
|
+
},
|
|
76
|
+
contextDependencies: {
|
|
77
|
+
add: d => loaderContext.addContextDependency(d)
|
|
78
|
+
},
|
|
79
|
+
missingDependencies: {
|
|
80
|
+
add: d => loaderContext.addMissingDependency(d)
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
const getAbsolutify = (0, memoize_1.memoize)(() => identifier_1.absolutify.bindCache(compiler.root));
|
|
85
|
+
const getAbsolutifyInContext = (0, memoize_1.memoize)(() => identifier_1.absolutify.bindContextCache(moduleContext, compiler.root));
|
|
86
|
+
const getContextify = (0, memoize_1.memoize)(() => identifier_1.contextify.bindCache(compiler.root));
|
|
87
|
+
const getContextifyInContext = (0, memoize_1.memoize)(() => identifier_1.contextify.bindContextCache(moduleContext, compiler.root));
|
|
88
|
+
const utils = {
|
|
89
|
+
absolutify: (context, request) => {
|
|
90
|
+
return context === moduleContext
|
|
91
|
+
? getAbsolutifyInContext()(request)
|
|
92
|
+
: getAbsolutify()(context, request);
|
|
93
|
+
},
|
|
94
|
+
contextify: (context, request) => {
|
|
95
|
+
return context === moduleContext
|
|
96
|
+
? getContextifyInContext()(request)
|
|
97
|
+
: getContextify()(context, request);
|
|
98
|
+
},
|
|
99
|
+
createHash: type => {
|
|
100
|
+
return (0, createHash_1.createHash)(type || compiler.compilation.outputOptions.hashFunction);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
60
103
|
const loaderContext = {
|
|
104
|
+
version: 2,
|
|
61
105
|
sourceMap: (0, devtool_1.isUseSourceMap)(options.devtool),
|
|
62
|
-
resourcePath:
|
|
63
|
-
resource:
|
|
106
|
+
resourcePath: data.resourcePath,
|
|
107
|
+
resource: data.resource,
|
|
64
108
|
// Return an empty string if there is no query or fragment
|
|
65
|
-
resourceQuery:
|
|
66
|
-
resourceFragment:
|
|
67
|
-
|
|
68
|
-
|
|
109
|
+
resourceQuery: data.resourceQuery || "",
|
|
110
|
+
resourceFragment: data.resourceFragment || "",
|
|
111
|
+
loaderIndex,
|
|
112
|
+
mode: compiler.options.mode,
|
|
113
|
+
hot: compiler.options.devServer.hot,
|
|
114
|
+
getOptions(schema) {
|
|
115
|
+
let { options } = use;
|
|
116
|
+
if (options === null || options === undefined) {
|
|
117
|
+
options = {};
|
|
118
|
+
}
|
|
119
|
+
if (schema) {
|
|
120
|
+
let name = "Loader";
|
|
121
|
+
let baseDataPath = "options";
|
|
122
|
+
let match;
|
|
123
|
+
if (schema.title && (match = /^(.+) (.+)$/.exec(schema.title))) {
|
|
124
|
+
[, name, baseDataPath] = match;
|
|
125
|
+
}
|
|
126
|
+
const { validate } = require("schema-utils");
|
|
127
|
+
validate(schema, options, {
|
|
128
|
+
name,
|
|
129
|
+
baseDataPath
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return options;
|
|
133
|
+
},
|
|
134
|
+
get query() {
|
|
135
|
+
return use.options && typeof use.options === "object"
|
|
136
|
+
? use.options
|
|
137
|
+
: use.query;
|
|
138
|
+
},
|
|
139
|
+
get data() {
|
|
140
|
+
return use.data;
|
|
141
|
+
},
|
|
142
|
+
resolve(context, request, callback) {
|
|
143
|
+
resolver.resolve({}, context, request, getResolveContext(), callback);
|
|
144
|
+
},
|
|
145
|
+
getResolve(options) {
|
|
146
|
+
const child = options ? resolver.withOptions(options) : resolver;
|
|
147
|
+
return (context, request, callback) => {
|
|
148
|
+
if (callback) {
|
|
149
|
+
child.resolve({}, context, request, getResolveContext(), callback);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
|
+
child.resolve({}, context, request, getResolveContext(), (err, result) => {
|
|
154
|
+
if (err)
|
|
155
|
+
reject(err);
|
|
156
|
+
else
|
|
157
|
+
resolve(result);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
getLogger(name) {
|
|
164
|
+
return compiler.getInfrastructureLogger(() => [name, data.resource].filter(Boolean).join("|"));
|
|
69
165
|
},
|
|
70
166
|
cacheable(value) {
|
|
71
167
|
cacheable = value;
|
|
@@ -81,27 +177,75 @@ function composeJsUse(uses, options) {
|
|
|
81
177
|
},
|
|
82
178
|
callback,
|
|
83
179
|
rootContext: options.context,
|
|
84
|
-
context:
|
|
180
|
+
context: moduleContext,
|
|
181
|
+
emitError(error) {
|
|
182
|
+
const title = "Module Error";
|
|
183
|
+
const message = error instanceof Error
|
|
184
|
+
? `${error.message}${error.stack ? `\n${error.stack}` : ""}`
|
|
185
|
+
: error;
|
|
186
|
+
compiler.compilation.pushDiagnostic("error", title, `${message}\n(from: ${use.loader})`);
|
|
187
|
+
},
|
|
188
|
+
emitWarning(warning) {
|
|
189
|
+
const title = "Module Warning";
|
|
190
|
+
const message = warning instanceof Error
|
|
191
|
+
? `${warning.message}${warning.stack ? `\n${warning.stack}` : ""}`
|
|
192
|
+
: warning;
|
|
193
|
+
compiler.compilation.pushDiagnostic("warning", title, `${message}\n(from: ${use.loader})`);
|
|
194
|
+
},
|
|
195
|
+
emitFile(name, content, sourceMap, assetInfo) {
|
|
196
|
+
let source;
|
|
197
|
+
if (sourceMap) {
|
|
198
|
+
if (typeof sourceMap === "string" &&
|
|
199
|
+
(loaderContext.sourceMap ||
|
|
200
|
+
(0, devtool_1.isUseSimpleSourceMap)(options.devtool))) {
|
|
201
|
+
source = new webpack_sources_1.OriginalSource(content, (0, identifier_1.makePathsRelative)(moduleContext, sourceMap, compiler));
|
|
202
|
+
}
|
|
203
|
+
if (this.useSourceMap) {
|
|
204
|
+
source = new webpack_sources_1.SourceMapSource(content, // webpack-sources type declaration is wrong
|
|
205
|
+
name, (0, identifier_1.makePathsRelative)(moduleContext, sourceMap, compiler) // webpack-sources type declaration is wrong
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
source = new webpack_sources_1.RawSource(content); // webpack-sources type declaration is wrong
|
|
211
|
+
}
|
|
212
|
+
compiler.compilation.emitAsset(name, source, assetInfo);
|
|
213
|
+
},
|
|
214
|
+
fs: compiler.inputFileSystem,
|
|
215
|
+
utils,
|
|
216
|
+
addBuildDependency(file) {
|
|
217
|
+
buildDependencies.push(file);
|
|
218
|
+
},
|
|
219
|
+
// Mock, we don't need to implement these since the dev-server use 'chokidar'
|
|
220
|
+
// to watch files under 'options.context'.
|
|
221
|
+
addDependency(file) { },
|
|
222
|
+
addContextDependency(context) { },
|
|
223
|
+
addMissingDependency(missing) { },
|
|
224
|
+
clearDependencies() { }
|
|
85
225
|
};
|
|
86
226
|
/**
|
|
87
227
|
* support loader as string
|
|
88
228
|
*/
|
|
229
|
+
let loader;
|
|
89
230
|
if (typeof use.loader === "string") {
|
|
90
231
|
try {
|
|
91
232
|
let loaderPath = require.resolve(use.loader, {
|
|
92
233
|
paths: [options.context]
|
|
93
234
|
});
|
|
94
|
-
|
|
235
|
+
loader = require(loaderPath);
|
|
95
236
|
}
|
|
96
237
|
catch (err) {
|
|
97
238
|
reject(err);
|
|
98
239
|
return;
|
|
99
240
|
}
|
|
100
241
|
}
|
|
242
|
+
else {
|
|
243
|
+
loader = use.loader;
|
|
244
|
+
}
|
|
101
245
|
let result = undefined;
|
|
102
246
|
try {
|
|
103
|
-
result =
|
|
104
|
-
|
|
247
|
+
result = loader.apply(loaderContext, [
|
|
248
|
+
loader.raw ? Buffer.from(content) : content.toString("utf-8"),
|
|
105
249
|
sourceMap,
|
|
106
250
|
additionalData
|
|
107
251
|
]);
|
|
@@ -110,16 +254,18 @@ function composeJsUse(uses, options) {
|
|
|
110
254
|
if (result === undefined) {
|
|
111
255
|
resolve({
|
|
112
256
|
content,
|
|
257
|
+
buildDependencies,
|
|
113
258
|
sourceMap,
|
|
114
259
|
additionalData,
|
|
115
260
|
cacheable
|
|
116
261
|
});
|
|
117
262
|
return;
|
|
118
263
|
}
|
|
119
|
-
if ((0,
|
|
264
|
+
if ((0, util_1.isPromiseLike)(result)) {
|
|
120
265
|
return result.then(function (result) {
|
|
121
266
|
resolve({
|
|
122
267
|
content: result,
|
|
268
|
+
buildDependencies,
|
|
123
269
|
sourceMap,
|
|
124
270
|
additionalData,
|
|
125
271
|
cacheable
|
|
@@ -128,6 +274,7 @@ function composeJsUse(uses, options) {
|
|
|
128
274
|
}
|
|
129
275
|
return resolve({
|
|
130
276
|
content: result,
|
|
277
|
+
buildDependencies,
|
|
131
278
|
sourceMap,
|
|
132
279
|
additionalData,
|
|
133
280
|
cacheable
|
|
@@ -156,34 +303,48 @@ function composeJsUse(uses, options) {
|
|
|
156
303
|
});
|
|
157
304
|
if ((loaderResult = await p)) {
|
|
158
305
|
additionalData =
|
|
159
|
-
(typeof loaderResult.additionalData === "string"
|
|
306
|
+
(_b = (typeof loaderResult.additionalData === "string"
|
|
160
307
|
? JSON.parse(loaderResult.additionalData)
|
|
161
|
-
: loaderResult.additionalData)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
308
|
+
: loaderResult.additionalData)) !== null && _b !== void 0 ? _b : additionalData;
|
|
309
|
+
buildDependencies = (_c = loaderResult.buildDependencies) !== null && _c !== void 0 ? _c : buildDependencies;
|
|
310
|
+
content = (_d = loaderResult.content) !== null && _d !== void 0 ? _d : content;
|
|
311
|
+
sourceMap = (_e = loaderResult.sourceMap) !== null && _e !== void 0 ? _e : sourceMap;
|
|
312
|
+
cacheable = (_f = loaderResult.cacheable) !== null && _f !== void 0 ? _f : cacheable;
|
|
165
313
|
}
|
|
166
314
|
}
|
|
167
|
-
|
|
315
|
+
return {
|
|
168
316
|
cacheable: cacheable,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
: additionalData
|
|
317
|
+
buildDependencies: buildDependencies,
|
|
318
|
+
content: toBuffer(content),
|
|
319
|
+
sourceMap: sourceMap
|
|
320
|
+
? toBuffer(typeof sourceMap === "string"
|
|
321
|
+
? sourceMap
|
|
322
|
+
: JSON.stringify(sourceMap))
|
|
323
|
+
: undefined,
|
|
324
|
+
additionalData: additionalData
|
|
325
|
+
? toBuffer(JSON.stringify(additionalData))
|
|
326
|
+
: undefined
|
|
180
327
|
};
|
|
181
|
-
return Buffer.from(JSON.stringify(loaderResultPayload), "utf-8");
|
|
182
328
|
}
|
|
183
329
|
loader.displayName = `NodeLoaderAdapter(${uses
|
|
184
330
|
.map(item => {
|
|
185
331
|
(0, assert_1.default)("loader" in item);
|
|
186
|
-
|
|
332
|
+
let loader;
|
|
333
|
+
if (typeof item.loader === "string") {
|
|
334
|
+
try {
|
|
335
|
+
const path = require.resolve(item.loader, {
|
|
336
|
+
paths: [options.context]
|
|
337
|
+
});
|
|
338
|
+
loader = require(path);
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
loader = null;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
loader = item.loader;
|
|
346
|
+
}
|
|
347
|
+
return (loader === null || loader === void 0 ? void 0 : loader.displayName) || (loader === null || loader === void 0 ? void 0 : loader.name) || "unknown-loader";
|
|
187
348
|
})
|
|
188
349
|
.join(" -> ")})`;
|
|
189
350
|
return {
|
|
@@ -191,23 +352,24 @@ function composeJsUse(uses, options) {
|
|
|
191
352
|
};
|
|
192
353
|
}
|
|
193
354
|
function createRawModuleRuleUses(uses, options) {
|
|
194
|
-
|
|
355
|
+
const allUses = [...uses].reverse();
|
|
356
|
+
return createRawModuleRuleUsesImpl(allUses, options, allUses);
|
|
195
357
|
}
|
|
196
358
|
exports.createRawModuleRuleUses = createRawModuleRuleUses;
|
|
197
|
-
function createRawModuleRuleUsesImpl(uses, options) {
|
|
359
|
+
function createRawModuleRuleUsesImpl(uses, options, allUses) {
|
|
198
360
|
if (!uses.length) {
|
|
199
361
|
return [];
|
|
200
362
|
}
|
|
201
363
|
const index = uses.findIndex(use => "builtinLoader" in use);
|
|
202
364
|
if (index < 0) {
|
|
203
|
-
return [composeJsUse(uses, options)];
|
|
365
|
+
return [composeJsUse(uses, options, allUses)];
|
|
204
366
|
}
|
|
205
367
|
const before = uses.slice(0, index);
|
|
206
368
|
const after = uses.slice(index + 1);
|
|
207
369
|
return [
|
|
208
|
-
composeJsUse(before, options),
|
|
370
|
+
composeJsUse(before, options, allUses),
|
|
209
371
|
createNativeUse(uses[index]),
|
|
210
|
-
...createRawModuleRuleUsesImpl(after, options)
|
|
372
|
+
...createRawModuleRuleUsesImpl(after, options, allUses)
|
|
211
373
|
].filter((item) => Boolean(item));
|
|
212
374
|
}
|
|
213
375
|
function createNativeUse(use) {
|
|
@@ -251,21 +413,21 @@ function resolveModuleOptions(module = {}, options) {
|
|
|
251
413
|
}
|
|
252
414
|
return {
|
|
253
415
|
...rule,
|
|
254
|
-
test: (0,
|
|
255
|
-
include: (0,
|
|
416
|
+
test: (0, util_1.isNil)(rule.test) ? null : resolveModuleRuleCondition(rule.test),
|
|
417
|
+
include: (0, util_1.isNil)(rule.include)
|
|
256
418
|
? null
|
|
257
419
|
: Array.isArray(rule.include)
|
|
258
420
|
? resolveModuleRuleConditions(rule.include)
|
|
259
421
|
: [resolveModuleRuleCondition(rule.include)],
|
|
260
|
-
exclude: (0,
|
|
422
|
+
exclude: (0, util_1.isNil)(rule.exclude)
|
|
261
423
|
? null
|
|
262
424
|
: Array.isArray(rule.exclude)
|
|
263
425
|
? resolveModuleRuleConditions(rule.exclude)
|
|
264
426
|
: [resolveModuleRuleCondition(rule.exclude)],
|
|
265
|
-
resource: (0,
|
|
427
|
+
resource: (0, util_1.isNil)(rule.resource)
|
|
266
428
|
? null
|
|
267
429
|
: resolveModuleRuleCondition(rule.resource),
|
|
268
|
-
resourceQuery: (0,
|
|
430
|
+
resourceQuery: (0, util_1.isNil)(rule.resourceQuery)
|
|
269
431
|
? null
|
|
270
432
|
: resolveModuleRuleCondition(rule.resourceQuery),
|
|
271
433
|
use: createRawModuleRuleUses(rule.use || [], options)
|