@shapeshift-labs/frontier-lang-compiler 0.2.125 → 0.2.126
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.
|
@@ -200,6 +200,7 @@ function validateCrossSideAddedNames(workerPlan, headPlan, context) {
|
|
|
200
200
|
const nameKey = `${entry.kind}:${name}`;
|
|
201
201
|
const headEntry = headEntriesByName.get(nameKey);
|
|
202
202
|
if (headEntry) {
|
|
203
|
+
if (shouldDeferReExportNameConflict(entry, headEntry, context)) continue;
|
|
203
204
|
const typeAliasConflict = entry.declarationInfo?.declarationKind === 'type'
|
|
204
205
|
|| headEntry.declarationInfo?.declarationKind === 'type';
|
|
205
206
|
addConflict(context, {
|
|
@@ -216,6 +217,16 @@ function validateCrossSideAddedNames(workerPlan, headPlan, context) {
|
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
219
|
|
|
220
|
+
function shouldDeferReExportNameConflict(left, right, context) {
|
|
221
|
+
return context.deferReExportIdentityConflictsToProjectGraph === true
|
|
222
|
+
&& isReExportEntry(left)
|
|
223
|
+
&& isReExportEntry(right);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function isReExportEntry(entry) {
|
|
227
|
+
return entry?.kind === 'export' && entry.declarationInfo?.reExport === true;
|
|
228
|
+
}
|
|
229
|
+
|
|
219
230
|
function validateCrossSideImportAdditions(workerPlan, headPlan, context) {
|
|
220
231
|
for (const [key, workerAdditions] of workerPlan.importAdditions) {
|
|
221
232
|
const headAdditions = headPlan.importAdditions.get(key) ?? [];
|
|
@@ -5,6 +5,7 @@ export function createMergeContext(input) {
|
|
|
5
5
|
id: String(input.id ?? 'js_ts_safe_merge'),
|
|
6
6
|
sourcePath: input.sourcePath,
|
|
7
7
|
language: input.language ?? 'typescript',
|
|
8
|
+
deferReExportIdentityConflictsToProjectGraph: input.deferReExportIdentityConflictsToProjectGraph === true,
|
|
8
9
|
conflicts: [],
|
|
9
10
|
blockedGateIds: new Set(),
|
|
10
11
|
gateReasonCodes: new Map()
|
|
@@ -24,6 +24,7 @@ export function validateLedgerUniqueness(ledger, context) {
|
|
|
24
24
|
const nameKey = `${entry.kind}:${name}`;
|
|
25
25
|
const existing = nameOwners.get(nameKey);
|
|
26
26
|
if (existing) {
|
|
27
|
+
if (shouldDeferMergedReExportNameConflict(ledger, existing, entry, context)) continue;
|
|
27
28
|
addConflict(context, {
|
|
28
29
|
code: JsTsSafeMergeConflictCodes.duplicateName,
|
|
29
30
|
gateId: JsTsSafeMergeGateIds.uniqueNames,
|
|
@@ -65,6 +66,17 @@ function validateUniqueImportSpecifiers(entry, side, context) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
function shouldDeferMergedReExportNameConflict(ledger, left, right, context) {
|
|
70
|
+
return ledger.label === 'merged'
|
|
71
|
+
&& context.deferReExportIdentityConflictsToProjectGraph === true
|
|
72
|
+
&& isReExportEntry(left)
|
|
73
|
+
&& isReExportEntry(right);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isReExportEntry(entry) {
|
|
77
|
+
return entry?.kind === 'export' && entry.declarationInfo?.reExport === true;
|
|
78
|
+
}
|
|
79
|
+
|
|
68
80
|
export function indexBaseLedger(base, context) {
|
|
69
81
|
const entriesByKey = new Map();
|
|
70
82
|
for (const entry of base.entries) entriesByKey.set(entry.key, entry);
|
|
@@ -19,7 +19,7 @@ export function classifyStatement(text, start, end) {
|
|
|
19
19
|
if (unsupported) return { unsupported, text, start, end };
|
|
20
20
|
return {
|
|
21
21
|
kind: declarationInfo.kind,
|
|
22
|
-
key:
|
|
22
|
+
key: declarationLedgerKey(declarationInfo),
|
|
23
23
|
text,
|
|
24
24
|
start,
|
|
25
25
|
end,
|
|
@@ -126,6 +126,50 @@ function parseDeclarationInfo(text) {
|
|
|
126
126
|
const defaultClass = trimmed.match(/^export\s+default\s+(?:abstract\s+)?class(?:\s+([A-Za-z_$][\w$]*))?\b/);
|
|
127
127
|
if (defaultClass) return { kind: 'declaration', names: ['default'], declarationKind: 'class', exported: true, defaultExport: true };
|
|
128
128
|
|
|
129
|
+
const namespaceReExport = trimmed.match(/^export\s+(type\s+)?\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s+(['"])([^'"]+)\3\s*;?$/);
|
|
130
|
+
if (namespaceReExport) {
|
|
131
|
+
return {
|
|
132
|
+
kind: 'export',
|
|
133
|
+
names: [namespaceReExport[2]],
|
|
134
|
+
declarationKind: 're-export-namespace',
|
|
135
|
+
exported: true,
|
|
136
|
+
typeOnly: Boolean(namespaceReExport[1]),
|
|
137
|
+
reExport: true,
|
|
138
|
+
moduleSpecifier: namespaceReExport[4],
|
|
139
|
+
namespace: namespaceReExport[2]
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const starReExport = trimmed.match(/^export\s+(type\s+)?\*\s+from\s+(['"])([^'"]+)\2\s*;?$/);
|
|
144
|
+
if (starReExport) {
|
|
145
|
+
return {
|
|
146
|
+
kind: 'export',
|
|
147
|
+
names: [],
|
|
148
|
+
declarationKind: 're-export-star',
|
|
149
|
+
exported: true,
|
|
150
|
+
typeOnly: Boolean(starReExport[1]),
|
|
151
|
+
reExport: true,
|
|
152
|
+
moduleSpecifier: starReExport[3],
|
|
153
|
+
exportStar: true
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const namedReExport = trimmed.match(/^export\s+(type\s+)?\{([\s\S]+)\}\s+from\s+(['"])([^'"]+)\3\s*;?$/);
|
|
158
|
+
if (namedReExport) {
|
|
159
|
+
const names = splitCommaList(namedReExport[2]).map((part) => parseExportSpecifierName(part)).filter(Boolean);
|
|
160
|
+
const expectedCount = splitCommaList(namedReExport[2]).filter((part) => part.trim()).length;
|
|
161
|
+
if (names.length !== expectedCount || names.length === 0) return undefined;
|
|
162
|
+
return {
|
|
163
|
+
kind: 'export',
|
|
164
|
+
names,
|
|
165
|
+
declarationKind: 're-export-list',
|
|
166
|
+
exported: true,
|
|
167
|
+
typeOnly: Boolean(namedReExport[1]),
|
|
168
|
+
reExport: true,
|
|
169
|
+
moduleSpecifier: namedReExport[4]
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
129
173
|
const namedExport = trimmed.match(/^export\s+(type\s+)?\{([\s\S]+)\}\s*;?$/);
|
|
130
174
|
if (namedExport) {
|
|
131
175
|
const names = splitCommaList(namedExport[2]).map((part) => parseExportSpecifierName(part)).filter(Boolean);
|
|
@@ -154,6 +198,19 @@ function parseDeclarationInfo(text) {
|
|
|
154
198
|
return undefined;
|
|
155
199
|
}
|
|
156
200
|
|
|
201
|
+
function declarationLedgerKey(declarationInfo) {
|
|
202
|
+
if (declarationInfo.reExport) {
|
|
203
|
+
return [
|
|
204
|
+
declarationInfo.kind,
|
|
205
|
+
declarationInfo.declarationKind,
|
|
206
|
+
declarationInfo.moduleSpecifier ?? '',
|
|
207
|
+
declarationInfo.typeOnly ? 'type' : 'value',
|
|
208
|
+
declarationInfo.exportStar ? '*' : declarationInfo.names.join('|')
|
|
209
|
+
].join(':');
|
|
210
|
+
}
|
|
211
|
+
return `${declarationInfo.kind}:${declarationInfo.names.join('|')}`;
|
|
212
|
+
}
|
|
213
|
+
|
|
157
214
|
function unsupportedDeclarationPolicy(text, declarationInfo) {
|
|
158
215
|
const trimmed = text.trim();
|
|
159
216
|
if (/^\s*@/m.test(text)) {
|
|
@@ -111,6 +111,7 @@ function mergeProjectFile(file, input, projectId) {
|
|
|
111
111
|
const result = safeMergeJsTsSource({
|
|
112
112
|
...input,
|
|
113
113
|
...context,
|
|
114
|
+
deferReExportIdentityConflictsToProjectGraph: input.includeProjectGraphDelta === true,
|
|
114
115
|
id: `${projectId}_${safeId(file.sourcePath)}`,
|
|
115
116
|
baseSourceText: base,
|
|
116
117
|
workerSourceText: worker,
|
package/package.json
CHANGED