Skip to content

Build api, component and fluent-theme with tsdown - #6079

Open
Eugene (OEvgeny) wants to merge 20 commits into
mainfrom
OEvgeny/feat-tsdown-css-packages
Open

Eugene (OEvgeny) wants to merge 20 commits into
mainfrom
OEvgeny/feat-tsdown-css-packages

Conversation

@OEvgeny

@OEvgeny Eugene (OEvgeny) commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Second step of moving the build from tsup to tsdown, after #6071: the packages with CSS modules.

Changelog Entry

Changed

  • Built botframework-webchat-api, botframework-webchat-component and botframework-webchat-fluent-theme with tsdown instead of tsup, in PR #6079, by @OEvgeny

Description

tsup is no longer actively maintained and its declaration build does not work with TypeScript 7 (egoist/tsup#1405). After #6071, this pull request moves api, component and fluent-theme to tsdown with the same exports, declarations, class names and CSS order; bundle and debug-theme follow.

Design

  • CSS modules keep our Lightning CSS pipeline instead of the experimental @tsdown/css, which writes one CSS file per build or chunk; we inject one per entry.
  • Output changes: a few more -webkit- prefixes for Safari 15; no CSS source map (nothing reads it), metafile-*.json or *.LEGAL.txt; JS 3–15 % smaller.

Specific Changes

  • rolldownPlugins.mjs: cssPlugin compiles CSS modules and writes <entry>.css
  • injectCSSRolldownPlugin.ts: rolldown flavor of injectCSSPlugin
  • tsdown.base.config.mts: one cssPlugin per build, with its minify and target
  • tsdown.config.mts instead of tsup.config.ts in api, component and fluent-theme
  • lightningCSSOptions.mjs: sortClassMap, since Lightning CSS returns class maps in random order; its spec runs in npm run precommit (CI: Static code analysis)
  • sharedStylesRuntime.spec.js: counts the styles runtime in the published scripts, not in metafiles
  • addMetaTag.spec.* of api, component and fluent-theme: build tool is tsdown
  • I have added tests and executed them locally
  • I have added .changelog/<PR#>-<slug>.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

Eugene Olonov added 19 commits November 13, 2026 02:43
- tsdown 0.23.7 (rolldown 1.3.0, rolldown-plugin-dts 0.30.0), next to tsup.
- tsdown.base.config.mts: port of tsup.base.config.ts with createDualFormatConfigs(), iifeOptions() and packagePattern().
- rolldownPlugins.mjs: cssPlugin (CSS modules with the same Lightning CSS options, bundled per entry, lowered for the targets, with a source map) and istanbulPlugin (NODE_ENV=test).
- injectCSSRolldownPlugin: rolldown flavor of injectCSSPlugin, next to it.
api-graph, api-middleware, base, component-better-link, core, core-debug-api, core-graph, core-json-ld, directlinespeech, react-hooks, react-valibot, redux-store, styles and test/web-server.
No package of this step has CSS modules: cssPlugin, injectCSSRolldownPlugin and css: false come with api, component and fluent-theme. Also drop the metafile exclusion of directlinespeech, tsdown writes none.
- rolldownPlugins.mjs cssPlugin: CSS modules with the same Lightning CSS options, bundled per entry in esbuild's order, lowered for the targets per module, with a rule-level source map.
- injectCSSRolldownPlugin: rolldown flavor of injectCSSPlugin, next to it.
- tsdown.base.config.mts creates cssPlugin in the build:before hook, with the minify and target of the build being run: a config's own minify (e.g. a production.min IIFE in a development build) is honored, and configs that spread another config no longer share its state.
- @jridgewell/sourcemap-codec is now a root devDependency (rolldownPlugins.mjs imports it).
- Same entries, formats and placeholders as the tsup configs; fluent-theme's IIFE builds resolve React and Web Chat from the page with a rolldown umdResolvePlugin.

- sharedStylesRuntime.spec.js counts the copies of the styles runtime in the published scripts instead of reading esbuild metafiles, which tsdown does not write.

- addMetaTag specs expect buildTool "tsdown".
Minified CommonJS is no longer compressed: oxc prints `enumerable: !0` in re-export getters, which cjs-module-lexer (Node.js) does not match. component hook.js exposes 102/102 names again, like tsup; CommonJS is 4-5 % larger than compressed.
Minified CommonJS is no longer compressed: oxc prints `enumerable: !0` in re-export getters, which cjs-module-lexer (Node.js) does not match. Production CommonJS lists the same names as tsup again, for a few % more bytes than compressed.
Lightning CSS returns the classes of a CSS module in random order (a Rust
HashMap; fixed upstream in parcel-bundler/lightningcss#1355, not released in
1.33.0), so two builds of the same tree wrote the class maps of component,
fluent-theme and bundle in different orders. Sort them by class name in the
rolldown and esbuild plugins; class names and CSS are unchanged.

The rolldown class map modules no longer carry a source map: their source
was the generated code with the absolute path of the built CSS.
rolldown-plugin-dts emits declarations module by module as they load and
TypeScript 6 prints union members in type creation order, so two clean builds
printed unions such as the core-graph schemas and injectStyleElementsPropsSchema
in a different order. stableTypeOrdering (hidden TypeScript 6.0 option, the
TypeScript 7 behavior) orders them by declaration position instead.
…ss-packages

Step 2 merged as #6071 (8f113e3). Conflicts:
- tsdown.base.config.mts: main's escape-string-regexp import, onlyBundle comment and packagePattern(), plus this branch's cssPlugin import, css: false, build:before hook and checks.
- rolldownPlugins.mjs: this branch's version (main's istanbulPlugin is unchanged).
- package-lock.json: main's, regenerated with npm install --package-lock-only.
Nothing reads them. The packages do not export <entry>.css: injectCSSRolldownPlugin injects it into the entry's
script, without a source map. `npm start` rebuilds with notify-build.sh and `build:run`, not `tsdown --watch`.

