Skip to content

fix: compile themeable package to CommonJS so it is importable - #181

Open
amanabiy wants to merge 1 commit into
mainfrom
dev-v3-amanabiy-chat-theming
Open

amanabiy wants to merge 1 commit into
mainfrom
dev-v3-amanabiy-chat-theming

Conversation

@amanabiy

@amanabiy amanabiy commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Mirror the components repo: compile src-themeable to CommonJS and point the exports entry at the file via default, so both import and require resolve to the CJS build.

Also drop designTokensTemplateDir: chat components reuse the core design tokens and ship no template-tokens directory, so the build failed with ENOENT once the import succeeded. The option is optional in theming-build; the design-tokens output is still generated from the preset.

ticket: AWSUI-62329

Description

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The themeable entry point `theming.js` is a copy of the one in
cloudscape-design/components, which compiles it to CommonJS. This repo
compiled it with `module: ESNext`, so the emitted file kept `import`
syntax and Node loaded it as ESM, where `__dirname` is not defined:

    ReferenceError: __dirname is not defined in ES module scope

Mirror the components repo: compile `src-themeable` to CommonJS and
point the `exports` entry at the file via `default`, so both `import`
and `require` resolve to the CJS build.

Also drop `designTokensTemplateDir`: chat components reuse the core
design tokens and ship no `template-tokens` directory, so the build
failed with ENOENT once the import succeeded. The option is optional in
theming-build; the design-tokens output is still generated from the
preset.
@amanabiy amanabiy changed the title fix: Compile themeable package to CommonJS so it is importable fix: compile themeable package to CommonJS so it is importable Oct 7, 2026
@amanabiy
amanabiy marked this pull request as ready for review October 7, 2026 11:26
@amanabiy
amanabiy requested a review from a team as a code owner October 7, 2026 11:26
@amanabiy
amanabiy requested review from srungta08 and removed request for a team October 7, 2026 11:26
@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.16%. Comparing base (6ed3348) to head (35acef6).

❌ Your project check has failed because the head coverage (88.16%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #181   +/-   ##
=======================================
  Coverage   88.16%   88.16%           
=======================================
  Files          25       25           
  Lines         355      355           
  Branches      100      101    +1     
=======================================
  Hits          313      313           
  Misses         42       42           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@amanabiy
amanabiy requested a review from avinashbot October 8, 2026 09:37
@amanabiy
amanabiy enabled auto-merge October 8, 2026 17:26

This branch was successfully deployed

1 active deployment
dev-pages — 35acef60 Deployed Oct 7, 2026 by amanabiy via deploy / deploy #810
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant