@shapeshift-labs/frontier-lang-compiler 0.2.126 → 0.2.128
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/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +2 -1
- package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +4 -0
- package/dist/js-ts-safe-merge-analyze.js +2 -0
- package/dist/js-ts-safe-merge-export-star-validation.js +46 -0
- package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +1 -1
- package/package.json +1 -1
|
@@ -214,7 +214,7 @@ function moduleSpecifierForDeclaration(declaration) {
|
|
|
214
214
|
declaration.metadata?.importPath,
|
|
215
215
|
declaration.metadata?.exportPath,
|
|
216
216
|
declaration.metadata?.source,
|
|
217
|
-
declaration.symbolKind === 'module' ? declaration.name : undefined
|
|
217
|
+
declaration.role === 'import' && declaration.symbolKind === 'module' ? declaration.name : undefined
|
|
218
218
|
);
|
|
219
219
|
}
|
|
220
220
|
|
|
@@ -245,6 +245,7 @@ function publicContractRegionForDeclaration(declaration, ownershipRegion, module
|
|
|
245
245
|
function reExportIdentityForDeclaration(declaration, input, documentId, relationId, ownershipRegion, moduleEdge) {
|
|
246
246
|
if (!moduleEdge?.isReExport && !declaration.reExport) return undefined;
|
|
247
247
|
const bindingCount = Number(declaration.nativeNode?.metadata?.bindingCount ?? declaration.metadata?.bindingCount ?? 0);
|
|
248
|
+
if (declaration.symbolKind === 'module' && declaration.metadata?.namespaceReExport) return undefined;
|
|
248
249
|
if (declaration.symbolKind === 'module' && !declaration.exportStar && !declaration.metadata?.exportStar && bindingCount > 1) return undefined;
|
|
249
250
|
const identityId = hashSemanticValue([relationId, declaration.symbolId, declaration.exportedName ?? declaration.metadata?.exportedName, declaration.importedName ?? declaration.metadata?.importedName, declaration.localName ?? declaration.metadata?.localName]);
|
|
250
251
|
const stableId = bindingCount > 1 ? idFragment(identityId) : idFragment(relationId);
|
|
@@ -39,17 +39,20 @@ function exportDeclarationEntries(node, nativeNodeId, input) {
|
|
|
39
39
|
const typeOnly = Boolean(node.isTypeOnly);
|
|
40
40
|
const exportStar = moduleSpecifier && !node.exportClause;
|
|
41
41
|
const bindings = exportClauseBindings(node.exportClause, { typeOnly, reExport: Boolean(moduleSpecifier) });
|
|
42
|
+
const namespaceReExport = Boolean(moduleSpecifier && bindings.some((binding) => binding.exportKind === 'namespace-reexport'));
|
|
42
43
|
return [
|
|
43
44
|
...(moduleSpecifier ? importModuleEntries(input, nativeNodeId, moduleSpecifier, 'ExportFromDeclaration', reExportImportBindings(bindings, exportStar), {
|
|
44
45
|
typeOnly,
|
|
45
46
|
reexport: true,
|
|
46
47
|
exportStar,
|
|
48
|
+
namespaceReExport,
|
|
47
49
|
importKind: exportStar ? 'reexport' : 'reexport'
|
|
48
50
|
}) : []),
|
|
49
51
|
...exportModuleEntries(input, nativeNodeId, moduleSpecifier, bindings, {
|
|
50
52
|
typeOnly,
|
|
51
53
|
exportStar,
|
|
52
54
|
reExport: Boolean(moduleSpecifier),
|
|
55
|
+
namespaceReExport,
|
|
53
56
|
exportKind: exportStar ? 'export-star' : 'named'
|
|
54
57
|
})
|
|
55
58
|
];
|
|
@@ -269,6 +272,7 @@ function moduleMetadata(scan, bindings, metadata) {
|
|
|
269
272
|
sideEffectOnly: metadata.sideEffectOnly,
|
|
270
273
|
reexport: metadata.reexport,
|
|
271
274
|
reExport: metadata.reExport,
|
|
275
|
+
namespaceReExport: metadata.namespaceReExport,
|
|
272
276
|
exportStar: metadata.exportStar,
|
|
273
277
|
publicContract: metadata.reExport || metadata.exportKind
|
|
274
278
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JsTsSafeMergeConflictCodes, JsTsSafeMergeGateIds } from './js-ts-safe-merge-constants.js';
|
|
2
2
|
import { addConflict, arraysEqual, sameStatementText } from './js-ts-safe-merge-context.js';
|
|
3
|
+
import { validateCrossSideExportStarAdditions } from './js-ts-safe-merge-export-star-validation.js';
|
|
3
4
|
|
|
4
5
|
export function analyzeVariantLedger(base, variant, baseIndex, side, context) {
|
|
5
6
|
const projectedBaseKeys = [];
|
|
@@ -159,6 +160,7 @@ export function validateIndependentAdditions(base, workerPlan, headPlan, context
|
|
|
159
160
|
validateAddedEntryNames(workerPlan, declarationNames, context);
|
|
160
161
|
validateAddedEntryNames(headPlan, declarationNames, context);
|
|
161
162
|
validateCrossSideAddedNames(workerPlan, headPlan, context);
|
|
163
|
+
validateCrossSideExportStarAdditions(workerPlan, headPlan, context);
|
|
162
164
|
validateCrossSideImportAdditions(workerPlan, headPlan, context);
|
|
163
165
|
validateMergedImportAndDeclarationNames(base, workerPlan, headPlan, context);
|
|
164
166
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { JsTsSafeMergeConflictCodes, JsTsSafeMergeGateIds } from './js-ts-safe-merge-constants.js';
|
|
2
|
+
import { addConflict } from './js-ts-safe-merge-context.js';
|
|
3
|
+
|
|
4
|
+
export function validateCrossSideExportStarAdditions(workerPlan, headPlan, context) {
|
|
5
|
+
if (context.deferReExportIdentityConflictsToProjectGraph === true) return;
|
|
6
|
+
for (const workerEntry of workerPlan.addedEntries) {
|
|
7
|
+
for (const headEntry of headPlan.addedEntries) {
|
|
8
|
+
if (!isSourceOnlyExportStarRisk(workerEntry, headEntry)) continue;
|
|
9
|
+
addConflict(context, {
|
|
10
|
+
code: JsTsSafeMergeConflictCodes.duplicateName,
|
|
11
|
+
gateId: JsTsSafeMergeGateIds.uniqueNames,
|
|
12
|
+
side: 'worker',
|
|
13
|
+
message: 'Source-only merge cannot prove export-star additions have disjoint public names.',
|
|
14
|
+
details: {
|
|
15
|
+
reasonCode: 'source-only-export-star-requires-project-graph',
|
|
16
|
+
workerKey: workerEntry.key,
|
|
17
|
+
headKey: headEntry.key,
|
|
18
|
+
workerStatement: workerEntry.text.trim(),
|
|
19
|
+
headStatement: headEntry.text.trim()
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function isSourceOnlyExportStarRisk(left, right) {
|
|
28
|
+
const leftStar = isExportStarReExportEntry(left);
|
|
29
|
+
const rightStar = isExportStarReExportEntry(right);
|
|
30
|
+
if (!leftStar && !rightStar) return false;
|
|
31
|
+
if (leftStar && rightStar && sameExportStarIdentity(left, right)) return false;
|
|
32
|
+
return isPublicSurfaceAddition(left) && isPublicSurfaceAddition(right);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isExportStarReExportEntry(entry) {
|
|
36
|
+
return entry?.kind === 'export' && entry.declarationInfo?.reExport === true && entry.declarationInfo?.exportStar === true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function sameExportStarIdentity(left, right) {
|
|
40
|
+
return left?.declarationInfo?.moduleSpecifier === right?.declarationInfo?.moduleSpecifier
|
|
41
|
+
&& Boolean(left?.declarationInfo?.typeOnly) === Boolean(right?.declarationInfo?.typeOnly);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function isPublicSurfaceAddition(entry) {
|
|
45
|
+
return entry?.kind === 'export' || entry?.declarationInfo?.exported === true;
|
|
46
|
+
}
|
|
@@ -46,7 +46,7 @@ function addProjectGraphDeltaConflictSummary(projectGraphDelta, conflicts) {
|
|
|
46
46
|
publicContractConflicts: conflicts.filter((conflict) => conflict.code === 'project-public-contract-delta-conflict').length,
|
|
47
47
|
reExportIdentityConflicts: conflicts.filter((conflict) => conflict.code === 'project-re-export-identity-delta-conflict').length,
|
|
48
48
|
importTargetConflicts: conflicts.filter((conflict) => conflict.code === 'project-import-target-delta-conflict').length,
|
|
49
|
-
limitConflicts: conflicts.filter((conflict) => conflict.
|
|
49
|
+
limitConflicts: conflicts.filter((conflict) => conflict.gateId === 'project-graph-limit').length
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
}
|
package/package.json
CHANGED