Skip to content

Conversation

@bennypowers
Copy link
Owner

@bennypowers bennypowers commented Nov 3, 2025

Closes #44

Summary by CodeRabbit

  • New Features

    • Adds a Parcel transformer to convert CSS imports into Lit css template literals, configurable and preprocessor-friendly.
  • Documentation

    • Parcel integration guide, configuration options, and usage examples added.
  • Tests

    • Integration tests and demo page added; test runner supports optional skip flags and includes mock packages for fixtures.
  • Chores

    • Added Parcel dev tooling and a postinstall setup script; updated git/ESLint ignores to exclude Parcel cache and package tarballs.

@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2025

🦋 Changeset detected

Latest commit: a154823

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
parcel-transformer-lit-css Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Nov 3, 2025

Walkthrough

Adds a new Parcel transformer package parcel-transformer-lit-css (implementation, package manifest, README), integration tests and fixtures, test harness and mock packages, a postinstall helper and symlink setup, and updates to ignore/config files for Parcel usage.

Changes

Cohort / File(s) Change Summary
Root config & scripts
\.eslintignore, \.gitignore, package.json
Add ESLint ignore for packages/*/integration-test/**/*.js, add .parcel-cache to .gitignore, add root postinstall script and Parcel devDependencies.
Transformer package manifest & docs
packages/parcel-transformer-lit-css/package.json, packages/parcel-transformer-lit-css/\.gitignore, packages/parcel-transformer-lit-css/README.md
New package manifest (exports, engines, peerDeps), add *.tgz ignore, and add README with installation, usage, options and examples.
Transformer implementation
packages/parcel-transformer-lit-css/parcel-transformer-lit-css.ts
New Parcel Transformer exporting LitCSSOptions type and default transformer with loadConfig (reads lit-css field) and transform (reads CSS, calls @pwrs/lit-css transform, sets asset.type = 'js', sets generated code).
Integration test package & app
packages/parcel-transformer-lit-css/integration-test/.parcelrc, packages/parcel-transformer-lit-css/integration-test/package.json, packages/parcel-transformer-lit-css/integration-test/README.md, packages/parcel-transformer-lit-css/integration-test/src/index.html, packages/parcel-transformer-lit-css/integration-test/src/my-element.js, packages/parcel-transformer-lit-css/integration-test/src/styles.css
New integration-test package registering the transformer, scripts for build/dev, Lit demo app files, and README with run/verify instructions.
Test harness & expected outputs
packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js, packages/parcel-transformer-lit-css/test/expected/*
New test that packs the transformer, runs Parcel builds for fixtures, normalizes produced bundles for assertions; adds expected JS outputs for multiple fixture scenarios.
Test utilities & mocks
test/test.js, test/mock-packages/*, test/mock-packages/README.md
test/test.js gains optional skip parameter to gate SCSS/PostCSS tests; add snoot mock package (module + package.json) and README describing mock packages.
Dev helper script
scripts/setup-mock-packages.js
New script to symlink test/mock-packages/snoot into root node_modules during postinstall, tolerant of existing links.

Sequence Diagram(s)

sequenceDiagram
    participant Parcel as Parcel
    participant Transformer as parcel-transformer-lit-css
    participant Lib as `@pwrs/lit-css`
    participant Asset as CSS Asset

    rect rgb(230,245,255)
    Parcel->>Transformer: loadConfig({ config })
    Transformer-->>Parcel: return package "lit-css" config (if present)
    end

    rect rgb(245,255,230)
    Parcel->>Transformer: transform({ asset, config })
    Transformer->>Asset: asset.getCode()
    Asset-->>Transformer: CSS content
    Transformer->>Lib: transform({ css, filePath, options })
    Lib-->>Transformer: JS module code (lit `css` template)
    Transformer->>Asset: asset.setCode(transformed JS)
    Transformer->>Asset: asset.type = "js"
    Transformer-->>Parcel: return [updated asset]
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

  • Review focus:
    • packages/parcel-transformer-lit-css/parcel-transformer-lit-css.ts — Parcel API usage, config loading, error handling, options merging.
    • packages/parcel-transformer-lit-css/package.json — exports/engines/peerDependencies and publish settings.
    • packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js — test environment setup, tarball packaging and bundle normalization.
    • test/test.js & scripts/setup-mock-packages.js — skip gating semantics and symlink robustness.

Poem

🐇
I hop through parcels, css in paw,
Tagging styles with litty law.
Bundles hum and tests applaud,
Tiny hops, a tidy mod.
Hoppity hop — the transformer’s awed!

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(parcel): add Parcel support' clearly summarizes the main change—introducing Parcel support to the project.
Linked Issues check ✅ Passed The PR implements Parcel support by introducing a parcel-transformer-lit-css package with configuration examples and integration tests, fully addressing issue #44's request for Parcel support and configuration guidance.
Out of Scope Changes check ✅ Passed All changes directly support the core objective of adding Parcel support, including the transformer package, integration tests, mock packages for testing, and documentation.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/parcel

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27640e8 and a154823.

📒 Files selected for processing (1)
  • scripts/setup-mock-packages.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/setup-mock-packages.js

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
packages/parcel-transformer-lit-css/README.md (1)

95-111: Update Sass example to use modern API.

The preprocessor example uses the deprecated Sass.render() callback-based API. Modern versions of the Sass package use compile() or compileString() instead.

Apply this diff to update the example:

 // custom-transform.js
-import Sass from 'sass';
+import * as sass from 'sass';
 
 export default async function sassTransform(css, { filePath }) {
-  return new Promise((resolve, reject) => {
-    Sass.render({ data: css, file: filePath }, (err, result) => {
-      if (err) reject(err);
-      else resolve(result.css.toString());
-    });
-  });
+  try {
+    const result = sass.compileString(css, { url: new URL(`file://${filePath}`) });
+    return result.css;
+  } catch (err) {
+    throw err;
+  }
 }
packages/parcel-transformer-lit-css/parcel-transformer-lit-css.ts (2)

14-23: Consider adding runtime validation for config.

The type assertion (config as LitCSSOptions) bypasses type safety. While the transform function will handle invalid options gracefully, explicit validation would provide clearer error messages if the configuration is malformed.


29-30: Preserve the original error stack trace.

Creating a new Error discards the original stack trace, making debugging harder. Consider re-throwing the error directly or using the cause option.

Apply this diff to preserve the stack trace:

-    } catch (error: any) {
-      throw new Error(error?.message ?? String(error));
-    }
+    } catch (error: any) {
+      throw error instanceof Error ? error : new Error(String(error));
+    }
packages/parcel-transformer-lit-css/package.json (1)

8-10: Consider adding TypeScript types to exports map.

While the top-level types field works, modern TypeScript resolves types better when they're included in the exports map alongside the import/require entries.

Example enhancement:

 "exports": {
-  "import": "./parcel-transformer-lit-css.js",
-  "require": "./parcel-transformer-lit-css.cjs"
+  "import": {
+    "types": "./parcel-transformer-lit-css.d.ts",
+    "default": "./parcel-transformer-lit-css.js"
+  },
+  "require": {
+    "types": "./parcel-transformer-lit-css.d.ts",
+    "default": "./parcel-transformer-lit-css.cjs"
+  }
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c69d07 and e4e56b4.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • packages/parcel-transformer-lit-css/integration-test/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (24)
  • .changeset/sad-boats-tan.md (1 hunks)
  • .eslintignore (1 hunks)
  • .gitignore (1 hunks)
  • README.md (1 hunks)
  • package.json (1 hunks)
  • packages/parcel-transformer-lit-css/.gitignore (1 hunks)
  • packages/parcel-transformer-lit-css/README.md (1 hunks)
  • packages/parcel-transformer-lit-css/integration-test/.parcelrc (1 hunks)
  • packages/parcel-transformer-lit-css/integration-test/README.md (1 hunks)
  • packages/parcel-transformer-lit-css/integration-test/package.json (1 hunks)
  • packages/parcel-transformer-lit-css/integration-test/src/index.html (1 hunks)
  • packages/parcel-transformer-lit-css/integration-test/src/my-element.js (1 hunks)
  • packages/parcel-transformer-lit-css/integration-test/src/styles.css (1 hunks)
  • packages/parcel-transformer-lit-css/package.json (1 hunks)
  • packages/parcel-transformer-lit-css/parcel-transformer-lit-css.ts (1 hunks)
  • packages/parcel-transformer-lit-css/test/expected/bare/output.js (1 hunks)
  • packages/parcel-transformer-lit-css/test/expected/basic/boop.js (1 hunks)
  • packages/parcel-transformer-lit-css/test/expected/basic/fast.js (1 hunks)
  • packages/parcel-transformer-lit-css/test/expected/basic/output.js (1 hunks)
  • packages/parcel-transformer-lit-css/test/expected/basic/uglified.js (1 hunks)
  • packages/parcel-transformer-lit-css/test/expected/postcss/output.js (1 hunks)
  • packages/parcel-transformer-lit-css/test/expected/scss/output.js (1 hunks)
  • packages/parcel-transformer-lit-css/test/expected/special-chars/output.js (1 hunks)
  • packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-03T06:29:44.714Z
Learnt from: bennypowers
Repo: bennypowers/lit-css PR: 70
File: packages/vite-plugin-lit-css/integration-test/src/my-element.js:5-5
Timestamp: 2025-11-03T06:29:44.714Z
Learning: In the bennypowers/lit-css repository, the .eslintignore file contains the pattern "packages/*/integration-test/**/*.js" which correctly excludes integration test files from linting, so ESLint parsing errors should not occur for files in integration-test directories.

