Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu authored and nicolo-ribaudo committed Jan 8, 2024
1 parent 902b917 commit 16ee5b5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Expand Up @@ -213,6 +213,20 @@ function getExportSpecifierName(
}
}

function assertExportSpecifier(
path: NodePath,
): asserts path is NodePath<t.ExportSpecifier> {
if (path.isExportSpecifier()) {
return;
} else if (path.isExportNamespaceSpecifier()) {
throw path.buildCodeFrameError(
"Export namespace should be first transformed by `@babel/plugin-transform-export-namespace-from`.",
);
} else {
throw path.buildCodeFrameError("Unexpected export specifier type");
}
}

/**
* Get metadata about the imports and exports present in this module.
*/
Expand Down Expand Up @@ -350,6 +364,7 @@ function getModuleMetadata(
if (!data.loc) data.loc = child.node.loc;

child.get("specifiers").forEach(spec => {
assertExportSpecifier(spec);
const importName = getExportSpecifierName(
spec.get("local"),
stringSpecifiers,
Expand Down Expand Up @@ -450,8 +465,9 @@ function getLocalExportMetadata(
child.node.source &&
child.get("source").isStringLiteral()
) {
(child.node.specifiers as t.ExportSpecifier[]).forEach(spec => {
bindingKindLookup.set(spec.local.name, "block");
child.get("specifiers").forEach(spec => {
assertExportSpecifier(spec);
bindingKindLookup.set(spec.get("local").node.name, "block");
});
return;
}
Expand Down
@@ -0,0 +1,3 @@
{
"throws": "Export namespace should be first transformed by `@babel/plugin-transform-export-namespace-from`."
}

This file was deleted.

0 comments on commit 16ee5b5

Please sign in to comment.