Skip to content

Conversation

@flex-minhyeok
Copy link

@flex-minhyeok flex-minhyeok commented Nov 18, 2025

Summary

This PR adds support for vanilla-extract CSS-in-TypeScript library to Plasmo, enabling developers to write type-safe, zero-runtime CSS.

Changes

1. Custom Parcel Transformer (@plasmohq/parcel-transformer-vanilla-extract)

Created a new transformer package that:

  • Uses official @vanilla-extract/integration for CSS compilation
  • Processes .css.ts files at build time
  • Generates scoped CSS with unique, hashed class names
  • Returns TypeScript modules with class name mappings

Implementation: core/parcel-transformer-vanilla-extract/

2. Parcel Upgrade (2.9.3 → 2.10.0)

Upgraded Parcel to version 2.10.0 to enable node: protocol support, which is required for vanilla-extract dependencies.

Why this was necessary:

  • vanilla-extract's dependency @vanilla-extract/integration uses mlly
  • mlly imports Node.js builtins with the node: protocol (e.g., require('node:module'))
  • Parcel 2.9.3 does not properly support node: prefix in module resolution
  • Parcel 2.10.0 added this support via PR #9244 and PR #9250

See PARCEL_UPGRADE.md for detailed documentation of the upgrade rationale.

Changed packages:

  • All @parcel/* packages upgraded from 2.9.3 to 2.10.0

3. Example: with-vanilla-extract

Added a complete example demonstrating:

  • Type-safe CSS-in-TypeScript with vanilla-extract
  • Custom .parcelrc configuration
  • Styled popup component with hover effects
  • Comprehensive documentation

Example structure:

examples/with-vanilla-extract/
├── .parcelrc           # Extends Plasmo config with transformer
├── package.json        # Dependencies
├── popup.tsx           # React component using styles
├── styles.css.ts       # Type-safe CSS definitions
├── tsconfig.json       # TypeScript config
├── .gitignore
└── README.md          # Documentation & requirements

4. Core Configuration Update

Modified core/parcel-config/index.json to include the vanilla-extract transformer in the default Plasmo configuration:

{
  "transformers": {
    "*.css.ts": ["@plasmohq/parcel-transformer-vanilla-extract"]
  }
}

5. Example

with-vanilla-extract example PR: PlasmoHQ/examples#86

Breaking Changes

None. The Parcel upgrade is backward compatible and all existing examples continue to work.

Related

@flex-minhyeok flex-minhyeok force-pushed the feat-vanilla-extract-support branch 8 times, most recently from 771423c to 70d3c3b Compare November 19, 2025 11:31
Upgrade Parcel from 2.9.3 to 2.10.0 to support node: protocol imports required by vanilla-extract. Add @vanilla-extract/parcel-transformer and configure it to handle *.css.ts files.

- Upgrade @parcel/* packages to 2.10.0 (except @parcel/graph and @parcel/hash which remain at 2.9.3)
- Add @vanilla-extract/parcel-transformer 1.0.17 dependency
- Configure *.css.ts transformer in parcel-config
- Add with-vanilla-extract example
@flex-minhyeok flex-minhyeok force-pushed the feat-vanilla-extract-support branch from 70d3c3b to 246ad40 Compare November 19, 2025 13:27
@flex-minhyeok flex-minhyeok marked this pull request as ready for review November 19, 2025 13:27
@flex-minhyeok
Copy link
Author

@louisgv plz review this PR!

@flex-minhyeok
Copy link
Author

@louisgv I'd appreciate it if you could review this PR.

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