mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 05:32:44 +00:00
fix(electron): retain unknown external module ownership (#7950)
This commit is contained in:
1 parent
3536ea2f49
commit
59a895a193
4 files changed
+77
-5
No files matched your search
@@ -741,7 +741,8 @@ const resolveReference = (
|
||||
targetPath !== undefined && isJsonModuleTarget(targetPath, targetKind);
|
||||
const targetImportsUnexamined =
|
||||
!targetIsJson &&
|
||||
(resolution.resolution_status === "unavailable" ||
|
||||
(resolution.unexamined_module_imports === true ||
|
||||
resolution.resolution_status === "unavailable" ||
|
||||
(path !== null &&
|
||||
!context.applicationModuleReferencesRetained.has(path)));
|
||||
if (path === null) {
|
||||
|
||||
@@ -4494,3 +4494,28 @@ describe("package metadata at archive module boundaries", () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("distinguishes an unobserved bare package from builtins and blocked aliases", () => {
|
||||
const files = aliasFiles({
|
||||
"package.json": JSON.stringify({
|
||||
imports: { "#blocked": null, "#builtin": "node:path" },
|
||||
}),
|
||||
"main.js": "",
|
||||
});
|
||||
const resolveName = (declaredPath: string) =>
|
||||
resolve({
|
||||
declaredPath,
|
||||
sourcePath: "main.js",
|
||||
context: "module-specifier",
|
||||
moduleKind: "require",
|
||||
files,
|
||||
});
|
||||
expect(resolveName("outside-package")).toMatchObject({
|
||||
resolution_status: "external",
|
||||
unexamined_module_imports: true,
|
||||
});
|
||||
for (const name of ["node:path", "electron", "#blocked", "#builtin"])
|
||||
expect(resolveName(name), name).not.toHaveProperty(
|
||||
"unexamined_module_imports",
|
||||
);
|
||||
});
|
||||
@@ -58,6 +58,8 @@ interface ArtifactPathResolutionBase {
|
||||
readonly limitations: readonly string[];
|
||||
readonly conditional_resolutions?: readonly ConditionalModuleResolution[];
|
||||
readonly candidate_path?: string;
|
||||
/** An external module can run code whose imports were not inventoried. */
|
||||
readonly unexamined_module_imports?: true;
|
||||
}
|
||||
|
||||
export interface ConditionalModuleResolution {
|
||||
@@ -192,6 +194,7 @@ type CandidateResolution = {
|
||||
readonly limitations: readonly string[];
|
||||
readonly candidatePath?: string;
|
||||
readonly conditionalResolutions?: readonly ConditionalModuleResolution[];
|
||||
readonly unexaminedModuleImports?: true;
|
||||
} & (
|
||||
| { readonly resolvedPath: string; readonly status: "resolved" }
|
||||
| {
|
||||
@@ -219,6 +222,9 @@ export const resolveArtifactPathByContext = (
|
||||
: {}),
|
||||
resolution_context: input.context,
|
||||
limitations: resolution.limitations,
|
||||
...(resolution.unexaminedModuleImports === true
|
||||
? { unexamined_module_imports: true as const }
|
||||
: {}),
|
||||
...(resolution.candidatePath === undefined
|
||||
? {}
|
||||
: { candidate_path: resolution.candidatePath }),
|
||||
@@ -339,6 +345,10 @@ const resolvePath = (input: ResolveArtifactPathInput): CandidateResolution => {
|
||||
return sameOutcome
|
||||
? {
|
||||
...imported,
|
||||
...(imported.unexaminedModuleImports === true ||
|
||||
required.unexaminedModuleImports === true
|
||||
? { unexaminedModuleImports: true as const }
|
||||
: {}),
|
||||
limitations: [
|
||||
...new Set([
|
||||
...imported.limitations,
|
||||
@@ -910,10 +920,21 @@ const bareModuleCandidate = (
|
||||
} else return packageResolution;
|
||||
}
|
||||
}
|
||||
if (nearestNotFound !== null) return nearestNotFound;
|
||||
return unresolvedCandidate("external", [
|
||||
"No matching bare package was inventoried in an enclosing node_modules directory.",
|
||||
]);
|
||||
if (nearestNotFound !== null)
|
||||
return {
|
||||
...nearestNotFound,
|
||||
...(ELECTRON_MODULE.test(input.declaredPath)
|
||||
? {}
|
||||
: { unexaminedModuleImports: true as const }),
|
||||
};
|
||||
return {
|
||||
...unresolvedCandidate("external", [
|
||||
"No matching bare package was inventoried in an enclosing node_modules directory.",
|
||||
]),
|
||||
...(ELECTRON_MODULE.test(input.declaredPath)
|
||||
? {}
|
||||
: { unexaminedModuleImports: true as const }),
|
||||
};
|
||||
};
|
||||
|
||||
function* packageLookupDirectories(
|
||||
|
||||
Reference in new issue
Block a user