Repository navigation
refactor(@angular/cli): import markdown files directly for command descriptions - #34092
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors how command long descriptions are loaded in the Angular CLI. Instead of dynamically reading files at runtime using paths, markdown files are now imported directly as asset dependencies, supported by a new ambient module declaration and a custom CommonJS markdown loader hook. Feedback suggests simplifying the markdown loader hook to handle all .md files rather than restricting it to long-description.md files, which prevents potential runtime errors when other markdown files are imported.
…scriptions Use TypeScript ambient module declaration for *.md files and register a scoped markdown require extension hook in CommonJS to allow direct import of command long descriptions. Loading markdown directly via module imports prepares the CLI codebase for ESM bundling, where __dirname and runtime filesystem reads are problematic. It simplifies unit tests by avoiding filesystem path resolution while bundling the text content seamlessly during production builds. This eliminates 12 __dirname references across command modules and removes the obsolete longDescriptionPath property.
eeddbc5 to
1acdec7
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Use TypeScript ambient module declaration for *.md files and register a scoped markdown require extension hook in CommonJS to allow direct import of command long descriptions.
Loading markdown directly via module imports prepares the CLI codebase for ESM bundling, where
__dirnameand runtime filesystem reads are problematic. It simplifies unit tests by avoiding filesystem path resolution while bundling the text content seamlessly during production builds.This eliminates 12
__dirnamereferences across command modules and removes the obsolete longDescriptionPath property.