@rspack/core
Advanced tools
Comparing version 0.6.5-canary-73c31ab-20240510004618 to 0.6.5-canary-d1f53fd-20240511004704
@@ -612,23 +612,29 @@ "use strict"; | ||
}), | ||
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => this.compilationParams.contextModuleFactory.hooks.beforeResolve, queried => async (arg) => { | ||
const data = { | ||
request: arg.request, | ||
context: arg.context, | ||
fileDependencies: [], | ||
missingDependencies: [], | ||
contextDependencies: [] | ||
}; | ||
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => this.compilationParams.contextModuleFactory.hooks.beforeResolve, queried => async (bindingData) => { | ||
return queried.promise(bindingData); | ||
}), | ||
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () => this.compilationParams.contextModuleFactory.hooks.afterResolve, queried => async (bindingData) => { | ||
var _a; | ||
const data = bindingData | ||
? ({ | ||
resource: bindingData.resource, | ||
regExp: bindingData.regExp | ||
? new RegExp(bindingData.regExp) | ||
: undefined, | ||
request: bindingData.request, | ||
context: bindingData.context, | ||
// TODO: Dependencies are not fully supported yet; this is a placeholder to prevent errors in moment-locales-webpack-plugin. | ||
dependencies: [] | ||
}) | ||
: false; | ||
const ret = await queried.promise(data); | ||
return [ret, data]; | ||
}), | ||
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () => this.compilationParams.contextModuleFactory.hooks.afterResolve, queried => async (arg) => { | ||
const data = { | ||
request: arg.request, | ||
context: arg.context, | ||
fileDependencies: arg.fileDependencies, | ||
missingDependencies: arg.missingDependencies, | ||
contextDependencies: arg.contextDependencies, | ||
createData: arg.createData | ||
}; | ||
return await queried.promise(data); | ||
const result = ret | ||
? ({ | ||
resource: ret.resource, | ||
context: ret.context, | ||
request: ret.request, | ||
regExp: (_a = ret.regExp) === null || _a === void 0 ? void 0 : _a.toString() | ||
}) | ||
: false; | ||
return result; | ||
}) | ||
@@ -635,0 +641,0 @@ }, "f"); |
import * as liteTapable from "./lite-tapable"; | ||
import { ResolveData } from "./Module"; | ||
import { ContextModuleFactoryAfterResolveResult, ContextModuleFactoryBeforeResolveResult } from "./Module"; | ||
export declare class ContextModuleFactory { | ||
hooks: { | ||
beforeResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>; | ||
afterResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>; | ||
beforeResolve: liteTapable.AsyncSeriesWaterfallHook<[ | ||
ContextModuleFactoryBeforeResolveResult | ||
], ContextModuleFactoryBeforeResolveResult | void>; | ||
afterResolve: liteTapable.AsyncSeriesWaterfallHook<[ | ||
ContextModuleFactoryAfterResolveResult | ||
], ContextModuleFactoryAfterResolveResult | void>; | ||
}; | ||
constructor(); | ||
} |
@@ -44,4 +44,4 @@ "use strict"; | ||
// /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */ | ||
beforeResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]), | ||
afterResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]) | ||
beforeResolve: new liteTapable.AsyncSeriesWaterfallHook(["resolveData"]), | ||
afterResolve: new liteTapable.AsyncSeriesWaterfallHook(["resolveData"]) | ||
// /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void>} */ | ||
@@ -48,0 +48,0 @@ // createModule: new AsyncSeriesBailHook(["createData", "resolveData"]), |
@@ -62,5 +62,7 @@ declare const rspackVersion: any, webpackVersion: any; | ||
import { NodeTargetPlugin } from "./builtin-plugin"; | ||
import NodeEnvironmentPlugin from "./node/NodeEnvironmentPlugin"; | ||
interface Node { | ||
NodeTargetPlugin: typeof NodeTargetPlugin; | ||
NodeTemplatePlugin: typeof NodeTemplatePlugin; | ||
NodeEnvironmentPlugin: typeof NodeEnvironmentPlugin; | ||
} | ||
@@ -67,0 +69,0 @@ export declare const node: Node; |
@@ -103,3 +103,8 @@ "use strict"; | ||
const builtin_plugin_10 = require("./builtin-plugin"); | ||
exports.node = { NodeTargetPlugin: builtin_plugin_10.NodeTargetPlugin, NodeTemplatePlugin: NodeTemplatePlugin_1.default }; | ||
const NodeEnvironmentPlugin_1 = __importDefault(require("./node/NodeEnvironmentPlugin")); | ||
exports.node = { | ||
NodeTargetPlugin: builtin_plugin_10.NodeTargetPlugin, | ||
NodeTemplatePlugin: NodeTemplatePlugin_1.default, | ||
NodeEnvironmentPlugin: NodeEnvironmentPlugin_1.default | ||
}; | ||
const builtin_plugin_11 = require("./builtin-plugin"); | ||
@@ -106,0 +111,0 @@ exports.electron = { ElectronTargetPlugin: builtin_plugin_11.ElectronTargetPlugin }; |
@@ -115,2 +115,8 @@ type FixedSizeArray<T extends number, U> = T extends 0 ? void[] : ReadonlyArray<U> & { | ||
} | ||
export declare class AsyncSeriesWaterfallHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> { | ||
constructor(args?: ArgumentNames<AsArray<T>>, name?: string); | ||
callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void; | ||
tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void; | ||
tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void; | ||
} | ||
export type HookMapKey = any; | ||
@@ -117,0 +123,0 @@ export type HookFactory<H> = (key: HookMapKey, hook?: H) => H; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.QueriedHookMap = exports.HookMap = exports.AsyncSeriesBailHook = exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncBailHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = exports.Hook = void 0; | ||
exports.QueriedHookMap = exports.HookMap = exports.AsyncSeriesWaterfallHook = exports.AsyncSeriesBailHook = exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncBailHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = exports.Hook = void 0; | ||
class Hook { | ||
@@ -581,2 +581,108 @@ constructor(args, name) { | ||
exports.AsyncSeriesBailHook = AsyncSeriesBailHook; | ||
class AsyncSeriesWaterfallHook extends Hook { | ||
constructor(args, name) { | ||
if (!(args === null || args === void 0 ? void 0 : args.length)) | ||
throw new Error("Waterfall hooks must have at least one argument"); | ||
super(args, name); | ||
} | ||
callAsyncStageRange(queried, ...args) { | ||
const { stageRange: [from, to], tapsInRange } = queried; | ||
let data = args[0]; | ||
const cb = args[1]; | ||
if (from === exports.minStage) { | ||
this._runCallInterceptors(data); | ||
} | ||
const done = () => { | ||
this._runDoneInterceptors(); | ||
cb(null, data); | ||
}; | ||
const error = (e) => { | ||
this._runErrorInterceptors(e); | ||
cb(e); | ||
}; | ||
if (tapsInRange.length === 0) | ||
return done(); | ||
let index = 0; | ||
const next = () => { | ||
const tap = tapsInRange[index]; | ||
this._runTapInterceptors(tap); | ||
if (tap.type === "promise") { | ||
const promise = tap.fn(data); | ||
if (!promise || !promise.then) { | ||
throw new Error("Tap function (tapPromise) did not return promise (returned " + | ||
promise + | ||
")"); | ||
} | ||
promise.then((r) => { | ||
index += 1; | ||
if (r !== undefined) { | ||
data = r; | ||
} | ||
if (index === tapsInRange.length) { | ||
done(); | ||
} | ||
else { | ||
next(); | ||
} | ||
}, (e) => { | ||
index = tapsInRange.length; | ||
error(e); | ||
}); | ||
} | ||
else if (tap.type === "async") { | ||
tap.fn(data, (e, r) => { | ||
if (e) { | ||
index = tapsInRange.length; | ||
error(e); | ||
} | ||
else { | ||
index += 1; | ||
if (r !== undefined) { | ||
data = r; | ||
} | ||
if (index === tapsInRange.length) { | ||
done(); | ||
} | ||
else { | ||
next(); | ||
} | ||
} | ||
}); | ||
} | ||
else { | ||
let hasError = false; | ||
try { | ||
const r = tap.fn(data); | ||
if (r !== undefined) { | ||
data = r; | ||
} | ||
} | ||
catch (e) { | ||
hasError = true; | ||
index = tapsInRange.length; | ||
error(e); | ||
} | ||
if (!hasError) { | ||
index += 1; | ||
if (index === tapsInRange.length) { | ||
done(); | ||
} | ||
else { | ||
next(); | ||
} | ||
} | ||
} | ||
if (index === tapsInRange.length) | ||
return; | ||
}; | ||
next(); | ||
} | ||
tapAsync(options, fn) { | ||
this._tap("async", options, fn); | ||
} | ||
tapPromise(options, fn) { | ||
this._tap("promise", options, fn); | ||
} | ||
} | ||
exports.AsyncSeriesWaterfallHook = AsyncSeriesWaterfallHook; | ||
const defaultFactory = (key, hook) => hook; | ||
@@ -583,0 +689,0 @@ class HookMap { |
@@ -21,2 +21,13 @@ import { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsModule } from "@rspack/binding"; | ||
}; | ||
export type ContextModuleFactoryBeforeResolveResult = false | { | ||
context: string; | ||
request?: string; | ||
}; | ||
export type ContextModuleFactoryAfterResolveResult = false | { | ||
resource: string; | ||
context: string; | ||
request: string; | ||
regExp?: RegExp; | ||
dependencies: Array<any>; | ||
}; | ||
export declare class Module { | ||
@@ -23,0 +34,0 @@ #private; |
{ | ||
"name": "@rspack/core", | ||
"version": "0.6.5-canary-73c31ab-20240510004618", | ||
"version": "0.6.5-canary-d1f53fd-20240511004704", | ||
"webpackVersion": "5.75.0", | ||
@@ -74,4 +74,4 @@ "license": "MIT", | ||
"zod-validation-error": "1.3.1", | ||
"@rspack/core": "0.6.5-canary-73c31ab-20240510004618", | ||
"@rspack/plugin-minify": "^0.6.5-canary-73c31ab-20240510004618" | ||
"@rspack/core": "0.6.5-canary-d1f53fd-20240511004704", | ||
"@rspack/plugin-minify": "^0.6.5-canary-d1f53fd-20240511004704" | ||
}, | ||
@@ -84,3 +84,3 @@ "dependencies": { | ||
"webpack-sources": "3.2.3", | ||
"@rspack/binding": "0.6.5-canary-73c31ab-20240510004618" | ||
"@rspack/binding": "0.6.5-canary-d1f53fd-20240511004704" | ||
}, | ||
@@ -87,0 +87,0 @@ "peerDependencies": { |
2303282
58195
+ Added@rspack/binding@0.6.5-canary-d1f53fd-20240511004704(transitive)
+ Added@rspack/binding-darwin-arm64@0.6.5-canary-d1f53fd-20240511004704(transitive)
+ Added@rspack/binding-darwin-x64@0.6.5-canary-d1f53fd-20240511004704(transitive)
+ Added@rspack/binding-linux-arm64-gnu@0.6.5-canary-d1f53fd-20240511004704(transitive)
+ Added@rspack/binding-linux-arm64-musl@0.6.5-canary-d1f53fd-20240511004704(transitive)
+ Added@rspack/binding-linux-x64-gnu@0.6.5-canary-d1f53fd-20240511004704(transitive)
+ Added@rspack/binding-linux-x64-musl@0.6.5-canary-d1f53fd-20240511004704(transitive)
+ Added@rspack/binding-win32-arm64-msvc@0.6.5-canary-d1f53fd-20240511004704(transitive)
+ Added@rspack/binding-win32-ia32-msvc@0.6.5-canary-d1f53fd-20240511004704(transitive)
+ Added@rspack/binding-win32-x64-msvc@0.6.5-canary-d1f53fd-20240511004704(transitive)
- Removed@rspack/binding@0.6.5-canary-73c31ab-20240510004618(transitive)
- Removed@rspack/binding-darwin-arm64@0.6.5-canary-73c31ab-20240510004618(transitive)
- Removed@rspack/binding-darwin-x64@0.6.5-canary-73c31ab-20240510004618(transitive)
- Removed@rspack/binding-linux-arm64-gnu@0.6.5-canary-73c31ab-20240510004618(transitive)
- Removed@rspack/binding-linux-arm64-musl@0.6.5-canary-73c31ab-20240510004618(transitive)
- Removed@rspack/binding-linux-x64-gnu@0.6.5-canary-73c31ab-20240510004618(transitive)
- Removed@rspack/binding-linux-x64-musl@0.6.5-canary-73c31ab-20240510004618(transitive)
- Removed@rspack/binding-win32-arm64-msvc@0.6.5-canary-73c31ab-20240510004618(transitive)
- Removed@rspack/binding-win32-ia32-msvc@0.6.5-canary-73c31ab-20240510004618(transitive)
- Removed@rspack/binding-win32-x64-msvc@0.6.5-canary-73c31ab-20240510004618(transitive)