Applied to files:

  • packages/parcel-transformer-lit-css/integration-test/package.json
  • packages/parcel-transformer-lit-css/integration-test/src/styles.css
  • packages/parcel-transformer-lit-css/.gitignore
  • .eslintignore
  • packages/parcel-transformer-lit-css/integration-test/README.md
  • .gitignore
  • packages/parcel-transformer-lit-css/integration-test/src/index.html
  • packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js
  • README.md
  • packages/parcel-transformer-lit-css/integration-test/.parcelrc
🧬 Code graph analysis (10)
packages/parcel-transformer-lit-css/test/expected/basic/uglified.js (5)
packages/parcel-transformer-lit-css/test/expected/bare/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/fast.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/postcss/output.js (1)
  • styles (2-2)
packages/parcel-transformer-lit-css/test/expected/scss/output.js (1)
  • styles (2-2)
packages/parcel-transformer-lit-css/integration-test/src/my-element.js (2)
packages/parcel-transformer-lit-css/test/expected/bare/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/special-chars/output.js (2)
packages/parcel-transformer-lit-css/test/expected/bare/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/boop.js (7)
packages/parcel-transformer-lit-css/test/expected/bare/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/fast.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/uglified.js (1)
  • styles (2-2)
packages/parcel-transformer-lit-css/test/expected/postcss/output.js (1)
  • styles (2-2)
