mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 01:13:39 +00:00
fix(javascript): preserve factory export helper identity
This commit is contained in:
1 parent
781760a195
commit
0f3a15de0d
12 files changed
+277
-29
No files matched your search
@@ -4,6 +4,7 @@ import { javascriptBootstrapAt } from "./javascriptBootstrap.js";
|
||||
import {
|
||||
resolveSemanticBindingState,
|
||||
type JavaScriptSemanticAnalysisState,
|
||||
type JavaScriptBindingIndex,
|
||||
} from "./javascriptSemanticState.js";
|
||||
import { semanticFactoryLoaderMemberAt } from "./javascriptSemanticRequireOrigin.js";
|
||||
|
||||
@@ -262,7 +263,7 @@ const recoverBundlerModule = (
|
||||
const parameter = parameters[index];
|
||||
return t.isIdentifier(parameter) ? parameter : undefined;
|
||||
};
|
||||
const exportsValue = collectJavaScriptExports(factory, bindings, {
|
||||
const roles = {
|
||||
exports:
|
||||
runtime === "esbuild-commonjs"
|
||||
? identifierAt(0)
|
||||
@@ -276,7 +277,9 @@ const recoverBundlerModule = (
|
||||
? undefined
|
||||
: identifierAt(0),
|
||||
loader: esbuild ? undefined : identifierAt(2),
|
||||
});
|
||||
};
|
||||
const exports: string[] = [];
|
||||
accumulator.pendingBundlerExports.push({ factory, roles, exports });
|
||||
const requireName = esbuild ? null : factoryRequireName(factory);
|
||||
const requireParameter = esbuild ? undefined : parameters[2];
|
||||
const requireBindingId = t.isIdentifier(requireParameter)
|
||||
@@ -310,7 +313,7 @@ const recoverBundlerModule = (
|
||||
source_sha256: sha256Text(sourceSlice(source, factory)),
|
||||
structural_fingerprint_sha256: fingerprint,
|
||||
structural_fingerprint_algorithm: JAVASCRIPT_AST_FINGERPRINT_ALGORITHM,
|
||||
exports: exportsValue.values,
|
||||
exports,
|
||||
location: range(factory),
|
||||
},
|
||||
asyncChunkKeys: asyncChunks.values,
|
||||
@@ -448,3 +451,17 @@ const uniqueValues = (values: readonly string[], unknown = 0): StaticValues => {
|
||||
unknown,
|
||||
};
|
||||
};
|
||||
|
||||
/** Complete factory exports once the shared alias-aware write index is ready. */
|
||||
export const finishBundlerExports = (
|
||||
accumulator: AnalysisAccumulator,
|
||||
index: JavaScriptBindingIndex,
|
||||
): void => {
|
||||
for (const pending of accumulator.pendingBundlerExports) {
|
||||
const collected = collectJavaScriptExports(pending.factory, {
|
||||
roles: pending.roles,
|
||||
index,
|
||||
});
|
||||
for (const value of collected.values) pending.exports.push(value);
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user