This removes concatCSS() and the root devDependency on @jridgewell/sourcemap-codec.
Since the class map is sorted in a transform hook, rolldown warned SOURCEMAP_BROKEN once per CSS module and build
(190 times in a full build). The class map is generated code, so its lines map to nothing, as before: the output,
source maps included, is byte-identical.
`moduleSideEffects: 'no-treeshake'` came from @tsdown/css. Our plugin finds the CSS of an entry through the module
graph (getModuleInfo().importedIds), not through the chunks, so it does not need the empty module in a chunk.
component and fluent-theme build byte-identical without it.
Measured in a component build:
- Without `css: false`, tsdown fails on each of the 53 CSS modules: "CSS file … was encountered but `@tsdown/css` is
  not installed".
- With the toleratedTransform check on, rolldown warns 351 times, once per class of the CommonJS (ES2019) build, for
  string export names like `export { _toast0 as "toast" }`, not only dashed ones.
…ss-packages

Brings #6072 (the root and BasicWebChat layout as CSS modules) and #6074. No conflicts.
So CI runs it: the "Static code analysis" job runs the root `npm run precommit --if-present`.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Injecting CSS after chunk hashes are finalized can leave filenames unchanged for CSS-only updates, causing clients to receive stale cached styles.

2 open issues
What changed in this PR

Continues the migration started in #6071 by moving API, component, and Fluent theme builds from tsup to tsdown while retaining the Lightning CSS pipeline.

Changes:

  • Replaces package build configurations and preserves existing entry points and module formats.
  • Adds Rolldown CSS compilation and injection, plus deterministic CSS class-map ordering.
  • Updates build metadata tests, shared-runtime checks, dependencies, and precommit checks.
File Description
tsdown.base.config.mts Registers CSS processing per build.
rolldownPlugins.mjs Compiles CSS modules and emits per-entry styles.
packages/​styles/​src/​build/​private/​injectCSSRolldownPlugin.ts Injects CSS into Rolldown output and adjusts source maps.
packages/​styles/​src/​build/​private/​injectCSSPlugin.ts Exports shared injection helpers.
packages/​styles/​src/​build/​index.ts Exports the Rolldown injection plugin.
packages/​fluent-theme/​tsup.config.ts Removes the previous build configuration.
packages/​fluent-theme/​tsdown.config.mts Configures module and browser-global builds.
packages/​fluent-theme/​src/​__tests__/​sharedStylesRuntime.spec.js Checks runtime copies in generated scripts.
packages/​fluent-theme/​src/​__tests__/​addMetaTag.spec.mjs Expects tsdown metadata for ES modules.
packages/​fluent-theme/​src/​__tests__/​addMetaTag.spec.js Expects tsdown metadata for CommonJS.
packages/​fluent-theme/​package.json Switches the build command and dependency.
packages/​fluent-theme/​.gitignore Removes the obsolete tsup ignore rule.
packages/​component/​tsup.config.ts Removes the previous build configuration.
packages/​component/​tsdown.config.mts Configures component entries and CSS injection.
packages/​component/​src/​__tests__/​addMetaTag.spec.mjs Expects tsdown metadata for ES modules.
packages/​component/​src/​__tests__/​addMetaTag.spec.js Expects tsdown metadata for CommonJS.
packages/​component/​package.json Switches the build command to tsdown.
packages/​component/​.gitignore Removes the obsolete tsup ignore rule.
packages/​api/​tsup.config.ts Removes the previous build configuration.
packages/​api/​tsdown.config.mts Configures API entries and Globalize bundling.
packages/​api/​src/​__tests__/​addMetaTag.spec.mjs Expects tsdown metadata for ES modules.
packages/​api/​src/​__tests__/​addMetaTag.spec.js Expects tsdown metadata for CommonJS.
packages/​api/​package.json Switches the build command to tsdown.
packages/​api/​.gitignore Removes the obsolete tsup ignore rule.
package.json Adds class-map tests to precommit checks.
package-lock.json Synchronizes the Fluent theme build dependency.
lightningCSSOptions.spec.mjs Tests deterministic class-map sorting.
lightningCSSOptions.mjs Adds class-map sorting.
esbuildPlugins.mjs Applies sorting to remaining esbuild builds.
.changelog/​6079-feat-tsdown-css-packages.md Records the build migration.

Review effort: Balanced

The rolldown flavor of the CSS injection finds the placeholder as written
between quotes, so a placeholder with a backslash or a quote would never
be found and the CSS would not be injected. Only letters, digits, "_",
"@", "." and "-" are allowed now, which covers our placeholders.

This branch has not been deployed

No deployments
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.

2 participants