Skip to content

Commit 6ff198d

Browse files
hi-ogawacodex
andcommitted
fix(rsc): attach positions to string export errors
Co-authored-by: Codex <noreply@openai.com>
1 parent c14d59e commit 6ff198d

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

packages/plugin-rsc/src/transforms/expand-export-all.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ function collectExplicitExportNames(ast: Program): Set<string> {
148148
if (spec.exported.type === 'Identifier') {
149149
names.add(spec.exported.name)
150150
} else {
151-
throw new Error('unsupported string literal export name')
151+
throw Object.assign(
152+
new Error('unsupported string literal export name'),
153+
{ pos: spec.exported.start },
154+
)
152155
}
153156
}
154157
}

packages/plugin-rsc/src/transforms/proxy-export.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ export function transformProxyExport(
107107
const names: string[] = []
108108
for (const spec of node.specifiers) {
109109
if (spec.exported.type !== 'Identifier') {
110-
throw new Error('unsupported string literal export name')
110+
throw Object.assign(
111+
new Error('unsupported string literal export name'),
112+
{ pos: spec.exported.start },
113+
)
111114
}
112115
names.push(spec.exported.name)
113116
}

packages/plugin-rsc/src/transforms/wrap-export.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ export function transformWrapExport(
147147
for (const spec of node.specifiers) {
148148
tinyassert(spec.local.type === 'Identifier')
149149
if (spec.exported.type !== 'Identifier') {
150-
throw new Error('unsupported string literal export name')
150+
throw Object.assign(
151+
new Error('unsupported string literal export name'),
152+
{ pos: spec.exported.start },
153+
)
151154
}
152155
const name = spec.local.name
153156
toAppend.push(
@@ -163,7 +166,10 @@ export function transformWrapExport(
163166
for (const spec of node.specifiers) {
164167
tinyassert(spec.local.type === 'Identifier')
165168
if (spec.exported.type !== 'Identifier') {
166-
throw new Error('unsupported string literal export name')
169+
throw Object.assign(
170+
new Error('unsupported string literal export name'),
171+
{ pos: spec.exported.start },
172+
)
167173
}
168174
wrapExport(spec.local.name, spec.exported.name)
169175
}

0 commit comments

Comments
 (0)