Skip to content

feat(parcel): add Parcel transformer plugin - #1995

Draft
JoshKappler wants to merge 5 commits into
mainfrom
feat/parcel-transformer
Draft

feat(parcel): add Parcel transformer plugin#1995
JoshKappler wants to merge 5 commits into
mainfrom
feat/parcel-transformer

Conversation

@JoshKappler

@JoshKappler JoshKappler commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Testing

  • Transformer unit tests ship in the diff. Nothing run locally; CI and Greptile review this PR.

Notes

  • Changeset is patch.
  • Lockfile regen let next move 16.2.11 to 16.2.12 (minimumReleaseAge window); rest of the churn is Parcel's own tree.
  • README points at examples/parcel-spa, which lands in the stacked PR.
  • No Linear issue yet.

Greptile Summary

This PR introduces @generaltranslation/parcel-transformer, a new Parcel 2 plugin that runs the General Translation compiler at build time. Since Parcel is not covered by unplugin, the package wraps the same @generaltranslation/compiler core used by the Vite, webpack, and Rollup adapters.

  • Two-pass transform: Babel first lowers TSX/JSX to the automatic JSX runtime (preserving ES module imports), then the GT compiler injects _hash values into <T> elements and t() calls — matching the behavior of the other bundler adapters exactly.
  • Pre-gate efficiency: A cheap regex (GT_SIGNAL_RE) skips the Babel lowering pass for files with no GT usage. The <T[\\s>\\/] boundary (addressed in prior review) correctly avoids false positives for <Typography>, <Table>, etc.
  • Config lifecycle: gt.config.json is loaded via config.getConfig so Parcel registers it as a dependency and invalidates transformed assets on change; the resolved plugin is memoized per options signature to avoid redundant disk reads across files.

Confidence Score: 5/5

Safe to merge — this is a self-contained new package with no changes to existing code paths.

The transformer is a new, isolated package. The two-pass Babel+GT flow is well-guarded: the pre-gate regex skips inert files cheaply, Babel failures are caught and passed through, and the GT compiler returning null correctly leaves the original source untouched for Parcel's default pipeline. The prior false-positive concern about the <T regex boundary has been fixed and is covered by tests.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
packages/parcel-transformer/src/index.ts Core transformer: two-pass Babel+GT transform with pre-gate regex, config caching, and correct passthrough when GT compiler returns null.
packages/parcel-transformer/src/tests/transform.test.ts Comprehensive tests covering JSX lowering, hash injection, cross-adapter parity, decorator handling, pre-gate signal matching with false-positive cases, and Parcel default export shape.
packages/parcel-transformer/package.json Well-formed package manifest with correct ESM-only exports, Parcel engine constraint, and all required Babel peer dependencies declared.
packages/parcel-transformer/tsdown.config.mts ESM-only build config; source maps intentionally omitted with documented rationale.
packages/parcel-transformer/tsconfig.json Standard tsconfig extending the repo base; test files correctly excluded from type-checking compilation.
packages/parcel-transformer/vitest.config.ts Minimal vitest config targeting Node environment, consistent with other packages in the monorepo.
.changeset/add-parcel-transformer.md Patch changeset for a new package at 0.0.0; appropriate for an initial release.

Reviews (3): Last reviewed commit: "chore: trim comments to the 3-line house..." | Re-trigger Greptile

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
generaltranslation 18.03 KB (0%)
generaltranslation/runtime 14.93 KB (0%)
generaltranslation/id 2.55 KB (0%)
generaltranslation/internal 7.38 KB (0%)
generaltranslation/types 89 B (0%)
generaltranslation/errors 81 B (0%)
@generaltranslation/format 9.5 KB (0%)
@generaltranslation/format/types 89 B (0%)
@generaltranslation/format/internal 880 B (0%)
gt-i18n 11.91 KB (0%)
gt-i18n/types 13 B (0%)
gt-i18n/internal 22.46 KB (0%)
gt-i18n/internal/types 13 B (0%)
@generaltranslation/react-core/pure 25.59 KB (0%)
@generaltranslation/react-core/hooks 20.61 KB (0%)
@generaltranslation/react-core/components 22.81 KB (0%)
@generaltranslation/react-core/components-rsc 26.16 KB (0%)
gt-react (client) 32.02 KB (0%)
gt-react (rsc) 28.67 KB (0%)
gt-react (server) 31.65 KB (0%)
gt-react/macros 8.86 KB (0%)
gt-next (client) 43.74 KB (0%)
gt-next (rsc) 47.52 KB (0%)
gt-next (server) 43.69 KB (0%)
gt-next/config 269.75 KB (0%)
gt-next/server 46.06 KB (0%)
gt-next/middleware 36.39 KB (0%)
gt-next/link 42.59 KB (0%)
gt-next/internal/_dictionary 144 B (0%)
gt-next/internal/_load-translations 144 B (0%)
gt-next/internal/_load-dictionary 144 B (0%)
gt-next/internal/_getLocale 125 B (0%)
gt-next/internal/_getRegion 122 B (0%)
gt-node 23.54 KB (0%)
gt-node/types 219 B (0%)
gt-node/internal 13.47 KB (0%)
gt-tanstack-start (client) 31.58 KB (0%)
gt-tanstack-start (server) 32.06 KB (0%)
gt-tanstack-start/server 10.27 KB (0%)
gt-react-native 30.05 KB (0%)
gt-react-native/plugin 4.62 KB (0%)
gt-react-native/internal 746 B (0%)

@JoshKappler

Copy link
Copy Markdown
Contributor Author

@greptileai review

Comment thread packages/parcel-transformer/src/index.ts
Comment thread packages/parcel-transformer/src/__tests__/transform.test.ts
@JoshKappler

Copy link
Copy Markdown
Contributor Author

@greptileai review

@JoshKappler

Copy link
Copy Markdown
Contributor Author

@greptileai review

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