-
Notifications
You must be signed in to change notification settings - Fork 25.4k
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(compiler-cli): produce metadata for .d.ts files without metadata #13526
Conversation
2fec6d8
to
53372e0
Compare
@@ -181,6 +181,9 @@ export class CompilerHost implements AotCompilerHost { | |||
const metadataPath = filePath.replace(DTS, '.metadata.json'); | |||
if (this.context.fileExists(metadataPath)) { | |||
return this.readMetadata(metadataPath, filePath); | |||
} else { | |||
return [this.upgradeVersion1Metadata( |
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.
+ add brief comment why no dts is equivalent to module v1
(Array.isArray(metadataOrMetadatas) ? metadataOrMetadatas : [metadataOrMetadatas]) : | ||
[]; | ||
const v1Metadata = metadatas.find((m: any) => m['version'] === 1); | ||
let v3Metadata = metadatas.find((m: any) => m['version'] === 3); | ||
const v1Metadata = metadatas.find(m => m.version === 1); |
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.
Is this considering l. 186 ? This should never be minified
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.
This code should never be minified through an aggressive minifier like closure so these are equivalent.
const isExported = (node: ts.FunctionDeclaration | ts.ClassDeclaration | ts.EnumDeclaration) => | ||
(node.flags & ts.NodeFlags.Export) || isExportedIdentifier(node.name); | ||
const exportedIdentifierName = (identifier: ts.Identifier) => | ||
exportMap.get(identifier.text) || identifier.text; |
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.
|| identifier.text
is this required ?
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.
ok got it, nevermind
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.
Yes. If the identifier is not renamed on export then it has its natural name.
@@ -376,9 +405,10 @@ export class MetadataCollector { | |||
} | |||
let exported = false; | |||
if (variableStatement.flags & ts.NodeFlags.Export || | |||
variableDeclaration.flags & ts.NodeFlags.Export) { | |||
variableDeclaration.flags & ts.NodeFlags.Export || |
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.
use isExported
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.
We cannot here because a variable declaration doesn't have a name but might have a name list. So instead of making isExported
complicated I left the special case here.
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.
LGTM with minor comments
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
All .d.ts files without metadata in v1 were considered to not have metadata for v3 so re-export information was lost and symbols reexported by these modules could not be resolved.
What is the new behavior?
A .d.ts file with no metadata will get metadata from the .d.ts file which will include the re-exports in that file.
Does this PR introduce a breaking change? (check one with "x")
Other information:
Fixes #13307