@rspack/core 0.5.8-canary-67df93d-20240322005756 → 0.5.8-canary-db10b37-20240323004659
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/Compilation.d.ts +1 -1
- package/dist/Compilation.js +1 -1
- package/dist/Compiler.d.ts +11 -3
- package/dist/Compiler.js +20 -29
- package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +11 -10
- package/dist/builtin-plugin/EnableLibraryPlugin.js +39 -1
- package/dist/builtin-plugin/base.d.ts +1 -1
- package/dist/exports.d.ts +2 -9
- package/dist/sharing/ShareRuntimePlugin.d.ts +1 -1
- package/dist/sharing/ShareRuntimePlugin.js +1 -1
- package/package.json +4 -4
package/dist/Compilation.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare class Compilation {
|
|
|
63
63
|
#private;
|
|
64
64
|
hooks: {
|
|
65
65
|
processAssets: liteTapable.AsyncSeriesHook<Assets>;
|
|
66
|
-
afterProcessAssets:
|
|
66
|
+
afterProcessAssets: liteTapable.SyncHook<Assets>;
|
|
67
67
|
childCompiler: tapable.SyncHook<[Compiler, string, number]>;
|
|
68
68
|
log: tapable.SyncBailHook<[string, LogEntry], true>;
|
|
69
69
|
additionalAssets: any;
|
package/dist/Compilation.js
CHANGED
|
@@ -129,7 +129,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
129
129
|
};
|
|
130
130
|
this.hooks = {
|
|
131
131
|
processAssets: processAssetsHook,
|
|
132
|
-
afterProcessAssets: new
|
|
132
|
+
afterProcessAssets: new liteTapable.SyncHook(["assets"]),
|
|
133
133
|
/** @deprecated */
|
|
134
134
|
additionalAssets: createProcessAssetsHook("additionalAssets", Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL, () => []),
|
|
135
135
|
childCompiler: new tapable.SyncHook([
|
package/dist/Compiler.d.ts
CHANGED
|
@@ -26,6 +26,14 @@ import { NormalModuleFactory } from "./NormalModuleFactory";
|
|
|
26
26
|
import { WatchFileSystem } from "./util/fs";
|
|
27
27
|
import { Watching } from "./Watching";
|
|
28
28
|
import { FileSystemInfoEntry } from "./FileSystemInfo";
|
|
29
|
+
import { Source } from "webpack-sources";
|
|
30
|
+
export interface AssetEmittedInfo {
|
|
31
|
+
content: Buffer;
|
|
32
|
+
source: Source;
|
|
33
|
+
outputPath: string;
|
|
34
|
+
targetPath: string;
|
|
35
|
+
compilation: Compilation;
|
|
36
|
+
}
|
|
29
37
|
declare class Compiler {
|
|
30
38
|
#private;
|
|
31
39
|
webpack: typeof import("./rspack").rspack & typeof import("./exports") & {
|
|
@@ -71,9 +79,9 @@ declare class Compiler {
|
|
|
71
79
|
infrastructureLog: tapable.SyncBailHook<[string, string, any[]], true>;
|
|
72
80
|
beforeRun: tapable.AsyncSeriesHook<[Compiler]>;
|
|
73
81
|
run: tapable.AsyncSeriesHook<[Compiler]>;
|
|
74
|
-
emit:
|
|
75
|
-
assetEmitted:
|
|
76
|
-
afterEmit:
|
|
82
|
+
emit: liteTapable.AsyncSeriesHook<[Compilation]>;
|
|
83
|
+
assetEmitted: liteTapable.AsyncSeriesHook<[string, AssetEmittedInfo]>;
|
|
84
|
+
afterEmit: liteTapable.AsyncSeriesHook<[Compilation]>;
|
|
77
85
|
failed: tapable.SyncHook<[Error]>;
|
|
78
86
|
shutdown: tapable.AsyncSeriesHook<[]>;
|
|
79
87
|
watchRun: tapable.AsyncSeriesHook<[Compiler]>;
|
package/dist/Compiler.js
CHANGED
|
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
|
-
var _Compiler_instances, _Compiler_instance, _Compiler_disabledHooks, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateDisabledHooks, _Compiler_afterProcessAssets, _Compiler_afterResolve, _Compiler_contextModuleFactoryBeforeResolve, _Compiler_contextModuleFactoryAfterResolve, _Compiler_normalModuleFactoryCreateModule, _Compiler_normalModuleFactoryResolveForScheme, _Compiler_optimizeChunkModules, _Compiler_optimizeTree, _Compiler_optimizeModules, _Compiler_afterOptimizeModules, _Compiler_emit,
|
|
39
|
+
var _Compiler_instances, _Compiler_instance, _Compiler_disabledHooks, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateDisabledHooks, _Compiler_afterProcessAssets, _Compiler_afterResolve, _Compiler_contextModuleFactoryBeforeResolve, _Compiler_contextModuleFactoryAfterResolve, _Compiler_normalModuleFactoryCreateModule, _Compiler_normalModuleFactoryResolveForScheme, _Compiler_optimizeChunkModules, _Compiler_optimizeTree, _Compiler_optimizeModules, _Compiler_afterOptimizeModules, _Compiler_emit, _Compiler_afterEmit, _Compiler_decorateUpdateDisabledHooks, _Compiler_createRegisterTaps, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.Compiler = void 0;
|
|
42
42
|
const index_1 = require("./index");
|
|
@@ -98,9 +98,9 @@ class Compiler {
|
|
|
98
98
|
afterDone: new tapable.SyncHook(["stats"]),
|
|
99
99
|
beforeRun: new tapable.AsyncSeriesHook(["compiler"]),
|
|
100
100
|
run: new tapable.AsyncSeriesHook(["compiler"]),
|
|
101
|
-
emit: new
|
|
102
|
-
assetEmitted: new
|
|
103
|
-
afterEmit: new
|
|
101
|
+
emit: new liteTapable.AsyncSeriesHook(["compilation"]),
|
|
102
|
+
assetEmitted: new liteTapable.AsyncSeriesHook(["file", "info"]),
|
|
103
|
+
afterEmit: new liteTapable.AsyncSeriesHook(["compilation"]),
|
|
104
104
|
thisCompilation: new liteTapable.SyncHook(["compilation", "params"]),
|
|
105
105
|
compilation: new liteTapable.SyncHook([
|
|
106
106
|
"compilation",
|
|
@@ -502,10 +502,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
502
502
|
const rawOptions = (0, config_1.getRawOptions)(options, this);
|
|
503
503
|
const instanceBinding = require("@rspack/binding");
|
|
504
504
|
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, {
|
|
505
|
-
emit: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_emit).bind(this),
|
|
506
|
-
assetEmitted: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_assetEmitted).bind(this),
|
|
507
|
-
afterEmit: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterEmit).bind(this),
|
|
508
|
-
afterProcessAssets: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterProcessAssets).bind(this),
|
|
509
505
|
optimizeModules: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_optimizeModules).bind(this),
|
|
510
506
|
afterOptimizeModules: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterOptimizeModules).bind(this),
|
|
511
507
|
optimizeTree: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_optimizeTree).bind(this),
|
|
@@ -526,6 +522,21 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
526
522
|
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.make, queried => async () => await queried.promise(this.compilation)),
|
|
527
523
|
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.finishMake, queried => async () => await queried.promise(this.compilation)),
|
|
528
524
|
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.shouldEmit, queried => () => queried.call(this.compilation)),
|
|
525
|
+
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.emit, queried => async () => await queried.promise(this.compilation)),
|
|
526
|
+
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.afterEmit, queried => async () => await queried.promise(this.compilation)),
|
|
527
|
+
registerCompilerAssetEmittedTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.assetEmitted, queried => async ({ filename, targetPath, outputPath }) => await queried.promise(filename, {
|
|
528
|
+
compilation: this.compilation,
|
|
529
|
+
targetPath,
|
|
530
|
+
outputPath,
|
|
531
|
+
get source() {
|
|
532
|
+
var _a;
|
|
533
|
+
return (_a = this.compilation.getAsset(filename)) === null || _a === void 0 ? void 0 : _a.source;
|
|
534
|
+
},
|
|
535
|
+
get content() {
|
|
536
|
+
var _a;
|
|
537
|
+
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.buffer();
|
|
538
|
+
}
|
|
539
|
+
})),
|
|
529
540
|
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.runtimeModule, queried => ({ module, chunk }) => {
|
|
530
541
|
var _a, _b;
|
|
531
542
|
const originSource = (_a = module.source) === null || _a === void 0 ? void 0 : _a.source;
|
|
@@ -580,6 +591,7 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
580
591
|
registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.finishModules, queried => async () => await queried.promise(this.compilation.modules)),
|
|
581
592
|
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, this.compilation), filename)),
|
|
582
593
|
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.processAssets, queried => async () => await queried.promise(this.compilation.assets)),
|
|
594
|
+
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.afterProcessAssets, queried => () => queried.call(this.compilation.assets)),
|
|
583
595
|
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
584
596
|
const normalizedResolveData = {
|
|
585
597
|
request: resolveData.request,
|
|
@@ -599,10 +611,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
599
611
|
var _a, _b, _c, _d, _e;
|
|
600
612
|
const disabledHooks = [];
|
|
601
613
|
const hookMap = {
|
|
602
|
-
emit: this.hooks.emit,
|
|
603
|
-
assetEmitted: this.hooks.assetEmitted,
|
|
604
|
-
afterEmit: this.hooks.afterEmit,
|
|
605
|
-
afterProcessAssets: this.compilation.hooks.afterProcessAssets,
|
|
606
614
|
optimizeTree: this.compilation.hooks.optimizeTree,
|
|
607
615
|
optimizeModules: this.compilation.hooks.optimizeModules,
|
|
608
616
|
afterOptimizeModules: this.compilation.hooks.afterOptimizeModules,
|
|
@@ -685,23 +693,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
685
693
|
}, _Compiler_emit = async function _Compiler_emit() {
|
|
686
694
|
await this.hooks.emit.promise(this.compilation);
|
|
687
695
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
688
|
-
}, _Compiler_assetEmitted = async function _Compiler_assetEmitted(args) {
|
|
689
|
-
const filename = args.filename;
|
|
690
|
-
const info = {
|
|
691
|
-
compilation: this.compilation,
|
|
692
|
-
outputPath: args.outputPath,
|
|
693
|
-
targetPath: args.targetPath,
|
|
694
|
-
get source() {
|
|
695
|
-
var _a;
|
|
696
|
-
return (_a = this.compilation.getAsset(args.filename)) === null || _a === void 0 ? void 0 : _a.source;
|
|
697
|
-
},
|
|
698
|
-
get content() {
|
|
699
|
-
var _a;
|
|
700
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.buffer();
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
await this.hooks.assetEmitted.promise(filename, info);
|
|
704
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
705
696
|
}, _Compiler_afterEmit = async function _Compiler_afterEmit() {
|
|
706
697
|
await this.hooks.afterEmit.promise(this.compilation);
|
|
707
698
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { BuiltinPluginName } from "@rspack/binding";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
|
|
2
|
+
import { RspackBuiltinPlugin } from "./base";
|
|
3
|
+
import { Compiler, LibraryType } from "..";
|
|
4
|
+
export declare class EnableLibraryPlugin extends RspackBuiltinPlugin {
|
|
5
|
+
private type;
|
|
6
|
+
name: BuiltinPluginName;
|
|
7
|
+
constructor(type: LibraryType);
|
|
8
|
+
static setEnabled(compiler: Compiler, type: LibraryType): void;
|
|
9
|
+
static checkEnabled(compiler: Compiler, type: LibraryType): void;
|
|
10
|
+
raw(compiler: Compiler): BuiltinPlugin | undefined;
|
|
11
|
+
}
|
|
@@ -3,4 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EnableLibraryPlugin = void 0;
|
|
4
4
|
const binding_1 = require("@rspack/binding");
|
|
5
5
|
const base_1 = require("./base");
|
|
6
|
-
|
|
6
|
+
const enabledTypes = new WeakMap();
|
|
7
|
+
const getEnabledTypes = (compiler) => {
|
|
8
|
+
let set = enabledTypes.get(compiler);
|
|
9
|
+
if (set === undefined) {
|
|
10
|
+
set = new Set();
|
|
11
|
+
enabledTypes.set(compiler, set);
|
|
12
|
+
}
|
|
13
|
+
return set;
|
|
14
|
+
};
|
|
15
|
+
class EnableLibraryPlugin extends base_1.RspackBuiltinPlugin {
|
|
16
|
+
constructor(type) {
|
|
17
|
+
super();
|
|
18
|
+
this.type = type;
|
|
19
|
+
this.name = binding_1.BuiltinPluginName.EnableLibraryPlugin;
|
|
20
|
+
}
|
|
21
|
+
static setEnabled(compiler, type) {
|
|
22
|
+
getEnabledTypes(compiler).add(type);
|
|
23
|
+
}
|
|
24
|
+
static checkEnabled(compiler, type) {
|
|
25
|
+
if (!getEnabledTypes(compiler).has(type)) {
|
|
26
|
+
throw new Error(`Library type "${type}" is not enabled. ` +
|
|
27
|
+
"EnableLibraryPlugin need to be used to enable this type of library. " +
|
|
28
|
+
'This usually happens through the "output.enabledLibraryTypes" option. ' +
|
|
29
|
+
'If you are using a function as entry which sets "library", you need to add all potential library types to "output.enabledLibraryTypes". ' +
|
|
30
|
+
"These types are enabled: " +
|
|
31
|
+
Array.from(getEnabledTypes(compiler)).join(", "));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
raw(compiler) {
|
|
35
|
+
const { type } = this;
|
|
36
|
+
// Only enable once
|
|
37
|
+
const enabled = getEnabledTypes(compiler);
|
|
38
|
+
if (enabled.has(type))
|
|
39
|
+
return;
|
|
40
|
+
enabled.add(type);
|
|
41
|
+
return (0, base_1.createBuiltinPlugin)(this.name, type);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.EnableLibraryPlugin = EnableLibraryPlugin;
|
|
@@ -4,7 +4,7 @@ type AffectedHooks = keyof Compiler["hooks"];
|
|
|
4
4
|
export declare const HOOKS_CAN_NOT_INHERENT_FROM_PARENT: string[];
|
|
5
5
|
export declare function canInherentFromParent(affectedHooks?: AffectedHooks): boolean;
|
|
6
6
|
export declare abstract class RspackBuiltinPlugin implements RspackPluginInstance {
|
|
7
|
-
abstract raw(compiler: Compiler): binding.BuiltinPlugin |
|
|
7
|
+
abstract raw(compiler: Compiler): binding.BuiltinPlugin | undefined;
|
|
8
8
|
abstract name: binding.BuiltinPluginName;
|
|
9
9
|
affectedHooks?: AffectedHooks;
|
|
10
10
|
apply(compiler: Compiler): void;
|
package/dist/exports.d.ts
CHANGED
|
@@ -789,16 +789,9 @@ export declare const electron: {
|
|
|
789
789
|
};
|
|
790
790
|
};
|
|
791
791
|
};
|
|
792
|
+
import { EnableLibraryPlugin } from "./builtin-plugin";
|
|
792
793
|
export declare const library: {
|
|
793
|
-
EnableLibraryPlugin:
|
|
794
|
-
new (type: any): {
|
|
795
|
-
name: import("@rspack/binding").BuiltinPluginName;
|
|
796
|
-
_options: any;
|
|
797
|
-
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;
|
|
798
|
-
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
799
|
-
apply(compiler: import("./Compiler").Compiler): void;
|
|
800
|
-
};
|
|
801
|
-
};
|
|
794
|
+
EnableLibraryPlugin: typeof EnableLibraryPlugin;
|
|
802
795
|
};
|
|
803
796
|
export declare const wasm: {
|
|
804
797
|
EnableWasmLoadingPlugin: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "0.5.8-canary-
|
|
3
|
+
"version": "0.5.8-canary-db10b37-20240323004659",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Fast Rust-based Web Bundler",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"styled-components": "^6.0.8",
|
|
57
57
|
"terser": "5.27.2",
|
|
58
58
|
"wast-loader": "^1.11.4",
|
|
59
|
-
"@rspack/
|
|
60
|
-
"@rspack/
|
|
59
|
+
"@rspack/core": "0.5.8-canary-db10b37-20240323004659",
|
|
60
|
+
"@rspack/plugin-minify": "^0.5.8-canary-db10b37-20240323004659"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@module-federation/runtime-tools": "0.0.8",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"webpack-sources": "3.2.3",
|
|
73
73
|
"zod": "^3.21.4",
|
|
74
74
|
"zod-validation-error": "1.3.1",
|
|
75
|
-
"@rspack/binding": "0.5.8-canary-
|
|
75
|
+
"@rspack/binding": "0.5.8-canary-db10b37-20240323004659"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@swc/helpers": ">=0.5.1"
|