@shapeshift-labs/frontier-lang-compiler 0.2.149 → 0.2.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -9
- package/bench/real-repo-corpus-checkout-identity.mjs +134 -0
- package/bench/real-repo-corpus-checkout-proof.mjs +263 -0
- package/bench/real-repo-corpus-command-execution.mjs +314 -0
- package/bench/real-repo-corpus-evidence.mjs +165 -0
- package/bench/real-repo-corpus-suite.mjs +273 -0
- package/bench/smoke.mjs +109 -7
- package/dist/declarations/import-adapter-core.d.ts +4 -3
- package/dist/declarations/import-adapter-options-native.d.ts +21 -0
- package/dist/declarations/js-ts-project-merge-admission-routes.d.ts +35 -0
- package/dist/declarations/js-ts-project-merge-commonjs-interop.d.ts +29 -0
- package/dist/declarations/js-ts-project-merge-confidence.d.ts +64 -0
- package/dist/declarations/js-ts-project-merge-declaration-emit-parity.d.ts +37 -0
- package/dist/declarations/js-ts-project-merge-declarations.d.ts +65 -0
- package/dist/declarations/js-ts-project-merge-diagnostics.d.ts +97 -0
- package/dist/declarations/js-ts-project-merge-global-augmentation.d.ts +30 -0
- package/dist/declarations/js-ts-project-merge-jsx-render-branch.d.ts +48 -0
- package/dist/declarations/js-ts-project-merge-proof-levels.d.ts +109 -0
- package/dist/declarations/js-ts-project-merge-quality-gates.d.ts +38 -0
- package/dist/declarations/js-ts-project-merge-semantic-equivalence-proof.d.ts +45 -0
- package/dist/declarations/js-ts-project-merge-tsconfig.d.ts +43 -0
- package/dist/declarations/js-ts-safe-merge.d.ts +47 -0
- package/dist/declarations/js-ts-safe-project-merge.d.ts +120 -38
- package/dist/declarations/native-project-compiler-assignability-oracle.d.ts +41 -0
- package/dist/declarations/native-project-compiler-callable-signatures.d.ts +31 -0
- package/dist/declarations/native-project-compiler-class-member-runtime-proof.d.ts +87 -0
- package/dist/declarations/native-project-compiler-composite-types.d.ts +23 -0
- package/dist/declarations/native-project-compiler-enum-proof.d.ts +58 -0
- package/dist/declarations/native-project-compiler-index-signature.d.ts +7 -0
- package/dist/declarations/native-project-compiler-public-api-source-binding.d.ts +8 -0
- package/dist/declarations/native-project-compiler-scope.d.ts +37 -0
- package/dist/declarations/native-project-compiler-type-reference-targets.d.ts +38 -0
- package/dist/declarations/native-project-css-modules.d.ts +90 -0
- package/dist/declarations/native-project-decorator-metadata.d.ts +126 -0
- package/dist/declarations/native-project-jsx-graph.d.ts +313 -0
- package/dist/declarations/native-project-module-declarations.d.ts +52 -0
- package/dist/declarations/native-project-module-resolution.d.ts +76 -1
- package/dist/declarations/native-project-runtime-effect-target.d.ts +29 -0
- package/dist/declarations/native-project-runtime-executable-effect-evidence.d.ts +107 -0
- package/dist/declarations/native-project-runtime-mutation-target.d.ts +33 -0
- package/dist/declarations/native-project-runtime-promise-chain.d.ts +30 -0
- package/dist/declarations/native-project-runtime-promise-combinator.d.ts +22 -0
- package/dist/declarations/native-project-runtime-reachability.d.ts +30 -0
- package/dist/declarations/native-project-runtime-resource-management.d.ts +27 -0
- package/dist/declarations/native-project-runtime-yield-delegation.d.ts +10 -0
- package/dist/declarations/native-project-scope-template-reference.d.ts +13 -0
- package/dist/declarations/native-project-source-evidence.d.ts +8 -0
- package/dist/declarations/native-project.d.ts +40 -39
- package/dist/declarations/semantic-edit-script.d.ts +10 -8
- package/dist/declarations/semantic-graph-layers.d.ts +79 -0
- package/dist/declarations/semantic-patch-bundle-composition.d.ts +62 -0
- package/dist/declarations/semantic-sidecar.d.ts +3 -2
- package/dist/declarations/semantic-structural-diff.d.ts +94 -0
- package/dist/declarations/source-preservation.d.ts +32 -1
- package/dist/declarations/target-adapters.d.ts +22 -2
- package/dist/index.d.ts +32 -0
- package/dist/index.js +6 -0
- package/dist/internal/index-impl/compileNativeSource.js +53 -5
- package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
- package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
- package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
- package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
- package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
- package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
- package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
- package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
- package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
- package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
- package/dist/internal/index-impl/importNativeSource.js +2 -3
- package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
- package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
- package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
- package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
- package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
- package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
- package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
- package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
- package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
- package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
- package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
- package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
- package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
- package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
- package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
- package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
- package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
- package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
- package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
- package/dist/internal/index-impl/semanticEditScripts.js +42 -5
- package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
- package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
- package/dist/internal/index-impl/semanticPatchBundleComposition.js +166 -0
- package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
- package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
- package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
- package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
- package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
- package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
- package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
- package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
- package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
- package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
- package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
- package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
- package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
- package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
- package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
- package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
- package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
- package/dist/js-ts-safe-member-class-invariants.js +247 -0
- package/dist/js-ts-safe-member-merge-result.js +23 -3
- package/dist/js-ts-safe-member-merge.js +28 -4
- package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
- package/dist/js-ts-safe-merge-context.js +1 -0
- package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +314 -0
- package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
- package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
- package/dist/js-ts-safe-merge-parse-statements.js +8 -0
- package/dist/js-ts-safe-merge-plan.js +3 -1
- package/dist/js-ts-safe-merge-semantic-edit-fallback.js +49 -0
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +5 -1
- package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
- package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
- package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
- package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
- package/dist/js-ts-safe-merge.js +136 -0
- package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
- package/dist/js-ts-safe-project-merge-admission.js +161 -0
- package/dist/js-ts-safe-project-merge-ambient.js +110 -0
- package/dist/js-ts-safe-project-merge-core.js +85 -0
- package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
- package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
- package/dist/js-ts-safe-project-merge-declarations.js +227 -0
- package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
- package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
- package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
- package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
- package/dist/js-ts-safe-project-merge-files.js +70 -0
- package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
- package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
- package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
- package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
- package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
- package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
- package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
- package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
- package/dist/js-ts-safe-project-merge-graph.js +37 -5
- package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
- package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
- package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
- package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
- package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
- package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
- package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
- package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
- package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
- package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
- package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
- package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
- package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
- package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
- package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
- package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
- package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
- package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
- package/dist/js-ts-safe-project-merge-summary.js +320 -0
- package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
- package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
- package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
- package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
- package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
- package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
- package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
- package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
- package/dist/js-ts-safe-project-merge.js +171 -172
- package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
- package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
- package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
- package/dist/js-ts-semantic-scope-use-def.js +217 -0
- package/dist/lightweight-dependency-effects.js +28 -4
- package/dist/lightweight-dependency-relations.js +13 -7
- package/dist/lightweight-dependency-top-level.js +63 -0
- package/dist/native-import-language-profiles.js +27 -1
- package/dist/native-js-ts-importers.js +9 -5
- package/dist/native-parser-ast-format-profiles.js +12 -0
- package/dist/native-parser-html-css-format-profiles.js +85 -0
- package/dist/native-region-scanner-core.js +5 -3
- package/dist/native-region-scanner-js-commonjs.js +155 -0
- package/dist/native-region-scanner-js-imports.js +51 -13
- package/dist/native-region-scanner-js-reexports.js +79 -0
- package/dist/native-region-scanner-js-ts-helpers.js +23 -0
- package/dist/native-source-ledger-helpers.js +1 -1
- package/dist/native-source-ledger.js +24 -10
- package/dist/native-source-maps-ecma426.js +316 -0
- package/dist/native-source-maps.js +36 -6
- package/dist/native-source-preservation-ownership.js +292 -0
- package/dist/native-source-preservation-scanner.js +63 -25
- package/dist/native-source-preservation-types.d.ts +3 -0
- package/dist/semantic-import-effect-occurrences.js +242 -0
- package/dist/semantic-import-effect-regions.js +95 -58
- package/dist/semantic-import-graph-layers.js +224 -0
- package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
- package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
- package/dist/semantic-import-runtime-exit-evidence.js +32 -0
- package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
- package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
- package/dist/semantic-import-runtime-order-evidence.js +318 -0
- package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
- package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
- package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
- package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
- package/dist/semantic-import-runtime-switch-evidence.js +304 -0
- package/dist/semantic-import-runtime-throw-evidence.js +44 -0
- package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
- package/dist/semantic-import-sidecar-entry.js +4 -0
- package/dist/semantic-import-source-preservation.js +6 -2
- package/package.json +1 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import {
|
|
2
|
+
exportBindingEntry,
|
|
3
|
+
exportModuleEntries,
|
|
4
|
+
identifierName,
|
|
5
|
+
importModuleEntries,
|
|
6
|
+
sourceValue
|
|
7
|
+
} from './syntaxModuleEntryRecords.js';
|
|
8
|
+
|
|
9
|
+
export function commonJsRequireVariableEntries(node, nativeNodeId, input) {
|
|
10
|
+
const helper = commonJsInteropHelperRequireBinding(node);
|
|
11
|
+
if (helper) return importModuleEntries(input, nativeNodeId, helper.moduleSpecifier, [helper.binding], helper.metadata);
|
|
12
|
+
const moduleSpecifier = commonJsRequireModuleSpecifier(node.init);
|
|
13
|
+
if (!moduleSpecifier) return [];
|
|
14
|
+
const bindings = commonJsRequireBindings(node.id);
|
|
15
|
+
return importModuleEntries(input, nativeNodeId, moduleSpecifier, bindings, {
|
|
16
|
+
importKind: 'commonjs-require',
|
|
17
|
+
commonJs: true
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function commonJsRequireExpressionEntries(node, nativeNodeId, input) {
|
|
22
|
+
const moduleSpecifier = commonJsRequireModuleSpecifier(node.expression);
|
|
23
|
+
if (!moduleSpecifier) return [];
|
|
24
|
+
return importModuleEntries(input, nativeNodeId, moduleSpecifier, [], {
|
|
25
|
+
importKind: 'commonjs-require',
|
|
26
|
+
sideEffectOnly: true,
|
|
27
|
+
commonJs: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function commonJsExpressionStatementEntries(node, nativeNodeId, input) {
|
|
32
|
+
return [
|
|
33
|
+
...commonJsRequireExpressionEntries(node, nativeNodeId, input),
|
|
34
|
+
...commonJsExportStarExpressionEntries(node, nativeNodeId, input),
|
|
35
|
+
...commonJsCreateBindingReExportExpressionEntries(node, nativeNodeId, input),
|
|
36
|
+
...commonJsObjectAssignExportExpressionEntries(node, nativeNodeId, input),
|
|
37
|
+
...commonJsDefinePropertiesExportExpressionEntries(node, nativeNodeId, input),
|
|
38
|
+
...commonJsDefinePropertyExportExpressionEntries(node, nativeNodeId, input)
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function commonJsExportAssignmentEntries(node, nativeNodeId, input) {
|
|
43
|
+
if (node.operator && node.operator !== '=') return [];
|
|
44
|
+
const target = commonJsExportTarget(node.left);
|
|
45
|
+
if (!target) return [];
|
|
46
|
+
if (target.exportedName === '__esModule') return [];
|
|
47
|
+
const assignment = exportBindingEntry(input, nativeNodeId, undefined, {
|
|
48
|
+
localName: expressionExportLocalName(node.right),
|
|
49
|
+
exportedName: target.exportedName,
|
|
50
|
+
exportKind: target.exportKind,
|
|
51
|
+
isTypeOnly: false,
|
|
52
|
+
commonJs: true
|
|
53
|
+
});
|
|
54
|
+
return [
|
|
55
|
+
assignment,
|
|
56
|
+
...(target.exportedName === 'module.exports'
|
|
57
|
+
? commonJsObjectExpressionExportBindings(node.right).map((binding) => exportBindingEntry(input, nativeNodeId, undefined, binding))
|
|
58
|
+
: [])
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function commonJsObjectAssignExportExpressionEntries(node, nativeNodeId, input) {
|
|
63
|
+
const call = node.expression;
|
|
64
|
+
const kind = String(call?.type ?? call?.kind ?? '');
|
|
65
|
+
if (kind !== 'CallExpression') return [];
|
|
66
|
+
const callee = memberExpressionParts(call.callee);
|
|
67
|
+
if (callee?.objectName !== 'Object' || callee.propertyName !== 'assign') return [];
|
|
68
|
+
if (!commonJsObjectAssignExportTarget((call.arguments ?? [])[0])) return [];
|
|
69
|
+
return commonJsObjectExpressionExportBindings((call.arguments ?? [])[1])
|
|
70
|
+
.map((binding) => exportBindingEntry(input, nativeNodeId, undefined, binding));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function commonJsExportStarExpressionEntries(node, nativeNodeId, input) {
|
|
74
|
+
const call = node.expression;
|
|
75
|
+
const kind = String(call?.type ?? call?.kind ?? '');
|
|
76
|
+
if (kind !== 'CallExpression' || commonJsHelperName(call.callee) !== '__exportStar') return [];
|
|
77
|
+
if (!commonJsObjectAssignExportTarget((call.arguments ?? [])[1])) return [];
|
|
78
|
+
const moduleSpecifier = commonJsRequireModuleSpecifier((call.arguments ?? [])[0]);
|
|
79
|
+
if (!moduleSpecifier) return [];
|
|
80
|
+
const metadata = { commonJs: true, reexport: true, reExport: true, exportStar: true, importKind: 'reexport', interopHelper: commonJsHelperName(call.callee) };
|
|
81
|
+
return [
|
|
82
|
+
...importModuleEntries(input, nativeNodeId, moduleSpecifier, [], metadata),
|
|
83
|
+
...exportModuleEntries(input, nativeNodeId, moduleSpecifier, [], { ...metadata, exportKind: 'export-star' })
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function commonJsCreateBindingReExportExpressionEntries(node, nativeNodeId, input) {
|
|
88
|
+
const call = node.expression;
|
|
89
|
+
const kind = String(call?.type ?? call?.kind ?? '');
|
|
90
|
+
if (kind !== 'CallExpression' || commonJsHelperName(call.callee) !== '__createBinding') return [];
|
|
91
|
+
if (!commonJsObjectAssignExportTarget((call.arguments ?? [])[0])) return [];
|
|
92
|
+
const moduleSpecifier = commonJsRequireModuleSpecifier((call.arguments ?? [])[1]);
|
|
93
|
+
const importedName = sourceValue((call.arguments ?? [])[2]);
|
|
94
|
+
const exportedName = sourceValue((call.arguments ?? [])[3]) ?? importedName;
|
|
95
|
+
if (!moduleSpecifier || !importedName || !exportedName || exportedName === '__esModule') return [];
|
|
96
|
+
const binding = {
|
|
97
|
+
localName: exportedName,
|
|
98
|
+
importedName,
|
|
99
|
+
exportedName,
|
|
100
|
+
importKind: 'reexport',
|
|
101
|
+
exportKind: 'named',
|
|
102
|
+
isTypeOnly: false,
|
|
103
|
+
reExport: true,
|
|
104
|
+
commonJs: true
|
|
105
|
+
};
|
|
106
|
+
const metadata = { commonJs: true, reexport: true, reExport: true, importKind: 'reexport', interopHelper: commonJsHelperName(call.callee) };
|
|
107
|
+
return [
|
|
108
|
+
...importModuleEntries(input, nativeNodeId, moduleSpecifier, [binding], metadata),
|
|
109
|
+
...exportModuleEntries(input, nativeNodeId, moduleSpecifier, [binding], { ...metadata, exportKind: 'named' })
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function commonJsDefinePropertyExportExpressionEntries(node, nativeNodeId, input) {
|
|
114
|
+
const call = node.expression;
|
|
115
|
+
const kind = String(call?.type ?? call?.kind ?? '');
|
|
116
|
+
if (kind !== 'CallExpression') return [];
|
|
117
|
+
const callee = memberExpressionParts(call.callee);
|
|
118
|
+
if (callee?.objectName !== 'Object' || callee.propertyName !== 'defineProperty') return [];
|
|
119
|
+
if (!commonJsObjectAssignExportTarget((call.arguments ?? [])[0])) return [];
|
|
120
|
+
const exportedName = sourceValue((call.arguments ?? [])[1]);
|
|
121
|
+
if (!exportedName || exportedName === '__esModule') return [];
|
|
122
|
+
return [exportBindingEntry(input, nativeNodeId, undefined, {
|
|
123
|
+
localName: commonJsDescriptorLocalName((call.arguments ?? [])[2]),
|
|
124
|
+
exportedName,
|
|
125
|
+
exportKind: 'commonjs-named',
|
|
126
|
+
isTypeOnly: false,
|
|
127
|
+
commonJs: true
|
|
128
|
+
})];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function commonJsDefinePropertiesExportExpressionEntries(node, nativeNodeId, input) {
|
|
132
|
+
const call = node.expression;
|
|
133
|
+
const kind = String(call?.type ?? call?.kind ?? '');
|
|
134
|
+
if (kind !== 'CallExpression') return [];
|
|
135
|
+
const callee = memberExpressionParts(call.callee);
|
|
136
|
+
if (callee?.objectName !== 'Object' || callee.propertyName !== 'defineProperties') return [];
|
|
137
|
+
if (!commonJsObjectAssignExportTarget((call.arguments ?? [])[0])) return [];
|
|
138
|
+
return commonJsDefinePropertiesExportBindings((call.arguments ?? [])[1])
|
|
139
|
+
.map((binding) => exportBindingEntry(input, nativeNodeId, undefined, binding));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function commonJsDefinePropertiesExportBindings(node) {
|
|
143
|
+
const kind = String(node?.type ?? node?.kind ?? '');
|
|
144
|
+
if (kind !== 'ObjectExpression') return [];
|
|
145
|
+
return (node.properties ?? []).map(commonJsDefinePropertiesExportBinding).filter(Boolean);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function commonJsDefinePropertiesExportBinding(property) {
|
|
149
|
+
const kind = String(property?.type ?? property?.kind ?? '');
|
|
150
|
+
if (kind === 'SpreadElement' || kind === 'SpreadProperty') return undefined;
|
|
151
|
+
const exportedName = property.computed ? sourceValue(property.key) : memberPropertyName(property.key);
|
|
152
|
+
if (!exportedName || exportedName === '__esModule') return undefined;
|
|
153
|
+
return {
|
|
154
|
+
localName: commonJsDescriptorLocalName(property.value),
|
|
155
|
+
exportedName,
|
|
156
|
+
exportKind: 'commonjs-named',
|
|
157
|
+
isTypeOnly: false,
|
|
158
|
+
commonJs: true
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function commonJsObjectAssignExportTarget(node) {
|
|
163
|
+
if (identifierName(node) === 'exports') return true;
|
|
164
|
+
const member = memberExpressionParts(node);
|
|
165
|
+
return member?.objectName === 'module' && member.propertyName === 'exports';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function commonJsRequireModuleSpecifier(node) {
|
|
169
|
+
if (!isCommonJsRequireCall(node)) return undefined;
|
|
170
|
+
return sourceValue((node.arguments ?? [])[0]);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function isCommonJsRequireCall(node) {
|
|
174
|
+
const kind = String(node?.type ?? node?.kind ?? '');
|
|
175
|
+
return kind === 'CallExpression' && identifierName(node.callee) === 'require' && Array.isArray(node.arguments) && node.arguments.length > 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function commonJsRequireBindings(pattern) {
|
|
179
|
+
const localName = identifierName(pattern);
|
|
180
|
+
if (localName) return [{ localName, importedName: 'default', importKind: 'commonjs-require', commonJs: true }];
|
|
181
|
+
const kind = String(pattern?.type ?? pattern?.kind ?? '');
|
|
182
|
+
if (kind !== 'ObjectPattern') return [];
|
|
183
|
+
return (pattern.properties ?? []).map(commonJsDestructuredRequireBinding).filter(Boolean);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function commonJsInteropHelperRequireBinding(node) {
|
|
187
|
+
const localName = identifierName(node.id);
|
|
188
|
+
const init = node.init;
|
|
189
|
+
const kind = String(init?.type ?? init?.kind ?? '');
|
|
190
|
+
const helper = commonJsHelperName(init?.callee);
|
|
191
|
+
if (!localName || kind !== 'CallExpression' || (helper !== '__importStar' && helper !== '__importDefault')) return undefined;
|
|
192
|
+
const moduleSpecifier = commonJsRequireModuleSpecifier((init.arguments ?? [])[0]);
|
|
193
|
+
if (!moduleSpecifier) return undefined;
|
|
194
|
+
const binding = helper === '__importStar'
|
|
195
|
+
? { localName, importedName: '*', namespace: localName, importKind: 'namespace', commonJs: true }
|
|
196
|
+
: { localName, importedName: 'default', importKind: 'default', commonJs: true };
|
|
197
|
+
return {
|
|
198
|
+
moduleSpecifier,
|
|
199
|
+
binding,
|
|
200
|
+
metadata: { importKind: binding.importKind, commonJs: true, interopHelper: helper }
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function commonJsHelperName(node) {
|
|
205
|
+
const direct = identifierName(node);
|
|
206
|
+
return direct ?? memberExpressionParts(node)?.propertyName;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function commonJsDestructuredRequireBinding(property) {
|
|
210
|
+
const kind = String(property?.type ?? property?.kind ?? '');
|
|
211
|
+
if (kind === 'RestElement' || kind === 'RestProperty') return undefined;
|
|
212
|
+
const importedName = memberPropertyName(property.key);
|
|
213
|
+
const localName = identifierName(property.value) ?? identifierName(property.argument) ?? importedName;
|
|
214
|
+
if (!importedName || !localName) return undefined;
|
|
215
|
+
return { localName, importedName, importKind: 'commonjs-require', commonJs: true };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function commonJsExportTarget(node) {
|
|
219
|
+
const member = memberExpressionParts(node);
|
|
220
|
+
if (!member) return undefined;
|
|
221
|
+
if (member.objectName === 'module' && member.propertyName === 'exports') {
|
|
222
|
+
return { exportedName: 'module.exports', exportKind: 'assignment' };
|
|
223
|
+
}
|
|
224
|
+
if (member.objectName === 'exports') {
|
|
225
|
+
return { exportedName: member.propertyName, exportKind: 'commonjs-named' };
|
|
226
|
+
}
|
|
227
|
+
const nestedObject = memberExpressionParts(member.objectNode);
|
|
228
|
+
if (nestedObject?.objectName === 'module' && nestedObject.propertyName === 'exports') {
|
|
229
|
+
return { exportedName: member.propertyName, exportKind: 'commonjs-named' };
|
|
230
|
+
}
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function commonJsObjectExpressionExportBindings(node) {
|
|
235
|
+
const kind = String(node?.type ?? node?.kind ?? '');
|
|
236
|
+
if (kind !== 'ObjectExpression') return [];
|
|
237
|
+
return (node.properties ?? []).map(commonJsObjectExpressionExportBinding).filter(Boolean);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function commonJsObjectExpressionExportBinding(property) {
|
|
241
|
+
const kind = String(property?.type ?? property?.kind ?? '');
|
|
242
|
+
if (kind === 'SpreadElement' || kind === 'SpreadProperty') return undefined;
|
|
243
|
+
const exportedName = property.computed ? sourceValue(property.key) : memberPropertyName(property.key);
|
|
244
|
+
if (!exportedName || exportedName === '__esModule') return undefined;
|
|
245
|
+
return {
|
|
246
|
+
localName: property.shorthand ? exportedName : expressionExportLocalName(property.value),
|
|
247
|
+
exportedName,
|
|
248
|
+
exportKind: 'commonjs-named',
|
|
249
|
+
isTypeOnly: false,
|
|
250
|
+
commonJs: true
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function commonJsDescriptorLocalName(node) {
|
|
255
|
+
const kind = String(node?.type ?? node?.kind ?? '');
|
|
256
|
+
if (kind !== 'ObjectExpression') return undefined;
|
|
257
|
+
for (const property of node.properties ?? []) {
|
|
258
|
+
const key = property.computed ? sourceValue(property.key) : memberPropertyName(property.key);
|
|
259
|
+
if (key === 'value') return expressionExportLocalName(property.value);
|
|
260
|
+
if (key === 'get') return returnExpressionLocalName(property.value);
|
|
261
|
+
}
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function returnExpressionLocalName(node) {
|
|
266
|
+
const kind = String(node?.type ?? node?.kind ?? '');
|
|
267
|
+
if (kind === 'ArrowFunctionExpression') return returnBlockExpressionLocalName(node.body) ?? expressionExportLocalName(node.body);
|
|
268
|
+
if (kind !== 'FunctionExpression' && kind !== 'FunctionDeclaration') return undefined;
|
|
269
|
+
return returnBlockExpressionLocalName(node.body);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function returnBlockExpressionLocalName(node) {
|
|
273
|
+
const kind = String(node?.type ?? node?.kind ?? '');
|
|
274
|
+
if (kind !== 'BlockStatement') return undefined;
|
|
275
|
+
const statement = (node.body ?? []).find((entry) => String(entry?.type ?? entry?.kind ?? '') === 'ReturnStatement');
|
|
276
|
+
return expressionExportLocalName(statement?.argument);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function memberExpressionParts(node) {
|
|
280
|
+
const kind = String(node?.type ?? node?.kind ?? '');
|
|
281
|
+
if (kind !== 'MemberExpression' && kind !== 'OptionalMemberExpression') return undefined;
|
|
282
|
+
const objectName = expressionExportLocalName(node.object);
|
|
283
|
+
const propertyName = node.computed ? sourceValue(node.property) : memberPropertyName(node.property);
|
|
284
|
+
if (!objectName || !propertyName) return undefined;
|
|
285
|
+
return { objectName, propertyName, objectNode: node.object };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function memberPropertyName(node) {
|
|
289
|
+
return identifierName(node);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function expressionExportLocalName(node) {
|
|
293
|
+
const name = identifierName(node);
|
|
294
|
+
if (name) return name;
|
|
295
|
+
const member = memberExpressionParts(node);
|
|
296
|
+
return member ? `${member.objectName}.${member.propertyName}` : undefined;
|
|
297
|
+
}
|
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
commonJsExpressionStatementEntries,
|
|
3
|
+
commonJsExportAssignmentEntries,
|
|
4
|
+
commonJsRequireVariableEntries
|
|
5
|
+
} from './syntaxCommonJsModuleDeclarationEntries.js';
|
|
6
|
+
import { dynamicImportExpressionMetadata } from './dynamicImportExpressionMetadata.js';
|
|
7
|
+
import { hostModuleDependencyMetadata } from './importMetaUrlDependencyMetadata.js';
|
|
8
|
+
import { moduleImportAttributeMetadata } from './moduleImportAttributeMetadata.js';
|
|
9
|
+
import {
|
|
10
|
+
declarationName,
|
|
11
|
+
declarationTypeOnly,
|
|
12
|
+
exportBindingEntry,
|
|
13
|
+
exportModuleEntries,
|
|
14
|
+
identifierName,
|
|
15
|
+
importModuleEntries,
|
|
16
|
+
sourceValue
|
|
17
|
+
} from './syntaxModuleEntryRecords.js';
|
|
18
|
+
|
|
19
|
+
const UNKNOWN_DYNAMIC_IMPORT_MODULE_SPECIFIER = '<dynamic-import>';
|
|
20
|
+
|
|
3
21
|
export function syntaxModuleDeclarationEntries(node, nativeNodeId, input) {
|
|
4
22
|
const kind = String(node.type ?? node.kind ?? '');
|
|
5
23
|
if (kind === 'ImportDeclaration') return importDeclarationEntries(node, nativeNodeId, input);
|
|
24
|
+
if (kind === 'VariableDeclarator') return commonJsRequireVariableEntries(node, nativeNodeId, input);
|
|
25
|
+
if (kind === 'ExpressionStatement') return commonJsExpressionStatementEntries(node, nativeNodeId, input);
|
|
26
|
+
if (kind === 'AssignmentExpression') return commonJsExportAssignmentEntries(node, nativeNodeId, input);
|
|
27
|
+
if (kind === 'ImportExpression') return dynamicImportExpressionEntries(node, nativeNodeId, input);
|
|
28
|
+
if (kind === 'CallExpression' && isDynamicImportCall(node)) return dynamicImportExpressionEntries(node, nativeNodeId, input);
|
|
29
|
+
if (kind === 'CallExpression' || kind === 'NewExpression') return hostModuleDependencyEntries(node, nativeNodeId, input);
|
|
6
30
|
if (kind === 'ExportNamedDeclaration') return exportNamedDeclarationEntries(node, nativeNodeId, input);
|
|
7
31
|
if (kind === 'ExportAllDeclaration') return exportAllDeclarationEntries(node, nativeNodeId, input);
|
|
8
32
|
if (kind === 'ExportDefaultDeclaration') return exportDefaultDeclarationEntries(node, nativeNodeId, input);
|
|
@@ -17,10 +41,28 @@ function importDeclarationEntries(node, nativeNodeId, input) {
|
|
|
17
41
|
return importModuleEntries(input, nativeNodeId, moduleSpecifier, bindings, {
|
|
18
42
|
typeOnly,
|
|
19
43
|
sideEffectOnly: bindings.length === 0,
|
|
20
|
-
importKind: bindings.length === 0 ? 'side-effect' : 'module'
|
|
44
|
+
importKind: bindings.length === 0 ? 'side-effect' : 'module',
|
|
45
|
+
...moduleImportAttributeMetadata(node)
|
|
21
46
|
});
|
|
22
47
|
}
|
|
23
48
|
|
|
49
|
+
function dynamicImportExpressionEntries(node, nativeNodeId, input) {
|
|
50
|
+
const importArgument = node.source ?? (node.arguments ?? [])[0];
|
|
51
|
+
if (!importArgument) return [];
|
|
52
|
+
const moduleSpecifier = sourceValue(importArgument) ?? UNKNOWN_DYNAMIC_IMPORT_MODULE_SPECIFIER;
|
|
53
|
+
return importModuleEntries(input, nativeNodeId, moduleSpecifier, [], {
|
|
54
|
+
importKind: 'dynamic-import',
|
|
55
|
+
dynamicImport: true,
|
|
56
|
+
...dynamicImportExpressionMetadata(importArgument, moduleSpecifier),
|
|
57
|
+
...moduleImportAttributeMetadata(node)
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function hostModuleDependencyEntries(node, nativeNodeId, input) {
|
|
62
|
+
return hostModuleDependencyMetadata(node, { kind: String(node.type ?? node.kind ?? '') }).flatMap((dependency) =>
|
|
63
|
+
importModuleEntries(input, nativeNodeId, dependency.moduleSpecifier, [], dependency.metadata));
|
|
64
|
+
}
|
|
65
|
+
|
|
24
66
|
function exportNamedDeclarationEntries(node, nativeNodeId, input) {
|
|
25
67
|
const moduleSpecifier = sourceValue(node.source);
|
|
26
68
|
const typeOnly = node.exportKind === 'type';
|
|
@@ -32,12 +74,14 @@ function exportNamedDeclarationEntries(node, nativeNodeId, input) {
|
|
|
32
74
|
...(moduleSpecifier ? importModuleEntries(input, nativeNodeId, moduleSpecifier, reExportImportBindings(bindings), {
|
|
33
75
|
typeOnly,
|
|
34
76
|
reexport: true,
|
|
35
|
-
importKind: 'reexport'
|
|
77
|
+
importKind: 'reexport',
|
|
78
|
+
...moduleImportAttributeMetadata(node)
|
|
36
79
|
}) : []),
|
|
37
80
|
...exportModuleEntries(input, nativeNodeId, moduleSpecifier, bindings, {
|
|
38
81
|
typeOnly,
|
|
39
82
|
reExport: Boolean(moduleSpecifier),
|
|
40
|
-
exportKind: typeOnly ? 'type-named' : 'named'
|
|
83
|
+
exportKind: typeOnly ? 'type-named' : 'named',
|
|
84
|
+
...moduleImportAttributeMetadata(node)
|
|
41
85
|
})
|
|
42
86
|
];
|
|
43
87
|
}
|
|
@@ -62,13 +106,15 @@ function exportAllDeclarationEntries(node, nativeNodeId, input) {
|
|
|
62
106
|
typeOnly,
|
|
63
107
|
reexport: true,
|
|
64
108
|
exportStar: !exportedName,
|
|
65
|
-
importKind: exportedName ? 'namespace-reexport' : 'reexport'
|
|
109
|
+
importKind: exportedName ? 'namespace-reexport' : 'reexport',
|
|
110
|
+
...moduleImportAttributeMetadata(node)
|
|
66
111
|
}),
|
|
67
112
|
...exportModuleEntries(input, nativeNodeId, moduleSpecifier, bindings, {
|
|
68
113
|
typeOnly,
|
|
69
114
|
reExport: true,
|
|
70
115
|
exportStar: !exportedName,
|
|
71
|
-
exportKind: exportedName ? 'namespace-reexport' : 'export-star'
|
|
116
|
+
exportKind: exportedName ? 'namespace-reexport' : 'export-star',
|
|
117
|
+
...moduleImportAttributeMetadata(node)
|
|
72
118
|
})
|
|
73
119
|
];
|
|
74
120
|
}
|
|
@@ -151,129 +197,7 @@ function reExportImportBindings(bindings) {
|
|
|
151
197
|
}));
|
|
152
198
|
}
|
|
153
199
|
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
...declarationRecord(input, nativeNodeId, moduleSpecifier, 'module', 'import'),
|
|
158
|
-
importPath: moduleSpecifier,
|
|
159
|
-
moduleSpecifier,
|
|
160
|
-
importKind: metadata.importKind,
|
|
161
|
-
isTypeOnly: metadata.typeOnly,
|
|
162
|
-
exportStar: metadata.exportStar,
|
|
163
|
-
metadata: moduleMetadata('syntax-import', bindings, metadata)
|
|
164
|
-
})
|
|
165
|
-
}, ...bindings.map((binding) => importBindingEntry(input, nativeNodeId, moduleSpecifier, binding))];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function importBindingEntry(input, nativeNodeId, moduleSpecifier, binding) {
|
|
169
|
-
return {
|
|
170
|
-
declaration: compactRecord({
|
|
171
|
-
...declarationRecord(input, nativeNodeId, binding.localName, 'import', 'import'),
|
|
172
|
-
symbolId: `symbol:${input.language}:import:${idFragment(`${moduleSpecifier}:${binding.localName}:${binding.importedName}`)}`,
|
|
173
|
-
importPath: moduleSpecifier,
|
|
174
|
-
moduleSpecifier,
|
|
175
|
-
localName: binding.localName,
|
|
176
|
-
importedName: binding.importedName,
|
|
177
|
-
exportedName: binding.exportedName,
|
|
178
|
-
namespace: binding.namespace,
|
|
179
|
-
importKind: binding.importKind,
|
|
180
|
-
isTypeOnly: binding.isTypeOnly,
|
|
181
|
-
metadata: bindingMetadata('syntax-import-binding', moduleSpecifier, binding)
|
|
182
|
-
})
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function exportModuleEntries(input, nativeNodeId, moduleSpecifier, bindings, metadata) {
|
|
187
|
-
const statementName = metadata.exportStar
|
|
188
|
-
? `* from ${moduleSpecifier}`
|
|
189
|
-
: moduleSpecifier ? `{${bindings.map((binding) => binding.exportedName).join(',')}} from ${moduleSpecifier}` : `{${bindings.map((binding) => binding.exportedName).join(',')}}`;
|
|
190
|
-
return [{
|
|
191
|
-
declaration: compactRecord({
|
|
192
|
-
...declarationRecord(input, nativeNodeId, statementName, 'module', 'export'),
|
|
193
|
-
exportPath: moduleSpecifier,
|
|
194
|
-
moduleSpecifier,
|
|
195
|
-
exportKind: metadata.exportKind,
|
|
196
|
-
exportStar: metadata.exportStar,
|
|
197
|
-
isTypeOnly: metadata.typeOnly,
|
|
198
|
-
reExport: metadata.reExport,
|
|
199
|
-
publicContract: true,
|
|
200
|
-
metadata: moduleMetadata('syntax-export', bindings, metadata)
|
|
201
|
-
})
|
|
202
|
-
}, ...bindings.map((binding) => exportBindingEntry(input, nativeNodeId, moduleSpecifier, binding))];
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function exportBindingEntry(input, nativeNodeId, moduleSpecifier, binding) {
|
|
206
|
-
return {
|
|
207
|
-
declaration: compactRecord({
|
|
208
|
-
...declarationRecord(input, nativeNodeId, binding.exportedName, 'export', 'export'),
|
|
209
|
-
symbolId: `symbol:${input.language}:export:${idFragment(binding.exportedName)}`,
|
|
210
|
-
exportPath: moduleSpecifier,
|
|
211
|
-
moduleSpecifier,
|
|
212
|
-
localName: binding.localName,
|
|
213
|
-
importedName: binding.importedName,
|
|
214
|
-
exportedName: binding.exportedName,
|
|
215
|
-
namespace: binding.namespace,
|
|
216
|
-
exportKind: binding.exportKind,
|
|
217
|
-
isTypeOnly: binding.isTypeOnly,
|
|
218
|
-
reExport: binding.reExport,
|
|
219
|
-
publicContract: true,
|
|
220
|
-
metadata: bindingMetadata('syntax-export-binding', moduleSpecifier, binding, true)
|
|
221
|
-
})
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function moduleMetadata(scan, bindings, metadata) {
|
|
226
|
-
return compactRecord({
|
|
227
|
-
scan,
|
|
228
|
-
moduleOnly: true,
|
|
229
|
-
bindingCount: bindings.length,
|
|
230
|
-
importKind: metadata.importKind,
|
|
231
|
-
exportKind: metadata.exportKind,
|
|
232
|
-
isTypeOnly: metadata.typeOnly,
|
|
233
|
-
typeOnly: metadata.typeOnly,
|
|
234
|
-
sideEffectOnly: metadata.sideEffectOnly,
|
|
235
|
-
reexport: metadata.reexport,
|
|
236
|
-
reExport: metadata.reExport,
|
|
237
|
-
exportStar: metadata.exportStar,
|
|
238
|
-
publicContract: metadata.reExport || metadata.exportKind
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function bindingMetadata(scan, moduleSpecifier, binding, publicContract = false) {
|
|
243
|
-
return compactRecord({
|
|
244
|
-
scan,
|
|
245
|
-
moduleSpecifier,
|
|
246
|
-
importPath: moduleSpecifier,
|
|
247
|
-
exportPath: moduleSpecifier,
|
|
248
|
-
localName: binding.localName,
|
|
249
|
-
importedName: binding.importedName,
|
|
250
|
-
exportedName: binding.exportedName,
|
|
251
|
-
namespace: binding.namespace,
|
|
252
|
-
importKind: binding.importKind,
|
|
253
|
-
exportKind: binding.exportKind,
|
|
254
|
-
isTypeOnly: binding.isTypeOnly,
|
|
255
|
-
typeOnly: binding.isTypeOnly,
|
|
256
|
-
reExport: binding.reExport,
|
|
257
|
-
publicContract
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function sourceValue(source) {
|
|
262
|
-
return typeof source?.value === 'string' ? source.value : undefined;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function identifierName(node) {
|
|
266
|
-
return typeof node?.name === 'string' ? node.name : typeof node?.value === 'string' ? node.value : undefined;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function declarationName(node) {
|
|
270
|
-
return identifierName(node?.id) ?? identifierName(node?.name);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function declarationTypeOnly(kind) {
|
|
274
|
-
return kind === 'TSInterfaceDeclaration' || kind === 'TSTypeAliasDeclaration' || kind === 'InterfaceDeclaration' || kind === 'TypeAliasDeclaration';
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function compactRecord(record) {
|
|
278
|
-
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
200
|
+
function isDynamicImportCall(node) {
|
|
201
|
+
const calleeKind = String(node.callee?.type ?? node.callee?.kind ?? '');
|
|
202
|
+
return calleeKind === 'Import' || calleeKind === 'ImportKeyword' || identifierName(node.callee) === 'import';
|
|
279
203
|
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { idFragment } from '../../native-import-utils.js';
|
|
2
|
+
import { declarationRecord } from './declarationRecord.js';
|
|
3
|
+
|
|
4
|
+
export function importModuleEntries(input, nativeNodeId, moduleSpecifier, bindings, metadata) {
|
|
5
|
+
return [{
|
|
6
|
+
declaration: compactRecord({
|
|
7
|
+
...declarationRecord(input, nativeNodeId, moduleSpecifier, 'module', 'import'),
|
|
8
|
+
importPath: moduleSpecifier,
|
|
9
|
+
moduleSpecifier,
|
|
10
|
+
importKind: metadata.importKind,
|
|
11
|
+
isTypeOnly: metadata.typeOnly,
|
|
12
|
+
exportStar: metadata.exportStar,
|
|
13
|
+
metadata: moduleMetadata('syntax-import', bindings, metadata)
|
|
14
|
+
})
|
|
15
|
+
}, ...bindings.map((binding) => importBindingEntry(input, nativeNodeId, moduleSpecifier, binding, metadata))];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function importBindingEntry(input, nativeNodeId, moduleSpecifier, binding, metadata = {}) {
|
|
19
|
+
return {
|
|
20
|
+
declaration: compactRecord({
|
|
21
|
+
...declarationRecord(input, nativeNodeId, binding.localName, 'import', 'import'),
|
|
22
|
+
symbolId: `symbol:${input.language}:import:${idFragment(`${moduleSpecifier}:${binding.localName}:${binding.importedName}`)}`,
|
|
23
|
+
importPath: moduleSpecifier,
|
|
24
|
+
moduleSpecifier,
|
|
25
|
+
localName: binding.localName,
|
|
26
|
+
importedName: binding.importedName,
|
|
27
|
+
exportedName: binding.exportedName,
|
|
28
|
+
namespace: binding.namespace,
|
|
29
|
+
importKind: binding.importKind,
|
|
30
|
+
isTypeOnly: binding.isTypeOnly,
|
|
31
|
+
commonJs: binding.commonJs,
|
|
32
|
+
metadata: bindingMetadata('syntax-import-binding', moduleSpecifier, binding, false, metadata)
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function exportModuleEntries(input, nativeNodeId, moduleSpecifier, bindings, metadata) {
|
|
38
|
+
const statementName = metadata.exportStar
|
|
39
|
+
? `* from ${moduleSpecifier}`
|
|
40
|
+
: moduleSpecifier ? `{${bindings.map((binding) => binding.exportedName).join(',')}} from ${moduleSpecifier}` : `{${bindings.map((binding) => binding.exportedName).join(',')}}`;
|
|
41
|
+
return [{
|
|
42
|
+
declaration: compactRecord({
|
|
43
|
+
...declarationRecord(input, nativeNodeId, statementName, 'module', 'export'),
|
|
44
|
+
exportPath: moduleSpecifier,
|
|
45
|
+
moduleSpecifier,
|
|
46
|
+
exportKind: metadata.exportKind,
|
|
47
|
+
exportStar: metadata.exportStar,
|
|
48
|
+
isTypeOnly: metadata.typeOnly,
|
|
49
|
+
reExport: metadata.reExport,
|
|
50
|
+
publicContract: true,
|
|
51
|
+
metadata: moduleMetadata('syntax-export', bindings, metadata)
|
|
52
|
+
})
|
|
53
|
+
}, ...bindings.map((binding) => exportBindingEntry(input, nativeNodeId, moduleSpecifier, binding, metadata))];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function exportBindingEntry(input, nativeNodeId, moduleSpecifier, binding, metadata = {}) {
|
|
57
|
+
return {
|
|
58
|
+
declaration: compactRecord({
|
|
59
|
+
...declarationRecord(input, nativeNodeId, binding.exportedName, 'export', 'export'),
|
|
60
|
+
symbolId: `symbol:${input.language}:export:${idFragment(binding.exportedName)}`,
|
|
61
|
+
exportPath: moduleSpecifier,
|
|
62
|
+
moduleSpecifier,
|
|
63
|
+
localName: binding.localName,
|
|
64
|
+
importedName: binding.importedName,
|
|
65
|
+
exportedName: binding.exportedName,
|
|
66
|
+
namespace: binding.namespace,
|
|
67
|
+
exportKind: binding.exportKind,
|
|
68
|
+
isTypeOnly: binding.isTypeOnly,
|
|
69
|
+
reExport: binding.reExport,
|
|
70
|
+
publicContract: true,
|
|
71
|
+
commonJs: binding.commonJs,
|
|
72
|
+
metadata: bindingMetadata('syntax-export-binding', moduleSpecifier, binding, true, metadata)
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function sourceValue(source) {
|
|
78
|
+
if (typeof source?.value === 'string') return source.value;
|
|
79
|
+
const kind = String(source?.type ?? source?.kind ?? '');
|
|
80
|
+
if (kind === 'TemplateLiteral' && (source.expressions ?? []).length === 0 && (source.quasis ?? []).length === 1) {
|
|
81
|
+
return source.quasis[0]?.value?.cooked ?? source.quasis[0]?.value?.raw;
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function identifierName(node) {
|
|
87
|
+
return typeof node?.name === 'string' ? node.name : typeof node?.value === 'string' ? node.value : undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function declarationName(node) {
|
|
91
|
+
return identifierName(node?.id) ?? identifierName(node?.name);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function declarationTypeOnly(kind) {
|
|
95
|
+
return kind === 'TSInterfaceDeclaration' || kind === 'TSTypeAliasDeclaration' || kind === 'InterfaceDeclaration' || kind === 'TypeAliasDeclaration';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function compactRecord(record) {
|
|
99
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function moduleMetadata(scan, bindings, metadata) {
|
|
103
|
+
return compactRecord({
|
|
104
|
+
scan,
|
|
105
|
+
moduleOnly: true,
|
|
106
|
+
bindingCount: bindings.length,
|
|
107
|
+
importKind: metadata.importKind,
|
|
108
|
+
exportKind: metadata.exportKind,
|
|
109
|
+
isTypeOnly: metadata.typeOnly,
|
|
110
|
+
typeOnly: metadata.typeOnly,
|
|
111
|
+
sideEffectOnly: metadata.sideEffectOnly,
|
|
112
|
+
dynamicImport: metadata.dynamicImport,
|
|
113
|
+
dynamicImportSpecifierKind: metadata.dynamicImportSpecifierKind,
|
|
114
|
+
dynamicImportExpressionText: metadata.dynamicImportExpressionText,
|
|
115
|
+
dynamicImportExpressionHash: metadata.dynamicImportExpressionHash,
|
|
116
|
+
dynamicImportStaticSpecifierEvidence: metadata.dynamicImportStaticSpecifierEvidence,
|
|
117
|
+
dynamicImportRuntimeResolutionClaim: metadata.dynamicImportRuntimeResolutionClaim,
|
|
118
|
+
dynamicImportResolutionProofRequired: metadata.dynamicImportResolutionProofRequired,
|
|
119
|
+
hostDependency: metadata.hostDependency,
|
|
120
|
+
hostDependencyKind: metadata.hostDependencyKind,
|
|
121
|
+
hostDependencyBase: metadata.hostDependencyBase,
|
|
122
|
+
hostDependencyExpressionText: metadata.hostDependencyExpressionText,
|
|
123
|
+
hostDependencyExpressionHash: metadata.hostDependencyExpressionHash,
|
|
124
|
+
hostDependencyStaticSpecifierEvidence: metadata.hostDependencyStaticSpecifierEvidence,
|
|
125
|
+
hostDependencyRuntimeResolutionClaim: metadata.hostDependencyRuntimeResolutionClaim,
|
|
126
|
+
hostDependencyResolutionProofRequired: metadata.hostDependencyResolutionProofRequired,
|
|
127
|
+
hasImportAttributes: metadata.hasImportAttributes,
|
|
128
|
+
importAttributeCount: metadata.importAttributeCount,
|
|
129
|
+
importAttributeKeys: metadata.importAttributeKeys,
|
|
130
|
+
importAttributeHash: metadata.importAttributeHash,
|
|
131
|
+
importAttributes: metadata.importAttributes,
|
|
132
|
+
commonJs: metadata.commonJs,
|
|
133
|
+
interopHelper: metadata.interopHelper,
|
|
134
|
+
reexport: metadata.reexport,
|
|
135
|
+
reExport: metadata.reExport,
|
|
136
|
+
exportStar: metadata.exportStar,
|
|
137
|
+
publicContract: metadata.reExport || metadata.exportKind
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function bindingMetadata(scan, moduleSpecifier, binding, publicContract = false, metadata = {}) {
|
|
142
|
+
return compactRecord({
|
|
143
|
+
scan,
|
|
144
|
+
moduleSpecifier,
|
|
145
|
+
importPath: moduleSpecifier,
|
|
146
|
+
exportPath: moduleSpecifier,
|
|
147
|
+
localName: binding.localName,
|
|
148
|
+
importedName: binding.importedName,
|
|
149
|
+
exportedName: binding.exportedName,
|
|
150
|
+
namespace: binding.namespace,
|
|
151
|
+
importKind: binding.importKind,
|
|
152
|
+
exportKind: binding.exportKind,
|
|
153
|
+
isTypeOnly: binding.isTypeOnly,
|
|
154
|
+
typeOnly: binding.isTypeOnly,
|
|
155
|
+
reExport: binding.reExport,
|
|
156
|
+
publicContract, hasImportAttributes: metadata.hasImportAttributes, importAttributeCount: metadata.importAttributeCount, importAttributeKeys: metadata.importAttributeKeys, importAttributeHash: metadata.importAttributeHash, importAttributes: metadata.importAttributes,
|
|
157
|
+
commonJs: binding.commonJs,
|
|
158
|
+
interopHelper: binding.interopHelper ?? metadata.interopHelper
|
|
159
|
+
});
|
|
160
|
+
}
|