packages/parcel-transformer-lit-css/test/expected/scss/output.js (1)
  • styles (2-2)
packages/parcel-transformer-lit-css/test/expected/special-chars/output.js (1)
  • styles (2-8)
packages/parcel-transformer-lit-css/test/expected/bare/output.js (2)
packages/parcel-transformer-lit-css/test/expected/basic/fast.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/postcss/output.js (2)
packages/parcel-transformer-lit-css/test/expected/basic/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/uglified.js (1)
  • styles (2-2)
packages/parcel-transformer-lit-css/test/expected/basic/fast.js (3)
packages/parcel-transformer-lit-css/test/expected/bare/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/uglified.js (1)
  • styles (2-2)
packages/parcel-transformer-lit-css/test/expected/basic/output.js (3)
packages/parcel-transformer-lit-css/test/expected/bare/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/boop.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/fast.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (1)
test/test.js (1)
  • run (24-108)
packages/parcel-transformer-lit-css/test/expected/scss/output.js (2)
packages/parcel-transformer-lit-css/test/expected/bare/output.js (1)
  • styles (2-5)
packages/parcel-transformer-lit-css/test/expected/basic/uglified.js (1)
  • styles (2-2)
🪛 LanguageTool
packages/parcel-transformer-lit-css/integration-test/README.md

