@rspack/core 0.5.7 → 0.5.8
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 -2
- package/dist/Compiler.d.ts +7 -6
- package/dist/Compiler.js +101 -164
- package/dist/NormalModuleFactory.d.ts +2 -1
- package/dist/NormalModuleFactory.js +25 -1
- package/dist/Watching.js +2 -2
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +11 -0
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +7 -0
- package/dist/builtin-plugin/index.d.ts +1 -0
- package/dist/builtin-plugin/index.js +1 -0
- package/dist/config/adapter.js +9 -8
- package/dist/config/zod.d.ts +324 -70
- package/dist/config/zod.js +8 -1
- package/dist/exports.d.ts +16 -4
- package/dist/lite-tapable/index.d.ts +14 -1
- package/dist/lite-tapable/index.js +168 -1
- package/dist/loader-runner/index.d.ts +2 -2
- package/dist/loader-runner/index.js +4 -4
- package/dist/rspackOptionsApply.js +1 -0
- package/package.json +5 -5
package/dist/Compilation.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export interface LogEntry {
|
|
|
42
42
|
}
|
|
43
43
|
export interface CompilationParams {
|
|
44
44
|
normalModuleFactory: NormalModuleFactory;
|
|
45
|
+
contextModuleFactory: ContextModuleFactory;
|
|
45
46
|
}
|
|
46
47
|
export interface KnownCreateStatsOptionsContext {
|
|
47
48
|
forToString?: boolean;
|
|
@@ -101,9 +102,7 @@ export declare class Compilation {
|
|
|
101
102
|
childrenCounters: Record<string, number>;
|
|
102
103
|
startTime?: number;
|
|
103
104
|
endTime?: number;
|
|
104
|
-
normalModuleFactory?: NormalModuleFactory;
|
|
105
105
|
children: Compilation[];
|
|
106
|
-
contextModuleFactory?: ContextModuleFactory;
|
|
107
106
|
chunkGraph: ChunkGraph;
|
|
108
107
|
fileSystemInfo: {
|
|
109
108
|
createSnapshot(): null;
|
package/dist/Compiler.d.ts
CHANGED
|
@@ -32,7 +32,8 @@ declare class Compiler {
|
|
|
32
32
|
rspack: typeof import("./rspack").rspack & typeof import("./exports") & any;
|
|
33
33
|
webpack: typeof import("./rspack").rspack & typeof import("./exports") & any;
|
|
34
34
|
};
|
|
35
|
-
compilation
|
|
35
|
+
compilation?: Compilation;
|
|
36
|
+
compilationParams?: CompilationParams;
|
|
36
37
|
first: boolean;
|
|
37
38
|
builtinPlugins: binding.BuiltinPlugin[];
|
|
38
39
|
root: Compiler;
|
|
@@ -50,23 +51,23 @@ declare class Compiler {
|
|
|
50
51
|
intermediateFileSystem: any;
|
|
51
52
|
watchMode: boolean;
|
|
52
53
|
context: string;
|
|
53
|
-
modifiedFiles?: ReadonlySet<string>;
|
|
54
54
|
cache: Cache;
|
|
55
55
|
compilerPath: string;
|
|
56
|
+
modifiedFiles?: ReadonlySet<string>;
|
|
56
57
|
removedFiles?: ReadonlySet<string>;
|
|
57
58
|
fileTimestamps?: ReadonlyMap<string, FileSystemInfoEntry | "ignore" | null>;
|
|
58
59
|
contextTimestamps?: ReadonlyMap<string, FileSystemInfoEntry | "ignore" | null>;
|
|
59
60
|
hooks: {
|
|
60
61
|
done: tapable.AsyncSeriesHook<Stats>;
|
|
61
62
|
afterDone: tapable.SyncHook<Stats>;
|
|
63
|
+
thisCompilation: liteTapable.SyncHook<[Compilation, CompilationParams]>;
|
|
62
64
|
compilation: liteTapable.SyncHook<[Compilation, CompilationParams]>;
|
|
63
|
-
thisCompilation: tapable.SyncHook<[Compilation, CompilationParams]>;
|
|
64
65
|
invalid: tapable.SyncHook<[string | null, number]>;
|
|
65
|
-
compile: tapable.SyncHook<[
|
|
66
|
+
compile: tapable.SyncHook<[CompilationParams]>;
|
|
66
67
|
normalModuleFactory: tapable.SyncHook<NormalModuleFactory>;
|
|
67
68
|
contextModuleFactory: tapable.SyncHook<ContextModuleFactory>;
|
|
68
69
|
initialize: tapable.SyncHook<[]>;
|
|
69
|
-
shouldEmit:
|
|
70
|
+
shouldEmit: liteTapable.SyncBailHook<[Compilation], boolean>;
|
|
70
71
|
infrastructureLog: tapable.SyncBailHook<[string, string, any[]], true>;
|
|
71
72
|
beforeRun: tapable.AsyncSeriesHook<[Compiler]>;
|
|
72
73
|
run: tapable.AsyncSeriesHook<[Compiler]>;
|
|
@@ -82,7 +83,7 @@ declare class Compiler {
|
|
|
82
83
|
afterPlugins: tapable.SyncHook<[Compiler]>;
|
|
83
84
|
afterResolvers: tapable.SyncHook<[Compiler]>;
|
|
84
85
|
make: liteTapable.AsyncParallelHook<[Compilation]>;
|
|
85
|
-
beforeCompile: tapable.AsyncSeriesHook<
|
|
86
|
+
beforeCompile: tapable.AsyncSeriesHook<[CompilationParams]>;
|
|
86
87
|
afterCompile: tapable.AsyncSeriesHook<[Compilation]>;
|
|
87
88
|
finishModules: tapable.AsyncSeriesHook<[any]>;
|
|
88
89
|
finishMake: tapable.AsyncSeriesHook<[Compilation]>;
|
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,
|
|
39
|
+
var _Compiler_instances, _Compiler_instance, _Compiler_disabledHooks, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateDisabledHooks, _Compiler_finishMake, _Compiler_buildModule, _Compiler_afterProcessAssets, _Compiler_afterResolve, _Compiler_contextModuleFactoryBeforeResolve, _Compiler_contextModuleFactoryAfterResolve, _Compiler_normalModuleFactoryCreateModule, _Compiler_normalModuleFactoryResolveForScheme, _Compiler_optimizeChunkModules, _Compiler_optimizeTree, _Compiler_optimizeModules, _Compiler_afterOptimizeModules, _Compiler_chunkAsset, _Compiler_finishModules, _Compiler_emit, _Compiler_assetEmitted, _Compiler_afterEmit, _Compiler_succeedModule, _Compiler_stillValidModule, _Compiler_runtimeModule, _Compiler_executeModule, _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");
|
|
@@ -54,7 +54,6 @@ const ConcurrentCompilationError_1 = __importDefault(require("./error/Concurrent
|
|
|
54
54
|
const fileSystem_1 = require("./fileSystem");
|
|
55
55
|
const Cache_1 = __importDefault(require("./lib/Cache"));
|
|
56
56
|
const CacheFacade_1 = __importDefault(require("./lib/CacheFacade"));
|
|
57
|
-
const loader_runner_1 = require("./loader-runner");
|
|
58
57
|
const Logger_1 = require("./logging/Logger");
|
|
59
58
|
const NormalModuleFactory_1 = require("./NormalModuleFactory");
|
|
60
59
|
const bindingVersionCheck_1 = require("./util/bindingVersionCheck");
|
|
@@ -94,7 +93,7 @@ class Compiler {
|
|
|
94
93
|
this.removedFiles = undefined;
|
|
95
94
|
this.hooks = {
|
|
96
95
|
initialize: new tapable_1.SyncHook([]),
|
|
97
|
-
shouldEmit: new
|
|
96
|
+
shouldEmit: new liteTapable.SyncBailHook(["compilation"]),
|
|
98
97
|
done: new tapable.AsyncSeriesHook(["stats"]),
|
|
99
98
|
afterDone: new tapable.SyncHook(["stats"]),
|
|
100
99
|
beforeRun: new tapable.AsyncSeriesHook(["compiler"]),
|
|
@@ -102,10 +101,7 @@ class Compiler {
|
|
|
102
101
|
emit: new tapable.AsyncSeriesHook(["compilation"]),
|
|
103
102
|
assetEmitted: new tapable.AsyncSeriesHook(["file", "info"]),
|
|
104
103
|
afterEmit: new tapable.AsyncSeriesHook(["compilation"]),
|
|
105
|
-
thisCompilation: new
|
|
106
|
-
"compilation",
|
|
107
|
-
"params"
|
|
108
|
-
]),
|
|
104
|
+
thisCompilation: new liteTapable.SyncHook(["compilation", "params"]),
|
|
109
105
|
compilation: new liteTapable.SyncHook([
|
|
110
106
|
"compilation",
|
|
111
107
|
"params"
|
|
@@ -346,7 +342,7 @@ class Compiler {
|
|
|
346
342
|
if (err) {
|
|
347
343
|
return finalCallback(err);
|
|
348
344
|
}
|
|
349
|
-
this.
|
|
345
|
+
this.compile(err => {
|
|
350
346
|
if (err) {
|
|
351
347
|
return finalCallback(err);
|
|
352
348
|
}
|
|
@@ -386,8 +382,7 @@ class Compiler {
|
|
|
386
382
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
387
383
|
}
|
|
388
384
|
if (!this.first) {
|
|
389
|
-
|
|
390
|
-
rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
385
|
+
instance.rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
391
386
|
if (error) {
|
|
392
387
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
393
388
|
}
|
|
@@ -396,8 +391,7 @@ class Compiler {
|
|
|
396
391
|
return;
|
|
397
392
|
}
|
|
398
393
|
this.first = false;
|
|
399
|
-
|
|
400
|
-
build(error => {
|
|
394
|
+
instance.build(error => {
|
|
401
395
|
if (error) {
|
|
402
396
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
403
397
|
}
|
|
@@ -414,8 +408,7 @@ class Compiler {
|
|
|
414
408
|
if (error) {
|
|
415
409
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
416
410
|
}
|
|
417
|
-
|
|
418
|
-
rebuild(Array.from(modifiedFiles || []), Array.from(removedFiles || []), error => {
|
|
411
|
+
instance.rebuild(Array.from(modifiedFiles || []), Array.from(removedFiles || []), error => {
|
|
419
412
|
if (error) {
|
|
420
413
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
421
414
|
}
|
|
@@ -425,11 +418,13 @@ class Compiler {
|
|
|
425
418
|
}
|
|
426
419
|
compile(callback) {
|
|
427
420
|
const startTime = Date.now();
|
|
428
|
-
this
|
|
421
|
+
const params = __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_newCompilationParams).call(this);
|
|
422
|
+
this.hooks.beforeCompile.callAsync(params, (err) => {
|
|
429
423
|
if (err) {
|
|
430
424
|
return callback(err);
|
|
431
425
|
}
|
|
432
|
-
this.hooks.compile.call(
|
|
426
|
+
this.hooks.compile.call(params);
|
|
427
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_resetThisCompilation).call(this);
|
|
433
428
|
this.build(err => {
|
|
434
429
|
if (err) {
|
|
435
430
|
return callback(err);
|
|
@@ -462,14 +457,6 @@ class Compiler {
|
|
|
462
457
|
}
|
|
463
458
|
}
|
|
464
459
|
close(callback) {
|
|
465
|
-
// WARNING: Arbitrarily dropping the instance is not safe, as it may still be in use by the background thread.
|
|
466
|
-
// A hint is necessary for the compiler to know when it is safe to drop the instance.
|
|
467
|
-
// For example: register a callback to the background thread, and drop the instance when the callback is called (calling the `close` method queues the signal)
|
|
468
|
-
// See: https://github.com/webpack/webpack/blob/4ba225225b1348c8776ca5b5fe53468519413bc0/lib/Compiler.js#L1218
|
|
469
|
-
if (!this.running) {
|
|
470
|
-
// Manually drop the instance.
|
|
471
|
-
// this.#instance = undefined;
|
|
472
|
-
}
|
|
473
460
|
if (this.watching) {
|
|
474
461
|
// When there is still an active watching, close this first
|
|
475
462
|
this.watching.close(() => {
|
|
@@ -516,19 +503,11 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
516
503
|
const rawOptions = (0, config_1.getRawOptions)(options, this);
|
|
517
504
|
const instanceBinding = require("@rspack/binding");
|
|
518
505
|
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, {
|
|
519
|
-
beforeCompile: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_beforeCompile).bind(this),
|
|
520
|
-
afterCompile: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterCompile).bind(this),
|
|
521
506
|
finishMake: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_finishMake).bind(this),
|
|
522
|
-
shouldEmit: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_shouldEmit).bind(this),
|
|
523
507
|
emit: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_emit).bind(this),
|
|
524
508
|
assetEmitted: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_assetEmitted).bind(this),
|
|
525
509
|
afterEmit: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterEmit).bind(this),
|
|
526
510
|
afterProcessAssets: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterProcessAssets).bind(this),
|
|
527
|
-
// `Compilation` should be created with hook `thisCompilation`, and here is the reason:
|
|
528
|
-
// We know that the hook `thisCompilation` will not be called from a child compiler(it doesn't matter whether the child compiler is created on the Rust or the Node side).
|
|
529
|
-
// See webpack's API: https://webpack.js.org/api/compiler-hooks/#thiscompilation
|
|
530
|
-
// So it is safe to create a new compilation here.
|
|
531
|
-
thisCompilation: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_newCompilation).bind(this),
|
|
532
511
|
optimizeModules: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_optimizeModules).bind(this),
|
|
533
512
|
afterOptimizeModules: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterOptimizeModules).bind(this),
|
|
534
513
|
optimizeTree: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_optimizeTree).bind(this),
|
|
@@ -537,7 +516,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
537
516
|
normalModuleFactoryCreateModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryCreateModule).bind(this),
|
|
538
517
|
normalModuleFactoryResolveForScheme: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryResolveForScheme).bind(this),
|
|
539
518
|
chunkAsset: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_chunkAsset).bind(this),
|
|
540
|
-
beforeResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_beforeResolve).bind(this),
|
|
541
519
|
afterResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterResolve).bind(this),
|
|
542
520
|
contextModuleFactoryBeforeResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_contextModuleFactoryBeforeResolve).bind(this),
|
|
543
521
|
contextModuleFactoryAfterResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_contextModuleFactoryAfterResolve).bind(this),
|
|
@@ -547,19 +525,36 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
547
525
|
executeModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_executeModule).bind(this),
|
|
548
526
|
runtimeModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_runtimeModule).bind(this)
|
|
549
527
|
}, {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
528
|
+
registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.thisCompilation, queried => (native) => {
|
|
529
|
+
if (this.compilation === undefined) {
|
|
530
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createCompilation).call(this, native);
|
|
531
|
+
}
|
|
532
|
+
queried.call(this.compilation, this.compilationParams);
|
|
533
|
+
}),
|
|
534
|
+
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.compilation, queried => () => queried.call(this.compilation, this.compilationParams)),
|
|
535
|
+
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.make, queried => async () => await queried.promise(this.compilation)),
|
|
536
|
+
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.shouldEmit, queried => () => queried.call(this.compilation)),
|
|
537
|
+
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.processAssets, queried => async () => await queried.promise(this.compilation.assets)),
|
|
538
|
+
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
539
|
+
const normalizedResolveData = {
|
|
540
|
+
request: resolveData.request,
|
|
541
|
+
context: resolveData.context,
|
|
542
|
+
fileDependencies: [],
|
|
543
|
+
missingDependencies: [],
|
|
544
|
+
contextDependencies: []
|
|
545
|
+
};
|
|
546
|
+
const ret = await queried.promise(normalizedResolveData);
|
|
547
|
+
resolveData.request = normalizedResolveData.request;
|
|
548
|
+
resolveData.context = normalizedResolveData.context;
|
|
549
|
+
return [ret, resolveData];
|
|
550
|
+
})
|
|
551
|
+
}, (0, fileSystem_1.createThreadsafeNodeFSFromRaw)(this.outputFileSystem)), "f");
|
|
554
552
|
callback(null, __classPrivateFieldGet(this, _Compiler_instance, "f"));
|
|
555
553
|
}, _Compiler_updateDisabledHooks = function _Compiler_updateDisabledHooks(callback) {
|
|
556
|
-
var _a, _b, _c, _d, _e
|
|
554
|
+
var _a, _b, _c, _d, _e;
|
|
557
555
|
const disabledHooks = [];
|
|
558
556
|
const hookMap = {
|
|
559
|
-
beforeCompile: this.hooks.beforeCompile,
|
|
560
|
-
afterCompile: this.hooks.afterCompile,
|
|
561
557
|
finishMake: this.hooks.finishMake,
|
|
562
|
-
shouldEmit: this.hooks.shouldEmit,
|
|
563
558
|
emit: this.hooks.emit,
|
|
564
559
|
assetEmitted: this.hooks.assetEmitted,
|
|
565
560
|
afterEmit: this.hooks.afterEmit,
|
|
@@ -569,19 +564,15 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
569
564
|
optimizeModules: this.compilation.hooks.optimizeModules,
|
|
570
565
|
afterOptimizeModules: this.compilation.hooks.afterOptimizeModules,
|
|
571
566
|
chunkAsset: this.compilation.hooks.chunkAsset,
|
|
572
|
-
|
|
573
|
-
afterResolve: (_b = this.compilation.normalModuleFactory) === null || _b === void 0 ? void 0 : _b.hooks.afterResolve,
|
|
567
|
+
afterResolve: (_a = this.compilationParams) === null || _a === void 0 ? void 0 : _a.normalModuleFactory.hooks.afterResolve,
|
|
574
568
|
succeedModule: this.compilation.hooks.succeedModule,
|
|
575
569
|
stillValidModule: this.compilation.hooks.stillValidModule,
|
|
576
570
|
buildModule: this.compilation.hooks.buildModule,
|
|
577
|
-
// various of hooks are called inside `#newCompilation`, we shouldn't prevent `#newCompilation` from calling even when `thisCompilation` is not tapped.
|
|
578
|
-
// issue: https://github.com/web-infra-dev/rspack/issues/5398
|
|
579
|
-
thisCompilation: undefined,
|
|
580
571
|
optimizeChunkModules: this.compilation.hooks.optimizeChunkModules,
|
|
581
|
-
contextModuleFactoryBeforeResolve: (
|
|
582
|
-
contextModuleFactoryAfterResolve: (
|
|
583
|
-
normalModuleFactoryCreateModule: (
|
|
584
|
-
normalModuleFactoryResolveForScheme: (
|
|
572
|
+
contextModuleFactoryBeforeResolve: (_b = this.compilationParams) === null || _b === void 0 ? void 0 : _b.contextModuleFactory.hooks.beforeResolve,
|
|
573
|
+
contextModuleFactoryAfterResolve: (_c = this.compilationParams) === null || _c === void 0 ? void 0 : _c.contextModuleFactory.hooks.afterResolve,
|
|
574
|
+
normalModuleFactoryCreateModule: (_d = this.compilationParams) === null || _d === void 0 ? void 0 : _d.normalModuleFactory.hooks.createModule,
|
|
575
|
+
normalModuleFactoryResolveForScheme: (_e = this.compilationParams) === null || _e === void 0 ? void 0 : _e.normalModuleFactory.hooks.resolveForScheme,
|
|
585
576
|
executeModule: undefined,
|
|
586
577
|
runtimeModule: this.compilation.hooks.runtimeModule
|
|
587
578
|
};
|
|
@@ -601,17 +592,10 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
601
592
|
if (error) {
|
|
602
593
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
603
594
|
}
|
|
604
|
-
instance.
|
|
595
|
+
instance.setDisabledHooks(disabledHooks);
|
|
605
596
|
__classPrivateFieldSet(this, _Compiler_disabledHooks, disabledHooks, "f");
|
|
606
597
|
});
|
|
607
598
|
}
|
|
608
|
-
}, _Compiler_beforeCompile = async function _Compiler_beforeCompile() {
|
|
609
|
-
await this.hooks.beforeCompile.promise();
|
|
610
|
-
// compilation is not created yet, so this will fail
|
|
611
|
-
// this.#updateDisabledHooks();
|
|
612
|
-
}, _Compiler_afterCompile = async function _Compiler_afterCompile() {
|
|
613
|
-
await this.hooks.afterCompile.promise(this.compilation);
|
|
614
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
615
599
|
}, _Compiler_finishMake = async function _Compiler_finishMake() {
|
|
616
600
|
await this.hooks.finishMake.promise(this.compilation);
|
|
617
601
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
@@ -622,23 +606,8 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
622
606
|
}, _Compiler_afterProcessAssets = async function _Compiler_afterProcessAssets() {
|
|
623
607
|
await this.compilation.hooks.afterProcessAssets.promise(this.compilation.assets);
|
|
624
608
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
625
|
-
}, _Compiler_beforeResolve = async function _Compiler_beforeResolve(resolveData) {
|
|
626
|
-
var _a;
|
|
627
|
-
const normalizedResolveData = {
|
|
628
|
-
request: resolveData.request,
|
|
629
|
-
context: resolveData.context,
|
|
630
|
-
fileDependencies: [],
|
|
631
|
-
missingDependencies: [],
|
|
632
|
-
contextDependencies: []
|
|
633
|
-
};
|
|
634
|
-
let ret = await ((_a = this.compilation.normalModuleFactory) === null || _a === void 0 ? void 0 : _a.hooks.beforeResolve.promise(normalizedResolveData));
|
|
635
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
636
|
-
resolveData.request = normalizedResolveData.request;
|
|
637
|
-
resolveData.context = normalizedResolveData.context;
|
|
638
|
-
return [ret, resolveData];
|
|
639
609
|
}, _Compiler_afterResolve = async function _Compiler_afterResolve(resolveData) {
|
|
640
|
-
|
|
641
|
-
let res = await ((_a = this.compilation.normalModuleFactory) === null || _a === void 0 ? void 0 : _a.hooks.afterResolve.promise(resolveData));
|
|
610
|
+
let res = await this.compilationParams.normalModuleFactory.hooks.afterResolve.promise(resolveData);
|
|
642
611
|
NormalModule_1.NormalModule.getCompilationHooks(this.compilation).loader.tap("sideEffectFreePropPlugin", (loaderContext) => {
|
|
643
612
|
loaderContext._module = {
|
|
644
613
|
factoryMeta: {
|
|
@@ -647,29 +616,25 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
647
616
|
};
|
|
648
617
|
});
|
|
649
618
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
650
|
-
return res;
|
|
619
|
+
return [res, resolveData.createData];
|
|
651
620
|
}, _Compiler_contextModuleFactoryBeforeResolve = async function _Compiler_contextModuleFactoryBeforeResolve(resourceData) {
|
|
652
|
-
|
|
653
|
-
let res = await ((_a = this.compilation.contextModuleFactory) === null || _a === void 0 ? void 0 : _a.hooks.beforeResolve.promise(resourceData));
|
|
621
|
+
let res = await this.compilationParams.contextModuleFactory.hooks.beforeResolve.promise(resourceData);
|
|
654
622
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
655
623
|
return res;
|
|
656
624
|
}, _Compiler_contextModuleFactoryAfterResolve = async function _Compiler_contextModuleFactoryAfterResolve(resourceData) {
|
|
657
|
-
|
|
658
|
-
let res = await ((_a = this.compilation.contextModuleFactory) === null || _a === void 0 ? void 0 : _a.hooks.afterResolve.promise(resourceData));
|
|
625
|
+
let res = await this.compilationParams.contextModuleFactory.hooks.afterResolve.promise(resourceData);
|
|
659
626
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
660
627
|
return res;
|
|
661
628
|
}, _Compiler_normalModuleFactoryCreateModule = async function _Compiler_normalModuleFactoryCreateModule(createData) {
|
|
662
|
-
var _a;
|
|
663
629
|
const data = Object.assign({}, createData, {
|
|
664
630
|
settings: {},
|
|
665
631
|
matchResource: createData.resourceResolveData.resource
|
|
666
632
|
});
|
|
667
|
-
const nmfHooks =
|
|
633
|
+
const nmfHooks = this.compilationParams.normalModuleFactory.hooks;
|
|
668
634
|
await (nmfHooks === null || nmfHooks === void 0 ? void 0 : nmfHooks.createModule.promise(data, {}));
|
|
669
635
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
670
636
|
}, _Compiler_normalModuleFactoryResolveForScheme = async function _Compiler_normalModuleFactoryResolveForScheme(input) {
|
|
671
|
-
|
|
672
|
-
let stop = await ((_a = this.compilation.normalModuleFactory) === null || _a === void 0 ? void 0 : _a.hooks.resolveForScheme.for(input.scheme).promise(input.resourceData));
|
|
637
|
+
let stop = await this.compilationParams.normalModuleFactory.hooks.resolveForScheme.for(input.scheme).promise(input.resourceData);
|
|
673
638
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
674
639
|
return {
|
|
675
640
|
resourceData: input.resourceData,
|
|
@@ -693,10 +658,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
693
658
|
}, _Compiler_finishModules = async function _Compiler_finishModules() {
|
|
694
659
|
await this.compilation.hooks.finishModules.promise(this.compilation.modules);
|
|
695
660
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
696
|
-
}, _Compiler_shouldEmit = async function _Compiler_shouldEmit() {
|
|
697
|
-
const res = this.hooks.shouldEmit.call(this.compilation);
|
|
698
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
699
|
-
return Promise.resolve(res);
|
|
700
661
|
}, _Compiler_emit = async function _Compiler_emit() {
|
|
701
662
|
await this.hooks.emit.promise(this.compilation);
|
|
702
663
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
@@ -778,89 +739,65 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
778
739
|
if (jsTaps.length > 0) {
|
|
779
740
|
const last = jsTaps[jsTaps.length - 1];
|
|
780
741
|
const old = last.function;
|
|
781
|
-
last.function =
|
|
782
|
-
|
|
742
|
+
last.function = (...args) => {
|
|
743
|
+
const result = old(...args);
|
|
744
|
+
if (result && typeof result.then === "function") {
|
|
745
|
+
return result.then((r) => {
|
|
746
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
747
|
+
return r;
|
|
748
|
+
});
|
|
749
|
+
}
|
|
783
750
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
751
|
+
return result;
|
|
784
752
|
};
|
|
785
753
|
}
|
|
786
|
-
},
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const jsTaps = [];
|
|
814
|
-
for (let i = 0; i < breakpoints.length - 1; i++) {
|
|
815
|
-
const from = breakpoints[i];
|
|
816
|
-
const to = breakpoints[i + 1];
|
|
817
|
-
const stageRange = [from, to];
|
|
818
|
-
const queried = this.hooks.make.queryStageRange(stageRange);
|
|
819
|
-
if (!queried.isUsed())
|
|
820
|
-
continue;
|
|
821
|
-
jsTaps.push({
|
|
822
|
-
function: async () => {
|
|
823
|
-
await queried.promise(this.compilation);
|
|
824
|
-
},
|
|
825
|
-
stage: liteTapable.safeStage(from + 1)
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_decorateUpdateDisabledHooks).call(this, jsTaps);
|
|
829
|
-
return jsTaps;
|
|
830
|
-
}, _Compiler_registerCompilationProcessAssetsTaps = function _Compiler_registerCompilationProcessAssetsTaps(stages) {
|
|
831
|
-
if (!this.compilation.hooks.processAssets.isUsed())
|
|
832
|
-
return [];
|
|
833
|
-
const breakpoints = [liteTapable.minStage, ...stages, liteTapable.maxStage];
|
|
834
|
-
const jsTaps = [];
|
|
835
|
-
for (let i = 0; i < breakpoints.length - 1; i++) {
|
|
836
|
-
const from = breakpoints[i];
|
|
837
|
-
const to = breakpoints[i + 1];
|
|
838
|
-
const stageRange = [from, to];
|
|
839
|
-
const queried = this.compilation.hooks.processAssets.queryStageRange(stageRange);
|
|
840
|
-
if (!queried.isUsed())
|
|
841
|
-
continue;
|
|
842
|
-
jsTaps.push({
|
|
843
|
-
function: async () => {
|
|
844
|
-
await queried.promise(this.compilation.assets);
|
|
845
|
-
},
|
|
846
|
-
stage: liteTapable.safeStage(from + 1)
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_decorateUpdateDisabledHooks).call(this, jsTaps);
|
|
850
|
-
return jsTaps;
|
|
851
|
-
}, _Compiler_newCompilation = function _Compiler_newCompilation(native) {
|
|
754
|
+
}, _Compiler_createRegisterTaps = function _Compiler_createRegisterTaps(getHook, createTap) {
|
|
755
|
+
return stages => {
|
|
756
|
+
const hook = getHook();
|
|
757
|
+
if (!hook.isUsed())
|
|
758
|
+
return [];
|
|
759
|
+
const breakpoints = [
|
|
760
|
+
liteTapable.minStage,
|
|
761
|
+
...stages,
|
|
762
|
+
liteTapable.maxStage
|
|
763
|
+
];
|
|
764
|
+
const jsTaps = [];
|
|
765
|
+
for (let i = 0; i < breakpoints.length - 1; i++) {
|
|
766
|
+
const from = breakpoints[i];
|
|
767
|
+
const to = breakpoints[i + 1];
|
|
768
|
+
const stageRange = [from, to];
|
|
769
|
+
const queried = hook.queryStageRange(stageRange);
|
|
770
|
+
if (!queried.isUsed())
|
|
771
|
+
continue;
|
|
772
|
+
jsTaps.push({
|
|
773
|
+
function: createTap(queried),
|
|
774
|
+
stage: liteTapable.safeStage(from + 1)
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_decorateUpdateDisabledHooks).call(this, jsTaps);
|
|
778
|
+
return jsTaps;
|
|
779
|
+
};
|
|
780
|
+
}, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
|
|
852
781
|
const compilation = new Compilation_1.Compilation(this, native);
|
|
853
782
|
compilation.name = this.name;
|
|
854
783
|
this.compilation = compilation;
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
this.compilation
|
|
784
|
+
return compilation;
|
|
785
|
+
}, _Compiler_resetThisCompilation = function _Compiler_resetThisCompilation() {
|
|
786
|
+
// reassign new compilation in thisCompilation
|
|
787
|
+
this.compilation = undefined;
|
|
788
|
+
// ensure thisCompilation must call
|
|
789
|
+
this.hooks.thisCompilation.intercept({
|
|
790
|
+
call: () => { }
|
|
791
|
+
});
|
|
792
|
+
}, _Compiler_newCompilationParams = function _Compiler_newCompilationParams() {
|
|
793
|
+
const normalModuleFactory = new NormalModuleFactory_1.NormalModuleFactory();
|
|
859
794
|
this.hooks.normalModuleFactory.call(normalModuleFactory);
|
|
860
|
-
|
|
795
|
+
const contextModuleFactory = new ContextModuleFactory_1.ContextModuleFactory();
|
|
861
796
|
this.hooks.contextModuleFactory.call(contextModuleFactory);
|
|
862
|
-
|
|
863
|
-
normalModuleFactory
|
|
864
|
-
|
|
865
|
-
|
|
797
|
+
const params = {
|
|
798
|
+
normalModuleFactory,
|
|
799
|
+
contextModuleFactory
|
|
800
|
+
};
|
|
801
|
+
this.compilationParams = params;
|
|
802
|
+
return params;
|
|
866
803
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AsyncSeriesBailHook, HookMap } from "tapable";
|
|
2
|
+
import * as liteTapable from "./lite-tapable";
|
|
2
3
|
import type * as binding from "@rspack/binding";
|
|
3
4
|
type ResourceData = {
|
|
4
5
|
resource: string;
|
|
@@ -23,7 +24,7 @@ type CreateModuleData = binding.CreateModuleData & {
|
|
|
23
24
|
export declare class NormalModuleFactory {
|
|
24
25
|
hooks: {
|
|
25
26
|
resolveForScheme: HookMap<AsyncSeriesBailHook<[ResourceDataWithData], true | void>>;
|
|
26
|
-
beforeResolve: AsyncSeriesBailHook<[ResolveData],
|
|
27
|
+
beforeResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
|
|
27
28
|
afterResolve: AsyncSeriesBailHook<[ResolveData], boolean | void>;
|
|
28
29
|
createModule: AsyncSeriesBailHook<[CreateModuleData, {}], void>;
|
|
29
30
|
};
|
|
@@ -1,7 +1,31 @@
|
|
|
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
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.NormalModuleFactory = void 0;
|
|
4
27
|
const tapable_1 = require("tapable");
|
|
28
|
+
const liteTapable = __importStar(require("./lite-tapable"));
|
|
5
29
|
class NormalModuleFactory {
|
|
6
30
|
constructor() {
|
|
7
31
|
this.hooks = {
|
|
@@ -16,7 +40,7 @@ class NormalModuleFactory {
|
|
|
16
40
|
// /** @type {AsyncSeriesBailHook<[ResolveData], Module>} */
|
|
17
41
|
// factorize: new AsyncSeriesBailHook(["resolveData"]),
|
|
18
42
|
// /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
|
|
19
|
-
beforeResolve: new
|
|
43
|
+
beforeResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
|
|
20
44
|
// /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
|
|
21
45
|
afterResolve: new tapable_1.AsyncSeriesBailHook(["resolveData"]),
|
|
22
46
|
// /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void>} */
|
package/dist/Watching.js
CHANGED
|
@@ -254,13 +254,13 @@ _Watching_invalidReported = new WeakMap(), _Watching_closeCallbacks = new WeakMa
|
|
|
254
254
|
if (err)
|
|
255
255
|
return this._done(err, null);
|
|
256
256
|
const canRebuild = !__classPrivateFieldGet(this, _Watching_initial, "f") && ((modifiedFiles === null || modifiedFiles === void 0 ? void 0 : modifiedFiles.size) || (deleteFiles === null || deleteFiles === void 0 ? void 0 : deleteFiles.size));
|
|
257
|
-
const
|
|
257
|
+
const onCompile = (err) => {
|
|
258
258
|
if (err)
|
|
259
259
|
return this._done(err, null);
|
|
260
260
|
// if (this.invalid) return this._done(null);
|
|
261
261
|
this._done(null, this.compiler.compilation);
|
|
262
262
|
};
|
|
263
|
-
this.compiler.
|
|
263
|
+
this.compiler.compile(onCompile);
|
|
264
264
|
if (!canRebuild) {
|
|
265
265
|
__classPrivateFieldSet(this, _Watching_initial, false, "f");
|
|
266
266
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BuiltinPluginName } from "@rspack/binding";
|
|
2
|
+
import { Compiler } from "../Compiler";
|
|
3
|
+
export declare const JsLoaderRspackPlugin: {
|
|
4
|
+
new (compiler: Compiler): {
|
|
5
|
+
name: BuiltinPluginName;
|
|
6
|
+
_options: (rawContext: import("@rspack/binding").JsLoaderContext) => Promise<import("@rspack/binding").JsLoaderResult>;
|
|
7
|
+
affectedHooks: "emit" | "done" | "compilation" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
|
|
8
|
+
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsLoaderRspackPlugin = void 0;
|
|
4
|
+
const binding_1 = require("@rspack/binding");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
const loader_runner_1 = require("../loader-runner");
|
|
7
|
+
exports.JsLoaderRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.JsLoaderRspackPlugin, (compiler) => loader_runner_1.runLoaders.bind(null, compiler), "compilation");
|
|
@@ -50,6 +50,7 @@ export * from "./HtmlRspackPlugin";
|
|
|
50
50
|
export * from "./CopyRspackPlugin";
|
|
51
51
|
export * from "./SwcJsMinimizerPlugin";
|
|
52
52
|
export * from "./SwcCssMinimizerPlugin";
|
|
53
|
+
export * from "./JsLoaderRspackPlugin";
|
|
53
54
|
import { RawBuiltins, RawCssModulesConfig } from "@rspack/binding";
|
|
54
55
|
import { RspackOptionsNormalized } from "..";
|
|
55
56
|
type BuiltinsCssConfig = {
|
|
@@ -68,6 +68,7 @@ __exportStar(require("./HtmlRspackPlugin"), exports);
|
|
|
68
68
|
__exportStar(require("./CopyRspackPlugin"), exports);
|
|
69
69
|
__exportStar(require("./SwcJsMinimizerPlugin"), exports);
|
|
70
70
|
__exportStar(require("./SwcCssMinimizerPlugin"), exports);
|
|
71
|
+
__exportStar(require("./JsLoaderRspackPlugin"), exports);
|
|
71
72
|
function resolveTreeShaking(treeShaking, production) {
|
|
72
73
|
return treeShaking !== undefined
|
|
73
74
|
? treeShaking.toString()
|