Skip to content

RC #244#245

Merged
rmenner merged 1 commit into
mainfrom
rc/244
Dec 3, 2025
Merged

RC #244#245
rmenner merged 1 commit into
mainfrom
rc/244

Conversation

@rmenner

@rmenner rmenner commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator

Alaska Airlines Pull Request

Checklist:

  • My update follows the CONTRIBUTING guidelines of this project
  • I have performed a self-review of my own update

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:

  • Append global Svelte JSX intrinsic element typings and explicit re-exports to the generated dist/index.d.ts based on src/index.js exports.

Enhancements:

  • Add a dev mode flag to build configs to disable CSS minification and use stable, non-hashed filenames during development while retaining hashed assets in production.
  • Allow demo builds to optionally use non-hashed asset filenames in dev while keeping minified, hashed outputs for production.
  • Conditionally apply JS minification with terser only for non-dev production builds.

@rmenner
rmenner requested a review from a team as a code owner December 3, 2025 21:59
@sourcery-ai

sourcery-ai Bot commented Dec 3, 2025

Copy link
Copy Markdown

Reviewer's Guide

Adds 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 plugin

classDiagram

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
Loading

File-Level Changes

Change Details Files
Add a custom-elements-manifest plugin that appends global Svelte JSX intrinsic element typings and re-exports all index.js exports from the generated dist/index.d.ts file.
  • Introduce addDtsExportsPlugin with a packageLinkPhase hook that finds the src/index.js module in the CEM, collects its export names, and logs a warning when none are found.
  • Construct and append a TypeScript declaration snippet that augments the global svelteHTML.IntrinsicElements interface and re-exports all collected names from ./index.js into dist/index.d.ts using fs.appendFile.
  • Wire the new plugin into the custom-elements-manifest config plugin chain after jsxTypesPlugin and remove the defaultExport option from jsxTypesPlugin.
src/configs/custom-elements-manifest.config.mjs
Introduce a dev option through the build configuration to disable minification and hashing for easier development while keeping optimized behavior for production builds.
  • Extend getPluginsConfig to accept a dev flag and disable litScss CSS minification when dev is true.
  • Update getMainBundleConfig to accept dev, use stable filenames in dev and hashed filenames for non-entry chunks and assets in production, and pass dev into getPluginsConfig.
  • Update getDemoConfig to accept dev, control assetFileNames hashing based on dev, and pass dev into getPluginsConfig.
  • Change runProductionBuild to only add the terser plugin when dev is not enabled, allowing unminified builds in dev.
src/scripts/build/configUtils.js
src/scripts/build/index.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/configs/custom-elements-manifest.config.mjs
@rmenner
rmenner merged commit 8c3dd1d into main Dec 3, 2025
15 checks passed
@rmenner
rmenner deleted the rc/244 branch December 3, 2025 22:03
@rmenner rmenner linked an issue Dec 3, 2025 that may be closed by this pull request
@jason-capsule42

Copy link
Copy Markdown
Member

🎉 This PR is included in version 3.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jason-capsule42 jason-capsule42 added the released Completed work has been released label Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Completed work has been released semantic-status: fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RC 2025-12-03

3 participants