[grammar] ~51-~51: Ensure spelling is correct
Context: ...onent's static styles property 4. The hotpink color is applied to the h1 element You...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (25)
packages/parcel-transformer-lit-css/.gitignore (1)

1-1: LGTM!

Appropriately ignores tarball artifacts generated by npm pack for local testing workflows.

.eslintignore (1)

3-3: LGTM!

Correctly excludes integration test JavaScript files from linting, consistent with the repository's approach to generated and test fixture code.

packages/parcel-transformer-lit-css/test/expected/basic/fast.js (1)

1-9: LGTM!

Test fixture correctly demonstrates the expected output format for @microsoft/fast-element CSS transformations, with both default and named exports.

.gitignore (1)

115-115: LGTM!

Appropriately excludes Parcel's cache directory from version control, consistent with other build tool caches in this file.

packages/parcel-transformer-lit-css/integration-test/README.md (1)

1-125: LGTM!

Comprehensive integration test documentation that clearly explains the purpose, setup steps, and verification process. The instructions for both build and dev modes are well-structured and helpful.

packages/parcel-transformer-lit-css/test/expected/bare/output.js (1)

1-9: LGTM!

Test fixture correctly demonstrates the expected output format for lit CSS transformations, maintaining consistency with other test expectations.

package.json (1)

36-38: Parcel dependencies verified as current and secure.

The versions @parcel/core, @parcel/config-default, and @parcel/plugin at 2.16.0 are the latest available and have no known published vulnerabilities. A historical Origin Validation Error (CVE-2025-56648) affected older Parcel dev-server packages up through 2.14.4 and was fixed in later releases. The caret range specified (^2.16.0) is appropriate and safe.

packages/parcel-transformer-lit-css/parcel-transformer-lit-css.ts (1)

9-12: LGTM!

The configuration loading logic correctly uses optional chaining to safely access the lit-css configuration from package.json.

packages/parcel-transformer-lit-css/integration-test/src/styles.css (1)

1-9: LGTM!

The CSS file provides a clear test case for the transformer with both :host and element selectors.

packages/parcel-transformer-lit-css/integration-test/.parcelrc (1)

1-6: LGTM!

The Parcel configuration correctly extends the default config and registers the transformer for CSS files.

README.md (1)

30-30: LGTM!

The Parcel documentation entry is correctly positioned and formatted consistently with the existing plugin list.

packages/parcel-transformer-lit-css/test/expected/basic/uglified.js (1)

1-6: LGTM!

The expected output correctly demonstrates the transformer's handling of minified CSS with proper export patterns.

packages/parcel-transformer-lit-css/integration-test/src/index.html (1)

1-16: LGTM!

The integration test HTML is well-structured and correctly loads the module script to test the custom element with transformed CSS.

packages/parcel-transformer-lit-css/test/expected/basic/output.js (1)

1-9: LGTM!

The expected output correctly demonstrates the transformer's handling of formatted CSS with the proper dual export pattern.

packages/parcel-transformer-lit-css/integration-test/package.json (1)

15-15: Integration test is a documented manual prerequisite, not a build process requirement.

The verification shows that tarball generation is not configured in the build process or CI/CD workflows. However, this is intentional. The integration test README documents this as a manual prerequisite: "Before running the integration test, you need to pack the transformer package: cd .. # Go to parcel-transformer-lit-css directory; npm pack".

The root test script only runs automated tape tests, not integration tests. The CI/CD workflows (pull-request.yml and release.yml) both execute npm test, which does not include integration tests. The integration test is designed as a manual verification step for developers, not part of the automated build pipeline.

Likely an incorrect or invalid review comment.

.changeset/sad-boats-tan.md (1)

1-14: LGTM! Clear and comprehensive changeset documentation.

The changeset clearly describes the new Parcel transformer package and its features.

packages/parcel-transformer-lit-css/integration-test/src/my-element.js (1)

1-15: LGTM! Clean integration test component.

This Lit element correctly demonstrates the expected usage pattern for the transformer: importing a CSS file and assigning it to the static styles property.

packages/parcel-transformer-lit-css/test/expected/basic/boop.js (1)

