Conversation
Reviewer's GuideAdds a custom elements manifest plugin to append Svelte JSX typings and explicit exports to dist/index.d.ts, and introduces a dev flag across the Rollup build configs to control CSS minification, filename hashing, asset naming, and terser usage for more developer-friendly builds. Class diagram for updated build configs and custom elements manifest pluginclassDiagram
class CustomElementsManifestConfig {
+cemSorterPlugin()
+jsxTypesPlugin(fileName, outdir, excludeCssCustomProperties)
+addDtsExportsPlugin()
}
class AddDtsExportsPlugin {
+name
+packageLinkPhase(customElementsManifest)
}
class ConfigUtils {
+getPluginsConfig(modulePaths, options)
+getMainBundleConfig(options)
+getDemoConfig(options)
}
class BuildIndex {
+runProductionBuild(options)
}
class RollupConfig {
+input
+outputDir
+format
+dev
+output
+external
+plugins
+watch
}
class LitScssPlugin {
+minify
+options
}
class OutputOptions {
+format
+dir
+entryFileNames
+chunkFileNames
+assetFileNames
}
class Options {
+watch
+modulePaths
+input
+outputDir
+format
+dev
}
CustomElementsManifestConfig --> AddDtsExportsPlugin : uses
CustomElementsManifestConfig --> cemSorterPlugin : uses
CustomElementsManifestConfig --> jsxTypesPlugin : uses
ConfigUtils --> RollupConfig : creates
ConfigUtils --> LitScssPlugin : configures
ConfigUtils --> OutputOptions : configures
BuildIndex --> ConfigUtils : uses
BuildIndex --> RollupConfig : modifies
RollupConfig o-- OutputOptions : has
RollupConfig o-- LitScssPlugin : has
Options <.. ConfigUtils : parameter
Options <.. BuildIndex : parameter
AddDtsExportsPlugin : +string name
AddDtsExportsPlugin : +packageLinkPhase(customElementsManifest)
ConfigUtils : +getPluginsConfig(modulePaths, options)
ConfigUtils : +getMainBundleConfig(options)
ConfigUtils : +getDemoConfig(options)
BuildIndex : +runProductionBuild(options)
LitScssPlugin : +minify
LitScssPlugin : +options
OutputOptions : +entryFileNames(chunk)
OutputOptions : +chunkFileNames
OutputOptions : +assetFileNames
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
DukeFerdinand
approved these changes
Dec 3, 2025
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- In
addDtsExportsPlugin,exportedModules[0].exportswill throw if no module matchessrc/index.js; add a guard forexportedModules.length === 0before accessing the first element. - The
fs.appendFilecall inaddDtsExportsPluginis fire-and-forget; consider makingpackageLinkPhaseasync and awaiting the write (or using a synchronous API) so the build doesn't complete before theindex.d.tsupdate finishes or swallows errors.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `addDtsExportsPlugin`, `exportedModules[0].exports` will throw if no module matches `src/index.js`; add a guard for `exportedModules.length === 0` before accessing the first element.
- The `fs.appendFile` call in `addDtsExportsPlugin` is fire-and-forget; consider making `packageLinkPhase` async and awaiting the write (or using a synchronous API) so the build doesn't complete before the `index.d.ts` update finishes or swallows errors.
## Individual Comments
### Comment 1
<location> `src/configs/custom-elements-manifest.config.mjs:12` </location>
<code_context>
+ packageLinkPhase({customElementsManifest}){
+
+ // find modules where path matches 'src/index.js'
+ const exportedModules = customElementsManifest.modules.filter(
+ (mod) => mod.path.endsWith("src/index.js")
+ );
</code_context>
<issue_to_address>
**issue:** Guard against the case where no module matches `src/index.js` before accessing `exportedModules[0]`.
If `filter(...)` returns an empty array, `exportedModules[0]` is `undefined` and accessing `.exports` will throw before the `exportNames.length === 0` check. Add a guard (e.g. early return when `exportedModules.length === 0` or use optional chaining) to avoid this.
</issue_to_address>
### Comment 2
<location> `src/configs/custom-elements-manifest.config.mjs:40-42` </location>
<code_context>
+export { ${exportNames.join(', ')} } from "./index.js";\n`;
+
+ // append export statement to dist/index.d.ts
+ fs.appendFile('dist/index.d.ts', exportStatement).then(() => {
+ console.info('Appended export statements to index.d.ts');
+ }).catch((err) => {
+ console.error(`Error appending to index.d.ts: ${err.message}`);
+ });
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider making the `packageLinkPhase` handler `async` and awaiting `appendFile` instead of fire-and-forget.
Because `fs.appendFile` isn’t awaited, the build can complete and consumers may read `dist/index.d.ts` before the new exports are written, especially in fast builds or watch mode. Making `packageLinkPhase` `async` and awaiting `fs.appendFile` guarantees the manifest step only continues once the declarations are correctly updated.
Suggested implementation:
```javascript
// append export statement to dist/index.d.ts
try {
await fs.appendFile('dist/index.d.ts', exportStatement);
console.info('Appended export statements to index.d.ts');
} catch (err) {
console.error(`Error appending to index.d.ts: ${err.message}`);
}
```
To fully implement the suggestion you also need to:
1. Make the `packageLinkPhase` handler `async`. For example, if it currently looks like:
- `packageLinkPhase() { ... }` change it to `async packageLinkPhase() { ... }`, or
- `packageLinkPhase: () => { ... }` change it to `packageLinkPhase: async () => { ... }`.
2. Ensure whatever calls `packageLinkPhase` supports (or awaits) an async hook, following the conventions of the custom elements manifest tooling you are using.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Member
|
🎉 This PR is included in version 3.4.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alaska Airlines Pull Request
Checklist:
By submitting this Pull Request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Pull Requests will be evaluated by their quality of update and whether it is consistent with the goals and values of this project. Any submission is to be considered a conversation between the submitter and the maintainers of this project and may require changes to your submission.
Thank you for your submission!
-- Auro Design System Team
Summary by Sourcery
Improve build outputs and type declarations for better dev experience and Svelte integration.
New Features:
Enhancements: