-
-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(astBuilder): fix export statment #1998
Conversation
@willemneal Can you take a look? |
I'm still unsure what the issue is here. Is it that an AST from |
Yes, ASTbuilder does not handle the situation when the In /** Initializes an `export` statement. */
private initializeExports(
/** The statement to initialize. */
statement: ExportStatement,
/** Parent file. */
parent: File,
/** So far queued `export`s. */
queuedExports: Map<File,Map<string,QueuedExport>>,
/** So far queued `export *`s. */
queuedExportsStar: Map<File,QueuedExportStar[]>
): void {
var members = statement.members;
if (members) { // export { foo, bar } [from "./baz"]
for (let i = 0, k = members.length; i < k; ++i) {
this.initializeExport(members[i], parent, statement.internalPath, queuedExports);
}
} else { // export * from "./baz"
let queued: QueuedExportStar[];
if (queuedExportsStar.has(parent)) queued = assert(queuedExportsStar.get(parent));
else queuedExportsStar.set(parent, queued = []);
let foreignPath = statement.internalPath!; // must be set for export *
queued.push(new QueuedExportStar(
foreignPath,
foreignPath.endsWith(INDEX_SUFFIX) // strip or add index depending on what's already present
? foreignPath.substring(0, foreignPath.length - INDEX_SUFFIX.length)
: foreignPath + INDEX_SUFFIX,
assert(statement.path)
));
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay makes sense to me.
@MaxGraey Hi, anything wrong ? |
Now
export * from "xx"
will be built toexport {} from "xx"
.@willemneal visitor-as also has this problem.
It makes the behavior of the compiler plug-in difficult to understand, because there may be many files that are modified.