1-9: LGTM! Test fixture for custom specifier/tag options.

This fixture correctly tests the transformer's ability to use custom specifier and tag names (importing boop from snoot instead of the default css from lit).

packages/parcel-transformer-lit-css/test/expected/special-chars/output.js (1)

1-12: LGTM! Test fixture validates special character handling.

This fixture appropriately tests that the transformer preserves special characters (emoji) and CSS directives (@import) within the transformed output.

packages/parcel-transformer-lit-css/test/expected/scss/output.js (1)

1-6: LGTM! Test fixture for SCSS transformation.

This fixture correctly represents the expected output when transforming SCSS with minification enabled.

packages/parcel-transformer-lit-css/test/expected/postcss/output.js (1)

1-6: LGTM! Test fixture for PostCSS transformation.

This fixture correctly represents the expected output when transforming CSS through PostCSS with minification.

packages/parcel-transformer-lit-css/package.json (1)

36-41: LGTM! Correct dependency structure.

The dependency configuration is correct: @parcel/plugin as a peer dependency (provided by Parcel runtime) and @pwrs/lit-css as a regular dependency.

packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (3)

13-49: LGTM! Comprehensive test environment setup.

The test correctly creates an isolated environment with symlinking to the root node_modules for dependency access, and copies the transformer source for local resolution by Parcel. This is a standard pattern for testing build plugins.


51-82: LGTM! Well-configured Parcel build for testing.

The build configuration is appropriate: production mode with optimization disabled keeps output readable for test assertions, scopeHoist enables proper ES module output, and comprehensive error handling logs diagnostics for debugging.


84-102: LGTM! Robust bundle extraction and cleanup.

The code defensively checks for empty bundles, finds the appropriate JS bundle, and ensures cleanup happens in the finally block even if errors occur.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (1)

86-104: Minor formatting and bundle selection notes.

The cleanup logic is solid with proper use of the finally block. Two minor observations:

  • Line 92: Empty line could be removed
  • Line 94: Bundle selection uses find for JS bundles with fallback—this is adequate for the test cases but could be more explicit with a comment explaining the fallback scenario

Apply this diff to remove the empty line:

   if (bundles.length === 0)
     throw new Error('No bundles found in build output');
-

   // Get the main bundle
packages/parcel-transformer-lit-css/parcel-transformer-lit-css.ts (1)

29-31: Consider preserving the original error stack trace.

Creating a new Error object loses the stack trace from the original error, making debugging more difficult. Consider re-throwing the original error when possible.

Apply this diff to preserve stack traces:

