Update npm packages (73 packages including @jqhtml 2.3.36)
Update npm registry domain from privatenpm.hanson.xyz to npm.internal.hanson.xyz 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
143
node_modules/webpack/lib/library/ModuleLibraryPlugin.js
generated
vendored
143
node_modules/webpack/lib/library/ModuleLibraryPlugin.js
generated
vendored
@@ -7,11 +7,13 @@
|
||||
|
||||
const { ConcatSource } = require("webpack-sources");
|
||||
const { UsageState } = require("../ExportsInfo");
|
||||
const ExternalModule = require("../ExternalModule");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
const Template = require("../Template");
|
||||
const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
|
||||
const ConcatenatedModule = require("../optimize/ConcatenatedModule");
|
||||
const propertyAccess = require("../util/propertyAccess");
|
||||
const { getEntryRuntime } = require("../util/runtime");
|
||||
const { getEntryRuntime, getRuntimeKey } = require("../util/runtime");
|
||||
const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
@@ -20,11 +22,14 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
||||
/** @typedef {import("../../declarations/WebpackOptions").LibraryExport} LibraryExport */
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
||||
/** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */
|
||||
/** @typedef {import("../javascript/JavascriptModulesPlugin").ModuleRenderContext} ModuleRenderContext */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
@@ -76,17 +81,20 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
/** @type {BuildMeta} */
|
||||
const buildMeta = module.buildMeta || (module.buildMeta = {});
|
||||
|
||||
/** @type {BuildMeta["exportsSourceByRuntime"]} */
|
||||
const exportsSourceByRuntime =
|
||||
buildMeta.exportsSourceByRuntime ||
|
||||
(buildMeta.exportsSourceByRuntime = new Map());
|
||||
|
||||
/** @type {BuildMeta["exportsFinalNameByRuntime"]} */
|
||||
const exportsFinalNameByRuntime =
|
||||
buildMeta.exportsFinalNameByRuntime ||
|
||||
(buildMeta.exportsFinalNameByRuntime = new Map());
|
||||
|
||||
for (const runtime of runtimes) {
|
||||
exportsSourceByRuntime.set(runtime, source);
|
||||
exportsFinalNameByRuntime.set(runtime, finalName);
|
||||
const key = getRuntimeKey(runtime);
|
||||
exportsSourceByRuntime.set(key, source);
|
||||
exportsFinalNameByRuntime.set(key, finalName);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -116,8 +124,13 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
exportsInfo.canMangleUse = false;
|
||||
} else {
|
||||
const exportsInfo = moduleGraph.getExportsInfo(module);
|
||||
// If the entry module is commonjs, its exports cannot be mangled
|
||||
if (module.buildMeta && module.buildMeta.treatAsCommonJs) {
|
||||
|
||||
if (
|
||||
// If the entry module is commonjs, its exports cannot be mangled
|
||||
(module.buildMeta && module.buildMeta.treatAsCommonJs) ||
|
||||
// The entry module provides unknown exports
|
||||
exportsInfo._otherExportsInfo.provided === null
|
||||
) {
|
||||
exportsInfo.setUsedInUnknownWay(runtime);
|
||||
} else {
|
||||
exportsInfo.setAllKnownExportsUsed(runtime);
|
||||
@@ -128,7 +141,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
|
||||
/**
|
||||
* @param {LibraryOptions} library normalized library option
|
||||
* @returns {T | false} preprocess as needed by overriding
|
||||
* @returns {T} preprocess as needed by overriding
|
||||
*/
|
||||
parseOptions(library) {
|
||||
const { name } = library;
|
||||
@@ -144,6 +157,94 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Source} source source
|
||||
* @param {Module} module module
|
||||
* @param {ModuleGraph} moduleGraph moduleGraph
|
||||
* @param {RuntimeSpec} runtime chunk runtime
|
||||
* @param {[string, string][]} exports exports
|
||||
* @param {Set<string>} alreadyRenderedExports already rendered exports
|
||||
* @returns {ConcatSource} source with null provided exports
|
||||
*/
|
||||
_analyzeUnknownProvidedExports(
|
||||
source,
|
||||
module,
|
||||
moduleGraph,
|
||||
runtime,
|
||||
exports,
|
||||
alreadyRenderedExports
|
||||
) {
|
||||
const result = new ConcatSource(source);
|
||||
/** @type {Set<string>} */
|
||||
const moduleRequests = new Set();
|
||||
/** @type {Map<string, string>} */
|
||||
const unknownProvidedExports = new Map();
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {boolean} isDynamicReexport if module is dynamic reexported
|
||||
*/
|
||||
const resolveDynamicStarReexport = (module, isDynamicReexport) => {
|
||||
for (const connection of moduleGraph.getOutgoingConnections(module)) {
|
||||
const dep = connection.dependency;
|
||||
|
||||
// Only handle star-reexport statement
|
||||
if (
|
||||
dep instanceof HarmonyExportImportedSpecifierDependency &&
|
||||
dep.name === null
|
||||
) {
|
||||
const importedModule = connection.resolvedModule;
|
||||
const importedModuleExportsInfo =
|
||||
moduleGraph.getExportsInfo(importedModule);
|
||||
|
||||
// The imported module provides unknown exports
|
||||
// So keep the reexports rendered in the bundle
|
||||
if (
|
||||
dep.getMode(moduleGraph, runtime).type === "dynamic-reexport" &&
|
||||
importedModuleExportsInfo._otherExportsInfo.provided === null
|
||||
) {
|
||||
// Handle export * from 'external'
|
||||
if (importedModule instanceof ExternalModule) {
|
||||
moduleRequests.add(importedModule.userRequest);
|
||||
} else {
|
||||
resolveDynamicStarReexport(importedModule, true);
|
||||
}
|
||||
}
|
||||
// If importer modules existing `dynamic-reexport` dependency
|
||||
// We should keep export statement rendered in the bundle
|
||||
else if (isDynamicReexport) {
|
||||
for (const exportInfo of importedModuleExportsInfo.orderedExports) {
|
||||
if (!exportInfo.provided || exportInfo.name === "default") {
|
||||
continue;
|
||||
}
|
||||
const originalName = exportInfo.name;
|
||||
const usedName = exportInfo.getUsedName(originalName, runtime);
|
||||
|
||||
if (!alreadyRenderedExports.has(originalName) && usedName) {
|
||||
unknownProvidedExports.set(originalName, usedName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
resolveDynamicStarReexport(module, false);
|
||||
|
||||
for (const request of moduleRequests) {
|
||||
result.add(`export * from "${request}";\n`);
|
||||
}
|
||||
|
||||
for (const [origin, used] of unknownProvidedExports) {
|
||||
exports.push([
|
||||
origin,
|
||||
`${RuntimeGlobals.exports}${propertyAccess([used])}`
|
||||
]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Source} source source
|
||||
* @param {Module} module module
|
||||
@@ -164,9 +265,8 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
},
|
||||
{ options, compilation }
|
||||
) {
|
||||
const result = new ConcatSource(source);
|
||||
|
||||
const exportsInfo = options.export
|
||||
let result = new ConcatSource(source);
|
||||
const exportInfos = options.export
|
||||
? [
|
||||
moduleGraph.getExportInfo(
|
||||
module,
|
||||
@@ -178,7 +278,9 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
const exportsFinalNameByRuntime =
|
||||
(module.buildMeta &&
|
||||
module.buildMeta.exportsFinalNameByRuntime &&
|
||||
module.buildMeta.exportsFinalNameByRuntime.get(chunk.runtime)) ||
|
||||
module.buildMeta.exportsFinalNameByRuntime.get(
|
||||
getRuntimeKey(chunk.runtime)
|
||||
)) ||
|
||||
{};
|
||||
|
||||
const definitions =
|
||||
@@ -188,6 +290,9 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
const shortHandedExports = [];
|
||||
/** @type {[string, string][]} */
|
||||
const exports = [];
|
||||
/** @type {Set<string>} */
|
||||
const alreadyRenderedExports = new Set();
|
||||
|
||||
const isAsync = moduleGraph.isAsync(module);
|
||||
|
||||
const treatAsCommonJs =
|
||||
@@ -200,7 +305,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
);
|
||||
}
|
||||
|
||||
outer: for (const exportInfo of exportsInfo) {
|
||||
outer: for (const exportInfo of exportInfos) {
|
||||
if (!exportInfo.provided) continue;
|
||||
|
||||
const originalName = exportInfo.name;
|
||||
@@ -273,6 +378,8 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
: `${finalName} as ${originalName}`
|
||||
);
|
||||
}
|
||||
|
||||
alreadyRenderedExports.add(originalName);
|
||||
}
|
||||
|
||||
if (treatAsCommonJs) {
|
||||
@@ -283,6 +390,15 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
result.add(`export { ${shortHandedExports.join(", ")} };\n`);
|
||||
}
|
||||
|
||||
result = this._analyzeUnknownProvidedExports(
|
||||
result,
|
||||
module,
|
||||
moduleGraph,
|
||||
chunk.runtime,
|
||||
exports,
|
||||
alreadyRenderedExports
|
||||
);
|
||||
|
||||
for (const [exportName, final] of exports) {
|
||||
result.add(
|
||||
`export ${runtimeTemplate.renderConst()} ${exportName} = ${final};\n`
|
||||
@@ -308,9 +424,10 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||
const exportsSource =
|
||||
module.buildMeta &&
|
||||
module.buildMeta.exportsSourceByRuntime &&
|
||||
module.buildMeta.exportsSourceByRuntime.get(chunk.runtime);
|
||||
module.buildMeta.exportsSourceByRuntime.get(getRuntimeKey(chunk.runtime));
|
||||
|
||||
// Re-add the module's exports source when rendered in factory or as an inlined startup module wrapped in an IIFE
|
||||
// Re-add the module's exports source when rendered in factory
|
||||
// or as an inlined startup module wrapped in an IIFE
|
||||
if ((inlinedInIIFE || factory) && exportsSource) {
|
||||
return new ConcatSource(exportsSource, source);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user