@shapeshift-labs/frontier-lang-compiler 0.2.140 → 0.2.141

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 CHANGED
@@ -295,6 +295,9 @@ Public contract regions include `apiSurfaceKind`, `signatureHash`, and
295
295
  For `export * from './module.js'`, project graphs fan out re-export identities
296
296
  for each named export in the resolved target document and omit `default`, which
297
297
  matches JavaScript module semantics.
298
+ Output graph admission can use those expanded identities to accept disjoint
299
+ export-star additions while blocking incompatible duplicate exported names as
300
+ `project-output-re-export-identity-conflict`.
298
301
 
299
302
  When using `createTypeScriptCompilerNativeImporterAdapter`,
300
303
  `createEstreeNativeImporterAdapter`, or `createBabelNativeImporterAdapter`,
@@ -1,3 +1,4 @@
1
+ import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
1
2
  import { compactRecord } from './js-ts-safe-merge-context.js';
2
3
  import { projectGraphDeltaConflicts } from './js-ts-safe-project-merge-graph-delta-conflicts.js';
3
4
 
@@ -25,7 +26,8 @@ function outputProjectGraphConflicts(projectSymbolGraph) {
25
26
  return [
26
27
  ...limitConflicts,
27
28
  ...[...missingModuleGroups.values()].map(projectGraphMissingImportConflict),
28
- ...[...missingSymbolGroups.values()].map(projectGraphMissingTargetConflict)
29
+ ...[...missingSymbolGroups.values()].map(projectGraphMissingTargetConflict),
30
+ ...duplicateReExportIdentityConflicts(projectSymbolGraph?.reExportIdentities)
29
31
  ];
30
32
  }
31
33
 
@@ -94,6 +96,83 @@ function projectImportTargetName(edge) {
94
96
  return String(name);
95
97
  }
96
98
 
99
+ function duplicateReExportIdentityConflicts(records = []) {
100
+ const groups = new Map();
101
+ for (const record of records) {
102
+ const key = reExportIdentityKey(record);
103
+ if (!key) continue;
104
+ const group = groups.get(key) ?? [];
105
+ group.push(record);
106
+ groups.set(key, group);
107
+ }
108
+ return [...groups.entries()]
109
+ .filter(([, group]) => new Set(group.map(reExportIdentityFingerprint)).size > 1)
110
+ .map(([identityKey, group]) => projectGraphDuplicateReExportIdentityConflict(identityKey, group));
111
+ }
112
+
113
+ function projectGraphDuplicateReExportIdentityConflict(identityKey, group) {
114
+ const record = group[0] ?? {};
115
+ return {
116
+ code: 'project-output-re-export-identity-conflict',
117
+ gateId: 'project-symbol-graph',
118
+ message: `Output project graph exposes incompatible re-export identity ${JSON.stringify(identityKey)}.`,
119
+ sourcePath: record.sourcePath,
120
+ details: compactRecord({
121
+ reasonCode: 'project-output-re-export-identity-conflict',
122
+ conflictKey: `project-output-re-export-identity#${identityKey}`,
123
+ identityKey,
124
+ sourcePath: record.sourcePath,
125
+ exportedName: record.exportedName,
126
+ records: group.map(reExportIdentityDetails)
127
+ })
128
+ };
129
+ }
130
+
131
+ function reExportIdentityKey(record) {
132
+ return stableKey([
133
+ 're-export-identity',
134
+ record?.sourcePath,
135
+ record?.exportedName ?? record?.localName ?? record?.namespace ?? (record?.exportStar || record?.isExportStar ? '*' : undefined)
136
+ ]);
137
+ }
138
+
139
+ function reExportIdentityFingerprint(record) {
140
+ return hashSemanticValue({
141
+ moduleSpecifier: record.moduleSpecifier,
142
+ exportedName: record.exportedName,
143
+ importedName: record.importedName,
144
+ localName: record.localName,
145
+ namespace: record.namespace,
146
+ isTypeOnly: record.isTypeOnly,
147
+ exportStar: record.exportStar,
148
+ isExportStar: record.isExportStar,
149
+ originSymbolId: record.originSymbolId,
150
+ exportedSymbolId: record.exportedSymbolId,
151
+ localSymbolId: record.localSymbolId
152
+ });
153
+ }
154
+
155
+ function reExportIdentityDetails(record) {
156
+ return compactRecord({
157
+ moduleSpecifier: record.moduleSpecifier,
158
+ exportedName: record.exportedName,
159
+ importedName: record.importedName,
160
+ localName: record.localName,
161
+ namespace: record.namespace,
162
+ isTypeOnly: record.isTypeOnly,
163
+ exportStar: record.exportStar,
164
+ isExportStar: record.isExportStar,
165
+ originSymbolId: record.originSymbolId,
166
+ exportedSymbolId: record.exportedSymbolId,
167
+ localSymbolId: record.localSymbolId
168
+ });
169
+ }
170
+
171
+ function stableKey(parts) {
172
+ const values = parts.map((part) => part === undefined || part === null ? '' : String(part));
173
+ return values.some(Boolean) ? values.join('#') : undefined;
174
+ }
175
+
97
176
  function uniqueStrings(values) {
98
177
  return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))];
99
178
  }
@@ -111,7 +111,7 @@ function mergeProjectFile(file, input, projectId) {
111
111
  const result = safeMergeJsTsSource({
112
112
  ...input,
113
113
  ...context,
114
- deferReExportIdentityConflictsToProjectGraph: input.includeProjectGraphDelta === true,
114
+ deferReExportIdentityConflictsToProjectGraph: input.includeProjectGraphDelta === true || input.includeOutputProjectSymbolGraph === true,
115
115
  id: `${projectId}_${safeId(file.sourcePath)}`,
116
116
  baseSourceText: base,
117
117
  workerSourceText: worker,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.140",
3
+ "version": "0.2.141",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",