-    } catch (error) {
-      throw new Error(error?.message ?? String(error));
-    }
+    } catch (error) {
+      throw error instanceof Error ? error : new Error(String(error));
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4e56b4 and 0140cee.

📒 Files selected for processing (2)
  • packages/parcel-transformer-lit-css/parcel-transformer-lit-css.ts (1 hunks)
  • packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: bennypowers
Repo: bennypowers/lit-css PR: 70
File: packages/vite-plugin-lit-css/integration-test/src/my-element.js:5-5
Timestamp: 2025-11-03T06:29:44.714Z
Learning: In the bennypowers/lit-css repository, the .eslintignore file contains the pattern "packages/*/integration-test/**/*.js" which correctly excludes integration test files from linting, so ESLint parsing errors should not occur for files in integration-test directories.
📚 Learning: 2025-11-03T06:29:44.714Z
Learnt from: bennypowers
Repo: bennypowers/lit-css PR: 70
File: packages/vite-plugin-lit-css/integration-test/src/my-element.js:5-5
Timestamp: 2025-11-03T06:29:44.714Z
Learning: In the bennypowers/lit-css repository, the .eslintignore file contains the pattern "packages/*/integration-test/**/*.js" which correctly excludes integration test files from linting, so ESLint parsing errors should not occur for files in integration-test directories.

Applied to files:

  • packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js
🧬 Code graph analysis (1)
packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (1)
test/test.js (1)
  • run (24-108)
🔇 Additional comments (6)
packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (3)

1-12: LGTM! Well-structured imports and setup.

The imports are appropriate for the Parcel integration test, and the shared fixtures directory reference maintains consistency with the project structure.


53-84: Excellent Parcel configuration and error handling.

The bundler configuration is well-suited for testing with optimize: false to maintain readable output for assertions, and the comprehensive error handling with diagnostic logging will make debugging transformer issues much easier.


22-25: The original review comment is based on an incorrect assumption.

CI/CD only uses ubuntu-latest (Linux)—no Windows runners are configured. The symlink approach in the test is appropriate for the Linux-only testing environment. Windows portability is not a blocking concern for this codebase.

Likely an incorrect or invalid review comment.

packages/parcel-transformer-lit-css/parcel-transformer-lit-css.ts (3)

1-6: LGTM!

The imports are appropriate and the LitCSSOptions type correctly omits the css property since it will be provided by reading the asset content.


9-12: LGTM!

The configuration loading correctly reads from package.json and safely accesses the lit-css configuration using optional chaining.


14-28: The transform function returns only a code string; verify if dependency tracking is necessary for this transformer's use case.

The transform() function in the local @pwrs/lit-css package (packages/lit-css/lit-css.ts) returns Promise<string> containing only the transformed code—it does not return an object with dependency information. Therefore, the assumption that dependency info is being ignored is incorrect.

However, the underlying concern about CSS imports remains valid if:

  • CSS files can have @import statements that aren't resolved by the optional preprocessor
  • Parcel's CSS handler doesn't already track these imports before this transformer runs

To resolve this, verify that CSS files with @import statements are properly tracked by Parcel's built-in CSS handling, or test with a CSS file containing @import to confirm hot reloading and cache invalidation work correctly.

The suggestion about source maps is still worth considering for improved debugging of CSS-to-JS transformations.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0140cee and 0edc653.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • package.json (1 hunks)
  • packages/parcel-transformer-lit-css/README.md (1 hunks)
  • packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (1 hunks)
  • test/mock-packages/README.md (1 hunks)
  • test/mock-packages/snoot/index.js (1 hunks)
  • test/mock-packages/snoot/package.json (1 hunks)
  • test/test.js (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • test/mock-packages/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: bennypowers
Repo: bennypowers/lit-css PR: 70
File: packages/vite-plugin-lit-css/integration-test/src/my-element.js:5-5
Timestamp: 2025-11-03T06:29:44.714Z
Learning: In the bennypowers/lit-css repository, the .eslintignore file contains the pattern "packages/*/integration-test/**/*.js" which correctly excludes integration test files from linting, so ESLint parsing errors should not occur for files in integration-test directories.
📚 Learning: 2025-11-03T06:29:44.714Z
Learnt from: bennypowers
Repo: bennypowers/lit-css PR: 70
File: packages/vite-plugin-lit-css/integration-test/src/my-element.js:5-5
Timestamp: 2025-11-03T06:29:44.714Z
Learning: In the bennypowers/lit-css repository, the .eslintignore file contains the pattern "packages/*/integration-test/**/*.js" which correctly excludes integration test files from linting, so ESLint parsing errors should not occur for files in integration-test directories.

Applied to files:

  • packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js
  • test/test.js
🧬 Code graph analysis (2)
packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (1)
test/test.js (1)
  • run (24-114)
test/test.js (1)
packages/typescript-transform-lit-css/test/typescript-transform-lit-css.test.js (2)
  • getCode (18-19)
  • read (15-16)
🪛 GitHub Actions: Verify PR
packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js

[warning] 5-5: eslint: 'mkdir' is defined but never used. (no-unused-vars) | Command: npm run lint


[error] 29-29: eslint: Use array destructuring. (prefer-destructuring) | Command: npm run lint

🪛 GitHub Check: verify
packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js

[failure] 183-183:
'originalCwd' is not defined


[failure] 176-176:
Unnecessary catch clause


[failure] 170-170:
Use array destructuring


[failure] 157-157:
Split 'let' declarations into multiple statements


[warning] 156-156:
'tag' is assigned a value but never used


[failure] 156-156:
Use array destructuring


[failure] 155-155:
Use array destructuring


[failure] 146-146:
'||' should be placed at the end of the line


[failure] 82-82:
Multiple spaces found before '// Now relativ...'


[warning] 78-78:
'originalCwd' is assigned a value but never used


[failure] 63-63:
Missing trailing comma


[warning] 35-35:
'input' is assigned a value but never used


[failure] 29-29:
Use array destructuring


[warning] 5-5:
'mkdir' is defined but never used

test/mock-packages/snoot/index.js

[warning] 2-2:
'values' is defined but never used

🔇 Additional comments (6)
test/mock-packages/snoot/package.json (1)

1-6: LGTM! Clean mock package manifest.

The package.json correctly defines a test fixture with ESM module support, which aligns with the test requirements for custom specifier/tag combinations.

test/mock-packages/snoot/index.js (1)

1-4: LGTM! Correct signature for tagged template literal.

The values parameter is intentionally unused because this is a mock function for testing custom tag behavior. Tagged template literal functions require the (strings, ...values) signature even when the implementation doesn't need the interpolated values.

test/test.js (2)

24-24: Good addition of skip parameter.

The optional skip array enables selective test execution, which is necessary for different bundler implementations that handle preprocessing differently.


64-110: Well-structured conditional test execution.

The skip guards for scss-transform, scss-error, and postcss-transform tests are correctly implemented. This allows Parcel to use its own transformer chain while other bundlers can still use the transform callbacks.

packages/parcel-transformer-lit-css/README.md (1)

1-116: Excellent documentation.

The README is comprehensive and well-organized, covering all essential aspects:

  • Clear installation and setup instructions
  • Practical usage examples
  • Configuration options with defaults
  • Input/output example for clarity
  • Preprocessor integration guidance

This addresses the issue #44 requirement for sample configuration.

packages/parcel-transformer-lit-css/test/parcel-transformer-lit-css.test.js (1)

14-189: Solid integration test approach.

The test runner correctly:

  • Creates an isolated environment with symlinked dependencies
  • Configures Parcel with the custom transformer
  • Handles different specifier/tag combinations
  • Extracts and normalizes output for comparison
  • Skips transform callback tests (using Parcel's transformer chain instead)

The CSS extraction logic intelligently handles Parcel's bundling patterns to verify the transformation.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
scripts/setup-mock-packages.js (2)

11-21: Validate target directory exists before creating symlink.

The script creates a symlink without verifying that the target directory exists. If test/mock-packages/snoot is missing, a broken symlink will be created, leading to confusing errors when tests attempt to use the mock package.

Apply this diff to validate the target before symlinking:

 if (!existsSync(link)) {
+  if (!existsSync(target)) {
+    console.error('✗ Mock package directory does not exist:', target);
+    process.exit(1);
+  }
   try {
     symlinkSync(target, link, 'dir');

11-21: Consider cross-platform symlink limitations.

Directory symlinks on Windows typically require administrator privileges. While the error handling allows the script to continue with a warning, developers on Windows without elevated privileges may encounter issues. Consider documenting this requirement or exploring alternatives like junction points ('junction' type) which don't require admin rights on Windows.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e625c6 and 27640e8.

📒 Files selected for processing (2)
  • package.json (2 hunks)
  • scripts/setup-mock-packages.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: bennypowers
Repo: bennypowers/lit-css PR: 70
File: packages/vite-plugin-lit-css/integration-test/src/my-element.js:5-5
Timestamp: 2025-11-03T06:29:44.714Z
Learning: In the bennypowers/lit-css repository, the .eslintignore file contains the pattern "packages/*/integration-test/**/*.js" which correctly excludes integration test files from linting, so ESLint parsing errors should not occur for files in integration-test directories.
🪛 GitHub Actions: Verify PR
scripts/setup-mock-packages.js

[error] 14-14: ESLint: Unexpected console statement. (no-console)

🪛 GitHub Check: verify
scripts/setup-mock-packages.js

[failure] 18-18:
Unexpected console statement


[failure] 17-17:
Unnecessary { after 'if' condition


[failure] 14-14:
Unexpected console statement

@bennypowers
Copy link
Owner Author

@mediabuff, can you try this out?

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.

any support for Parcel ? S ample package.json configuration would be appreciated

2 participants