mirror of
https://github.com/morluto/rea.git
synced 2026-11-06 14:56:32 +00:00
fix(javascript): distinguish resolver discovery from module loading
Preserve load and resolve operations through semantic facts, worker transfer and graph Evidence. Only loads propagate executable ownership. Project ambient member writes and escapes through the shared path- and site-aware mutation owner; retain source literals, bases and uncertainty. Cover ownership and mutation boundaries through CLI and MCP.
This commit is contained in:
1 parent
635f673a8c
commit
f91b7f8009
14 files changed
+351
-17
No files matched your search
@@ -654,6 +654,7 @@ const loaderInvocationInterop = (state: JavaScriptSemanticAnalysisState) => {
|
||||
};
|
||||
|
||||
export interface JavaScriptRequireCallFact {
|
||||
readonly operation: "load" | "resolve";
|
||||
readonly loader: JavaScriptRequireLoaderFact;
|
||||
readonly arguments:
|
||||
| readonly t.CallExpression["arguments"][number][]
|
||||
@@ -670,7 +671,12 @@ export const semanticRequireCallAt = (
|
||||
factoryBindingIds: ReadonlySet<string>,
|
||||
): JavaScriptRequireCallFact | undefined => {
|
||||
if (semanticModuleRequireCallAt(node, state))
|
||||
return { loader: "unknown", arguments: undefined, sourceRelative: false };
|
||||
return {
|
||||
operation: "load",
|
||||
loader: "unknown",
|
||||
arguments: undefined,
|
||||
sourceRelative: false,
|
||||
};
|
||||
const callee = unwrapJavaScriptExpression(node.callee).node;
|
||||
if (
|
||||
(t.isMemberExpression(callee) || t.isOptionalMemberExpression(callee)) &&
|
||||
@@ -680,7 +686,12 @@ export const semanticRequireCallAt = (
|
||||
selectedRequireSourcesAt(callee, node, state, factoryBindingIds)?.loader ===
|
||||
"local"
|
||||
)
|
||||
return { loader: "local", arguments: undefined, sourceRelative: false };
|
||||
return {
|
||||
operation: "load",
|
||||
loader: "local",
|
||||
arguments: undefined,
|
||||
sourceRelative: false,
|
||||
};
|
||||
if (
|
||||
(t.isMemberExpression(callee) || t.isOptionalMemberExpression(callee)) &&
|
||||
semanticStaticPropertyKey(callee.property, callee.computed) === "resolve"
|
||||
@@ -691,6 +702,13 @@ export const semanticRequireCallAt = (
|
||||
state,
|
||||
factoryBindingIds,
|
||||
);
|
||||
if (loader === "unknown")
|
||||
return {
|
||||
operation: "load",
|
||||
loader,
|
||||
arguments: undefined,
|
||||
sourceRelative: false,
|
||||
};
|
||||
// Bundler factory loaders can share the `require` shape, but their
|
||||
// `.resolve` member is not Node's module resolver.
|
||||
if (loader === "commonjs-loader" || loader === "create-require") {
|
||||
@@ -701,6 +719,7 @@ export const semanticRequireCallAt = (
|
||||
factoryBindingIds,
|
||||
);
|
||||
return {
|
||||
operation: "resolve",
|
||||
loader: selected?.loader ?? loader,
|
||||
arguments: node.arguments,
|
||||
sourceRelative:
|
||||
@@ -726,6 +745,7 @@ export const semanticRequireCallAt = (
|
||||
);
|
||||
if (selected !== undefined || loader !== "local")
|
||||
return {
|
||||
operation: "load",
|
||||
loader: selected?.loader ?? loader,
|
||||
arguments: node.arguments,
|
||||
sourceRelative: selected?.sourceRelative ?? loader !== "create-require",
|
||||
@@ -767,6 +787,7 @@ export const semanticRequireCallAt = (
|
||||
factoryBindingIds,
|
||||
);
|
||||
return {
|
||||
operation: "load",
|
||||
loader:
|
||||
invocation.path[1] === "local"
|
||||
? "local"
|
||||
@@ -790,6 +811,7 @@ export const semanticRequireCallAt = (
|
||||
return factory === undefined
|
||||
? undefined
|
||||
: {
|
||||
operation: "load",
|
||||
loader: factory,
|
||||
arguments: node.arguments.slice(t.isIdentifier(node.callee) ? 0 : 1),
|
||||
sourceRelative: true,
|
||||
|
||||
Reference in new issue
Block a user