Skip to content

Conversation

@linyows
Copy link
Owner

@linyows linyows commented Dec 28, 2025

Summary

Migrate the UI module build process from rollup bundler to TypeScript compiler (tsc), matching the approach used by the exporter module. This simplifies the build toolchain while maintaining full functionality.

Changes

Build System

  • Remove rollup: Eliminate rollup and all related plugins
  • Use tsc directly: Compile TypeScript with the TypeScript compiler
  • PostCSS for CSS: Handle CSS bundling separately using PostCSS

Configuration

  • Reorganize TypeScript configs into src/exporter/ and src/ui/ directories
  • Move vite.config.ts to .storybook/ (only used by Storybook)
  • Update .gitignore to exclude build artifacts while allowing build scripts

Build Scripts

Add custom scripts to handle build steps that rollup previously managed:

  • generate-css-entry.js: Auto-generate CSS entry file with all imports
  • fix-ui-build-output.js: Fix TypeScript output directory structure
  • remove-css-imports.js: Remove CSS imports from compiled .js and .d.ts files
  • add-use-client.js: Add 'use client' directives for Next.js App Router compatibility
  • postcss-remove-dark.js: PostCSS plugin to create light-mode-only CSS variant

Package Changes

  • ESM-only: Remove UMD and CJS builds, provide ESM only
  • Updated exports: Simplify package exports structure
  • Dependencies: Replace rollup plugins with postcss, postcss-cli, cssnano

Documentation

  • Add comprehensive README for build scripts explaining purpose and workflow
  • Add development workflow to app-router example

Testing

Verified with examples/app-router using npm pack:

  • ✅ Package builds successfully
  • ✅ All components render correctly
  • ✅ No CSS import errors
  • ✅ Type definitions work properly
  • ✅ 'use client' directives present in all files

Benefits

  1. Simpler toolchain: One less bundler to maintain
  2. Consistent approach: Both exporter and UI now use tsc
  3. Better modularity: Configs live with their respective source code
  4. Clearer build process: Each step is explicit and documented
  5. Smaller bundle: ESM-only reduces package size

Breaking Changes

None. The package API and exports remain unchanged.

- Move tsconfig.exporter.json to src/exporter/tsconfig.json
- Move tsconfig.ui.esm.json to src/ui/tsconfig.json
- Remove rollup.config.ts (no longer needed)
- Remove root tsconfig.json (rollup-specific config)

This reorganizes the build configuration to use tsc directly instead of
rollup, with configs living alongside their respective source code.
Add custom build scripts to handle UI module compilation:

- generate-css-entry.js: Auto-generates CSS entry file with all imports
- fix-ui-build-output.js: Fixes directory structure from tsc output
- remove-css-imports.js: Removes CSS imports from compiled .js and .d.ts files
- add-use-client.js: Adds 'use client' directive for Next.js App Router
- postcss-remove-dark.js: PostCSS plugin to remove dark mode styles
- README.md: Documentation for all build scripts

These scripts replace rollup's bundling functionality and handle:
- CSS bundling separately from JavaScript
- TypeScript output cleanup
- React Server Components compatibility
Dependencies:
- Remove rollup and related plugins
- Add postcss, postcss-cli, postcss-import, cssnano for CSS processing

Build scripts:
- Replace 'ui:rollup' with granular build steps:
  - ui:clean: Clean dist directory
  - ui:css:generate: Generate CSS entry file
  - ui:tsc: Compile TypeScript
  - ui:fix-output: Fix output directory structure
  - ui:remove-css-imports: Remove CSS imports from compiled files
  - ui:css:build: Bundle and minify CSS
  - ui:css:build:without-dark: Build CSS without dark mode
  - ui:use-client: Add 'use client' directives

Package exports:
- Switch to ESM-only (remove UMD and CJS)
- Update type definitions path: types.d.ts -> index.d.ts
- Update CSS paths to dist/ui/
- Move vite.config.ts to .storybook/ (only used by Storybook)
- Update .storybook/main.ts to reference new config location
- Update .gitignore to:
  - Exclude build scripts from JS ignore pattern
  - Remove css.d.ts (it's a source file, not build artifact)
Add css.d.ts to allow TypeScript to understand CSS module imports
during development and compilation.
Add instructions for testing local Rotion changes using npm pack:
- Build the package
- Create tarball
- Install in example
- Run dev server

This helps developers verify changes before publishing.
@linyows linyows self-assigned this Dec 28, 2025
* main:
  fix: add VCR pattern to oEmbed API tests to prevent flaky failures
@linyows linyows merged commit 2bbec65 into main Dec 28, 2025
3 checks passed
@linyows linyows deleted the remove-rollup branch December 28, 2025 03:19
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