@rspack/core 0.7.5-canary-0d03907-20240624125011 → 0.7.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/dist/Chunk.d.ts +14 -19
- package/dist/Chunk.js +17 -22
- package/dist/ChunkGraph.d.ts +1 -1
- package/dist/ChunkGraph.js +5 -5
- package/dist/ChunkGroup.d.ts +7 -17
- package/dist/ChunkGroup.js +2 -12
- package/dist/Compilation.d.ts +22 -18
- package/dist/Compilation.js +43 -20
- package/dist/Compiler.js +2 -18
- package/dist/Entrypoint.d.ts +1 -1
- package/dist/Entrypoint.js +2 -2
- package/dist/Module.d.ts +6 -7
- package/dist/Module.js +0 -1
- package/dist/NormalModule.d.ts +1 -0
- package/dist/NormalModule.js +7 -0
- package/dist/NormalModuleFactory.js +22 -0
- package/dist/Stats.d.ts +2 -2
- package/dist/builtin-loader/swc/emotion.d.ts +17 -0
- package/dist/builtin-loader/swc/emotion.js +22 -0
- package/dist/builtin-loader/swc/index.d.ts +4 -0
- package/dist/builtin-loader/swc/index.js +5 -1
- package/dist/builtin-loader/swc/preact.d.ts +4 -3
- package/dist/builtin-loader/swc/relay.d.ts +5 -0
- package/dist/builtin-loader/swc/relay.js +48 -0
- package/dist/builtin-loader/swc/types.d.ts +17 -2
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +9 -15
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -50
- package/dist/builtin-plugin/css-extract/index.d.ts +2 -2
- package/dist/config/adapter.js +10 -23
- package/dist/config/adapterRuleUse.js +11 -0
- package/dist/config/defaults.js +0 -1
- package/dist/config/normalization.js +2 -12
- package/dist/config/zod.d.ts +10 -114
- package/dist/config/zod.js +6 -8
- package/dist/exports.d.ts +1 -2
- package/dist/exports.js +1 -4
- package/dist/loader-runner/index.js +6 -27
- package/dist/stats/DefaultStatsFactoryPlugin.js +2 -19
- package/dist/stats/DefaultStatsPrinterPlugin.js +2 -2
- package/dist/stats/statsFactoryUtils.d.ts +2 -4
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.js +3 -4
- package/dist/util/memoize.js +1 -5
- package/package.json +4 -8
- package/dist/RspackError.d.ts +0 -8
- package/dist/RspackError.js +0 -21
package/dist/Module.js
CHANGED
|
@@ -27,7 +27,6 @@ class Module {
|
|
|
27
27
|
this.request = module.request;
|
|
28
28
|
this.userRequest = module.userRequest;
|
|
29
29
|
this.rawRequest = module.rawRequest;
|
|
30
|
-
this.factoryMeta = module.factoryMeta;
|
|
31
30
|
const customModule = compilation?.__internal__getCustomModule(module.moduleIdentifier);
|
|
32
31
|
this.buildInfo = customModule?.buildInfo || {};
|
|
33
32
|
this.buildMeta = customModule?.buildMeta || {};
|
package/dist/NormalModule.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { AsyncSeriesBailHook, HookMap, SyncHook } from "tapable";
|
|
|
3
3
|
import { Compilation } from "./Compilation";
|
|
4
4
|
import { LoaderContext } from "./config";
|
|
5
5
|
export declare class NormalModule {
|
|
6
|
+
constructor();
|
|
6
7
|
static getCompilationHooks(compilation: Compilation): {
|
|
7
8
|
loader: SyncHook<[LoaderContext<{}>], void, import("tapable").UnsetAdditionalOptions>;
|
|
8
9
|
readResourceForScheme: any;
|
package/dist/NormalModule.js
CHANGED
|
@@ -46,7 +46,10 @@ const deprecateAllProperties = (obj, message, code) => {
|
|
|
46
46
|
}
|
|
47
47
|
return newObj;
|
|
48
48
|
};
|
|
49
|
+
// Actually it is just a NormalModule proxy, used for hooks api alignment
|
|
50
|
+
// Maybe we can 1:1 align to webpack NormalModule once we found a better way to reduce communicate overhead between rust and js
|
|
49
51
|
class NormalModule {
|
|
52
|
+
constructor() { }
|
|
50
53
|
static getCompilationHooks(compilation) {
|
|
51
54
|
if (!(compilation instanceof Compilation_1.Compilation)) {
|
|
52
55
|
throw new TypeError("The 'compilation' argument must be an instance of Compilation");
|
|
@@ -55,6 +58,9 @@ class NormalModule {
|
|
|
55
58
|
if (hooks === undefined) {
|
|
56
59
|
hooks = {
|
|
57
60
|
loader: new tapable_1.SyncHook(["loaderContext"]),
|
|
61
|
+
// beforeLoaders: new SyncHook(["loaders", "module", "loaderContext"]),
|
|
62
|
+
// beforeParse: new SyncHook(["module"]),
|
|
63
|
+
// beforeSnapshot: new SyncHook(["module"]),
|
|
58
64
|
// TODO webpack 6 deprecate
|
|
59
65
|
readResourceForScheme: new tapable_1.HookMap(scheme => {
|
|
60
66
|
const hook = hooks.readResource.for(scheme);
|
|
@@ -65,6 +71,7 @@ class NormalModule {
|
|
|
65
71
|
});
|
|
66
72
|
}),
|
|
67
73
|
readResource: new tapable_1.HookMap(() => new tapable_1.AsyncSeriesBailHook(["loaderContext"]))
|
|
74
|
+
// needBuild: new AsyncSeriesBailHook(["module", "context"])
|
|
68
75
|
};
|
|
69
76
|
compilationHooksMap.set(compilation, hooks);
|
|
70
77
|
}
|
|
@@ -28,13 +28,35 @@ const liteTapable = __importStar(require("./lite-tapable"));
|
|
|
28
28
|
class NormalModuleFactory {
|
|
29
29
|
constructor() {
|
|
30
30
|
this.hooks = {
|
|
31
|
+
// /** @type {AsyncSeriesBailHook<[ResolveData], Module | false | void>} */
|
|
32
|
+
// resolve: new AsyncSeriesBailHook(["resolveData"]),
|
|
33
|
+
// /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>>} */
|
|
31
34
|
resolveForScheme: new liteTapable.HookMap(() => new liteTapable.AsyncSeriesBailHook(["resourceData"])),
|
|
35
|
+
// /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>>} */
|
|
36
|
+
// resolveInScheme: new HookMap(
|
|
37
|
+
// () => new AsyncSeriesBailHook(["resourceData", "resolveData"])
|
|
38
|
+
// ),
|
|
39
|
+
// /** @type {AsyncSeriesBailHook<[ResolveData], Module>} */
|
|
40
|
+
// factorize: new AsyncSeriesBailHook(["resolveData"]),
|
|
41
|
+
// /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
|
|
32
42
|
beforeResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
|
|
43
|
+
// /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
|
|
33
44
|
afterResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
|
|
45
|
+
// /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void>} */
|
|
34
46
|
createModule: new liteTapable.AsyncSeriesBailHook([
|
|
35
47
|
"createData",
|
|
36
48
|
"resolveData"
|
|
37
49
|
])
|
|
50
|
+
// /** @type {SyncWaterfallHook<[Module, ResolveData["createData"], ResolveData], Module>} */
|
|
51
|
+
// module: new SyncWaterfallHook(["module", "createData", "resolveData"]),
|
|
52
|
+
// createParser: new HookMap(() => new SyncBailHook(["parserOptions"])),
|
|
53
|
+
// parser: new HookMap(() => new SyncHook(["parser", "parserOptions"])),
|
|
54
|
+
// createGenerator: new HookMap(
|
|
55
|
+
// () => new SyncBailHook(["generatorOptions"])
|
|
56
|
+
// ),
|
|
57
|
+
// generator: new HookMap(
|
|
58
|
+
// () => new SyncHook(["generator", "generatorOptions"])
|
|
59
|
+
// )
|
|
38
60
|
};
|
|
39
61
|
}
|
|
40
62
|
}
|
package/dist/Stats.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Compilation } from "
|
|
1
|
+
import { Compilation } from ".";
|
|
2
2
|
import { StatsOptions, StatsValue } from "./config";
|
|
3
3
|
import type { StatsCompilation } from "./stats/statsFactoryUtils";
|
|
4
4
|
export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule, StatsWarnings } from "./stats/statsFactoryUtils";
|
|
@@ -6,7 +6,7 @@ export declare class Stats {
|
|
|
6
6
|
#private;
|
|
7
7
|
compilation: Compilation;
|
|
8
8
|
constructor(compilation: Compilation);
|
|
9
|
-
get hash():
|
|
9
|
+
get hash(): string | null;
|
|
10
10
|
hasErrors(): boolean;
|
|
11
11
|
hasWarnings(): boolean;
|
|
12
12
|
toJson(opts?: StatsValue, forToString?: boolean): StatsCompilation;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type EmotionConfigImportMap = {
|
|
2
|
+
[packageName: string]: {
|
|
3
|
+
[exportName: string]: {
|
|
4
|
+
canonicalImport?: [string, string];
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
type EmotionConfig = {
|
|
9
|
+
sourceMap?: boolean;
|
|
10
|
+
autoLabel?: "never" | "dev-only" | "always";
|
|
11
|
+
labelFormat?: string;
|
|
12
|
+
importMap?: EmotionConfigImportMap;
|
|
13
|
+
};
|
|
14
|
+
type EmotionOptions = boolean | EmotionConfig | undefined;
|
|
15
|
+
declare function resolveEmotion(emotion: EmotionOptions, isProduction: boolean): EmotionConfig | undefined;
|
|
16
|
+
export { resolveEmotion };
|
|
17
|
+
export type { EmotionOptions };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveEmotion = void 0;
|
|
4
|
+
function resolveEmotion(emotion, isProduction) {
|
|
5
|
+
if (!emotion) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
if (emotion === true) {
|
|
9
|
+
emotion = {};
|
|
10
|
+
}
|
|
11
|
+
const autoLabel = emotion?.autoLabel ?? "dev-only";
|
|
12
|
+
const emotionConfig = {
|
|
13
|
+
enabled: true,
|
|
14
|
+
// @ts-expect-error autoLabel is string for JavaScript interface, however is boolean for Rust interface
|
|
15
|
+
autoLabel: autoLabel === "dev-only" ? !isProduction : autoLabel === "always",
|
|
16
|
+
importMap: emotion?.importMap,
|
|
17
|
+
labelFormat: emotion?.labelFormat ?? "[local]",
|
|
18
|
+
sourcemap: isProduction ? false : emotion?.sourceMap ?? true
|
|
19
|
+
};
|
|
20
|
+
return emotionConfig;
|
|
21
|
+
}
|
|
22
|
+
exports.resolveEmotion = resolveEmotion;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
export type { EmotionOptions } from "./emotion";
|
|
2
|
+
export { resolveEmotion } from "./emotion";
|
|
1
3
|
export { resolvePluginImport } from "./pluginImport";
|
|
2
4
|
export type { PluginImportOptions } from "./pluginImport";
|
|
3
5
|
export type { ReactOptions } from "./react";
|
|
4
6
|
export { resolveReact } from "./react";
|
|
5
7
|
export { resolvePreact } from "./preact";
|
|
6
8
|
export type { PreactOptions } from "./preact";
|
|
9
|
+
export type { RelayOptions } from "./relay";
|
|
10
|
+
export { resolveRelay } from "./relay";
|
|
7
11
|
export type { SwcLoaderEnvConfig, SwcLoaderEsParserConfig, SwcLoaderJscConfig, SwcLoaderModuleConfig, SwcLoaderOptions, SwcLoaderParserConfig, SwcLoaderTransformConfig, SwcLoaderTsParserConfig } from "./types";
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePreact = exports.resolveReact = exports.resolvePluginImport = void 0;
|
|
3
|
+
exports.resolveRelay = exports.resolvePreact = exports.resolveReact = exports.resolvePluginImport = exports.resolveEmotion = void 0;
|
|
4
|
+
var emotion_1 = require("./emotion");
|
|
5
|
+
Object.defineProperty(exports, "resolveEmotion", { enumerable: true, get: function () { return emotion_1.resolveEmotion; } });
|
|
4
6
|
var pluginImport_1 = require("./pluginImport");
|
|
5
7
|
Object.defineProperty(exports, "resolvePluginImport", { enumerable: true, get: function () { return pluginImport_1.resolvePluginImport; } });
|
|
6
8
|
var react_1 = require("./react");
|
|
7
9
|
Object.defineProperty(exports, "resolveReact", { enumerable: true, get: function () { return react_1.resolveReact; } });
|
|
8
10
|
var preact_1 = require("./preact");
|
|
9
11
|
Object.defineProperty(exports, "resolvePreact", { enumerable: true, get: function () { return preact_1.resolvePreact; } });
|
|
12
|
+
var relay_1 = require("./relay");
|
|
13
|
+
Object.defineProperty(exports, "resolveRelay", { enumerable: true, get: function () { return relay_1.resolveRelay; } });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
type RawPreactOptions = {
|
|
2
2
|
library?: string;
|
|
3
3
|
};
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {};
|
|
4
|
+
type PreactOptions = RawPreactOptions | boolean | undefined;
|
|
5
|
+
declare function resolvePreact(preact: PreactOptions): RawPreactOptions | undefined;
|
|
6
|
+
export { resolvePreact };
|
|
7
|
+
export type { PreactOptions };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RawRelayConfig } from "@rspack/binding";
|
|
2
|
+
type RelayOptions = boolean | RawRelayConfig | undefined;
|
|
3
|
+
declare function resolveRelay(relay: RelayOptions, rootDir: string): RawRelayConfig | undefined;
|
|
4
|
+
export { resolveRelay };
|
|
5
|
+
export type { RelayOptions };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveRelay = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
function getRelayConfigFromProject(rootDir) {
|
|
9
|
+
for (const configName of [
|
|
10
|
+
"relay.config.json",
|
|
11
|
+
"relay.config.js",
|
|
12
|
+
"package.json"
|
|
13
|
+
]) {
|
|
14
|
+
const configPath = path_1.default.join(rootDir, configName);
|
|
15
|
+
try {
|
|
16
|
+
let config = require(configPath);
|
|
17
|
+
let finalConfig;
|
|
18
|
+
if (configName === "package.json") {
|
|
19
|
+
finalConfig = config?.relay;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
finalConfig = config;
|
|
23
|
+
}
|
|
24
|
+
if (finalConfig) {
|
|
25
|
+
return {
|
|
26
|
+
language: finalConfig.language,
|
|
27
|
+
artifactDirectory: finalConfig.artifactDirectory
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (_) { }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function resolveRelay(relay, rootDir) {
|
|
35
|
+
if (!relay) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
// Search relay config based on
|
|
39
|
+
if (relay === true) {
|
|
40
|
+
return (getRelayConfigFromProject(rootDir) || {
|
|
41
|
+
language: "javascript"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return relay;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.resolveRelay = resolveRelay;
|
|
@@ -2,9 +2,22 @@
|
|
|
2
2
|
* Some types are modified from https://github.com/swc-project/swc/blob/16a38851/packages/types/index.ts#L647
|
|
3
3
|
* license at https://github.com/swc-project/swc/blob/main/LICENSE
|
|
4
4
|
*/
|
|
5
|
+
import type { EmotionOptions } from "./emotion";
|
|
5
6
|
import type { PluginImportOptions } from "./pluginImport";
|
|
6
|
-
import type { PreactOptions } from "./preact";
|
|
7
7
|
import type { ReactOptions } from "./react";
|
|
8
|
+
import type { RelayOptions } from "./relay";
|
|
9
|
+
export type StyledComponentsOptions = {
|
|
10
|
+
displayName?: boolean;
|
|
11
|
+
ssr?: boolean;
|
|
12
|
+
fileName?: boolean;
|
|
13
|
+
meaninglessFileNames?: string[];
|
|
14
|
+
namespace?: string;
|
|
15
|
+
topLevelImportPaths?: string[];
|
|
16
|
+
transpileTemplateLiterals?: boolean;
|
|
17
|
+
minify?: boolean;
|
|
18
|
+
pure?: boolean;
|
|
19
|
+
cssProps?: boolean;
|
|
20
|
+
};
|
|
8
21
|
export type JscTarget = "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "esnext";
|
|
9
22
|
export type SwcLoaderParserConfig = SwcLoaderTsParserConfig | SwcLoaderEsParserConfig;
|
|
10
23
|
export interface SwcLoaderTsParserConfig {
|
|
@@ -441,7 +454,9 @@ export type SwcLoaderOptions = {
|
|
|
441
454
|
* @experimental
|
|
442
455
|
*/
|
|
443
456
|
rspackExperiments?: {
|
|
457
|
+
relay?: RelayOptions;
|
|
458
|
+
emotion?: EmotionOptions;
|
|
444
459
|
import?: PluginImportOptions;
|
|
445
|
-
|
|
460
|
+
styledComponents?: StyledComponentsOptions;
|
|
446
461
|
};
|
|
447
462
|
};
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { BuiltinPluginName } from "@rspack/binding";
|
|
2
|
+
export declare const JavascriptModulesPlugin: {
|
|
3
|
+
new (): {
|
|
4
|
+
name: BuiltinPluginName;
|
|
5
|
+
_options: void;
|
|
6
|
+
affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
7
|
+
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
8
|
+
apply(compiler: import("../Compiler").Compiler): void;
|
|
9
|
+
};
|
|
9
10
|
};
|
|
10
|
-
export declare class JavascriptModulesPlugin extends RspackBuiltinPlugin {
|
|
11
|
-
name: BuiltinPluginName;
|
|
12
|
-
affectedHooks: "compilation";
|
|
13
|
-
constructor();
|
|
14
|
-
raw(): BuiltinPlugin;
|
|
15
|
-
static getCompilationHooks(compilation: Compilation): CompilationHooks;
|
|
16
|
-
}
|
|
@@ -1,55 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.JavascriptModulesPlugin = void 0;
|
|
27
4
|
const binding_1 = require("@rspack/binding");
|
|
28
|
-
const Compilation_1 = require("../Compilation");
|
|
29
|
-
const liteTapable = __importStar(require("../lite-tapable"));
|
|
30
5
|
const base_1 = require("./base");
|
|
31
|
-
|
|
32
|
-
class JavascriptModulesPlugin extends base_1.RspackBuiltinPlugin {
|
|
33
|
-
constructor() {
|
|
34
|
-
super();
|
|
35
|
-
this.name = binding_1.BuiltinPluginName.JavascriptModulesPlugin;
|
|
36
|
-
this.affectedHooks = "compilation";
|
|
37
|
-
}
|
|
38
|
-
raw() {
|
|
39
|
-
return (0, base_1.createBuiltinPlugin)(this.name, undefined);
|
|
40
|
-
}
|
|
41
|
-
static getCompilationHooks(compilation) {
|
|
42
|
-
if (!(compilation instanceof Compilation_1.Compilation)) {
|
|
43
|
-
throw new TypeError("The 'compilation' argument must be an instance of Compilation");
|
|
44
|
-
}
|
|
45
|
-
let hooks = compilationHooksMap.get(compilation);
|
|
46
|
-
if (hooks === undefined) {
|
|
47
|
-
hooks = {
|
|
48
|
-
chunkHash: new liteTapable.SyncHook(["chunk", "hash"])
|
|
49
|
-
};
|
|
50
|
-
compilationHooksMap.set(compilation, hooks);
|
|
51
|
-
}
|
|
52
|
-
return hooks;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.JavascriptModulesPlugin = JavascriptModulesPlugin;
|
|
6
|
+
exports.JavascriptModulesPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.JavascriptModulesPlugin, () => { }, "compilation");
|
|
@@ -3,8 +3,8 @@ import { Compiler } from "../..";
|
|
|
3
3
|
export * from "./loader";
|
|
4
4
|
export type { CssExtractRspackLoaderOptions } from "./loader";
|
|
5
5
|
export interface CssExtractRspackPluginOptions {
|
|
6
|
-
filename?:
|
|
7
|
-
chunkFilename?:
|
|
6
|
+
filename?: string;
|
|
7
|
+
chunkFilename?: string;
|
|
8
8
|
ignoreOrder?: boolean;
|
|
9
9
|
insert?: string | ((linkTag: HTMLLinkElement) => void);
|
|
10
10
|
attributes?: Record<string, string>;
|
package/dist/config/adapter.js
CHANGED
|
@@ -85,24 +85,21 @@ function getRawResolveByDependency(byDependency) {
|
|
|
85
85
|
return byDependency;
|
|
86
86
|
return Object.fromEntries(Object.entries(byDependency).map(([k, v]) => [k, getRawResolve(v)]));
|
|
87
87
|
}
|
|
88
|
-
function getRawTsConfig(tsConfig) {
|
|
89
|
-
(0, assert_1.default)(typeof tsConfig !== "string", "should resolve string tsConfig in normalization");
|
|
90
|
-
if (tsConfig === undefined)
|
|
91
|
-
return tsConfig;
|
|
92
|
-
const { configFile, references } = tsConfig;
|
|
93
|
-
return {
|
|
94
|
-
configFile,
|
|
95
|
-
referencesType: references == "auto" ? "auto" : references ? "manual" : "disabled",
|
|
96
|
-
references: references == "auto" ? undefined : references
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
88
|
function getRawResolve(resolve) {
|
|
89
|
+
let references = resolve.tsConfig?.references;
|
|
90
|
+
let tsconfigConfigFile = resolve.tsConfigPath ?? resolve.tsConfig?.configFile;
|
|
100
91
|
return {
|
|
101
92
|
...resolve,
|
|
102
93
|
alias: getRawAlias(resolve.alias),
|
|
103
94
|
fallback: getRawAlias(resolve.fallback),
|
|
104
95
|
extensionAlias: getRawExtensionAlias(resolve.extensionAlias),
|
|
105
|
-
tsconfig:
|
|
96
|
+
tsconfig: tsconfigConfigFile
|
|
97
|
+
? {
|
|
98
|
+
configFile: tsconfigConfigFile,
|
|
99
|
+
referencesType: references == "auto" ? "auto" : references ? "manual" : "disabled",
|
|
100
|
+
references: references == "auto" ? undefined : references
|
|
101
|
+
}
|
|
102
|
+
: undefined,
|
|
106
103
|
byDependency: getRawResolveByDependency(resolve.byDependency)
|
|
107
104
|
};
|
|
108
105
|
}
|
|
@@ -467,19 +464,9 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
467
464
|
reexportExportsPresence: parser.reexportExportsPresence === false
|
|
468
465
|
? "false"
|
|
469
466
|
: parser.reexportExportsPresence,
|
|
470
|
-
strictExportPresence: parser.strictExportPresence ?? false
|
|
471
|
-
worker: getRawJavascriptParserOptionsWorker(parser.worker)
|
|
467
|
+
strictExportPresence: parser.strictExportPresence ?? false
|
|
472
468
|
};
|
|
473
469
|
}
|
|
474
|
-
function getRawJavascriptParserOptionsWorker(worker) {
|
|
475
|
-
const DEFAULT_SYNTAX = [
|
|
476
|
-
"Worker",
|
|
477
|
-
"SharedWorker",
|
|
478
|
-
// "navigator.serviceWorker.register()",
|
|
479
|
-
"Worker from worker_threads"
|
|
480
|
-
];
|
|
481
|
-
return (worker === false ? [] : Array.isArray(worker) ? worker : ["..."]).flatMap(item => (item === "..." ? DEFAULT_SYNTAX : item));
|
|
482
|
-
}
|
|
483
470
|
function getRawAssetParserOptions(parser) {
|
|
484
471
|
return {
|
|
485
472
|
dataUrlCondition: parser.dataUrlCondition
|
|
@@ -16,9 +16,20 @@ exports.createRawModuleRuleUses = createRawModuleRuleUses;
|
|
|
16
16
|
const getSwcLoaderOptions = (o, options) => {
|
|
17
17
|
if (o && typeof o === "object" && o.rspackExperiments) {
|
|
18
18
|
let expr = o.rspackExperiments;
|
|
19
|
+
const contextPath = options.context;
|
|
20
|
+
const production = options.mode === "production" || !options.mode;
|
|
21
|
+
if (expr.emotion) {
|
|
22
|
+
expr.emotion = (0, builtin_loader_1.resolveEmotion)(expr.emotion, production);
|
|
23
|
+
}
|
|
24
|
+
if (expr.relay) {
|
|
25
|
+
expr.relay = (0, builtin_loader_1.resolveRelay)(expr.relay, contextPath);
|
|
26
|
+
}
|
|
19
27
|
if (expr.import || expr.pluginImport) {
|
|
20
28
|
expr.import = (0, builtin_loader_1.resolvePluginImport)(expr.import || expr.pluginImport);
|
|
21
29
|
}
|
|
30
|
+
if (expr.react) {
|
|
31
|
+
expr.react = (0, builtin_loader_1.resolveReact)(expr.react);
|
|
32
|
+
}
|
|
22
33
|
if (expr.preact) {
|
|
23
34
|
expr.preact = (0, builtin_loader_1.resolvePreact)(expr.preact);
|
|
24
35
|
}
|
package/dist/config/defaults.js
CHANGED
|
@@ -155,7 +155,6 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, fallback) => {
|
|
|
155
155
|
D(parserOptions, "importExportsPresence", fallback?.importExportsPresence);
|
|
156
156
|
D(parserOptions, "reexportExportsPresence", fallback?.reexportExportsPresence);
|
|
157
157
|
D(parserOptions, "strictExportPresence", fallback?.strictExportPresence ?? false);
|
|
158
|
-
D(parserOptions, "worker", fallback?.worker ?? ["..."]);
|
|
159
158
|
};
|
|
160
159
|
const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
|
|
161
160
|
(0, assertNotNil_1.assertNotNill)(module.parser);
|
|
@@ -123,20 +123,10 @@ const getNormalizedRspackOptions = (config) => {
|
|
|
123
123
|
};
|
|
124
124
|
}),
|
|
125
125
|
resolve: nestedConfig(config.resolve, resolve => ({
|
|
126
|
-
...resolve
|
|
127
|
-
tsConfig: optionalNestedConfig(resolve.tsConfig, tsConfig => {
|
|
128
|
-
return typeof tsConfig === "string"
|
|
129
|
-
? { configFile: tsConfig }
|
|
130
|
-
: tsConfig;
|
|
131
|
-
})
|
|
126
|
+
...resolve
|
|
132
127
|
})),
|
|
133
128
|
resolveLoader: nestedConfig(config.resolveLoader, resolve => ({
|
|
134
|
-
...resolve
|
|
135
|
-
tsConfig: optionalNestedConfig(resolve.tsConfig, tsConfig => {
|
|
136
|
-
return typeof tsConfig === "string"
|
|
137
|
-
? { configFile: tsConfig }
|
|
138
|
-
: tsConfig;
|
|
139
|
-
})
|
|
129
|
+
...resolve
|
|
140
130
|
})),
|
|
141
131
|
module: nestedConfig(config.module, module => ({
|
|
142
132
|
noParse: module.noParse,
|