Skip to content

solid: add include option to transform JSX inside node_modules - #1741

Closed
dskanakoglou wants to merge 1 commit into
anomalyco:mainfrom
dskanakoglou:solid-transform-include
Closed

dskanakoglou wants to merge 1 commit into
anomalyco:mainfrom
dskanakoglou:solid-transform-include

Conversation

@dskanakoglou

Copy link
Copy Markdown

The Solid transform skips every path that contains node_modules. OpenCode installs plugin packages (npm, git+ and github: specs) into its cache under <cache>/npm/<key>/<n>/node_modules/<pkg>/, so the JSX in those plugins is never compiled. Bun's JSX runtime evaluates {n()} once, and the plugin renders but never updates. The same folder loaded by path works. This is anomalyco/opencode#39986, whose plan puts the fix in OpenTUI.

This adds an include option, a list of directories whose .jsx/.tsx files are transformed even though their paths contain node_modules. createSolidTransformPlugin, ensureSolidTransformPlugin and ensureRuntimePluginSupport all accept it. A host passes its install directory:

ensureRuntimePluginSupport({ include: [path.join(cacheDir, "npm")], ... })

Only JSX files match. Plain modules in node_modules already get the runtime specifier rewrites, and transforming every dependency would be slow. Nothing is bundled, so plugin modules load normally and import.meta.url keeps pointing at the installed file.

Bun fixes plugin filters when a plugin is registered, so when the transform is already installed, ensureSolidTransformPlugin registers one extra plugin for directories it has not seen. That extra plugin only transforms sources; it does not add the solid-js server-build redirects a second time.

Tests:

  • a unit test for the filters the option registers
  • a subprocess test that loads a .tsx component from a directory under node_modules via ensureRuntimePluginSupport({ include }), changes a signal, and checks that the rendered frame updates

bun test in packages/solid passes (300), and oxlint and oxfmt --check are clean.

Refs anomalyco/opencode#39986

The Solid transform skips every path containing node_modules. Hosts
that install plugin packages into their own cache (for example
OpenCode's npm cache) need those packages' JSX compiled too, or it runs
once and never updates. `include` lists such directories; it is also
accepted by ensureSolidTransformPlugin and ensureRuntimePluginSupport,
which register an extra plugin when the transform is already installed.
@dskanakoglou

Copy link
Copy Markdown
Author

The OpenCode side is now confirmed: anomalyco/opencode#39986 was reproduced on 2.2.0 and current dev (labelled reproduced). Could a maintainer approve the CI workflows for this PR? Happy to adjust the approach if you'd prefer a different shape for the option.

@simonklee

Copy link
Copy Markdown
Member

Thanks. We'd rather decide how external TSX is compiled ourselves, so I'm closing this.

@simonklee simonklee closed this Nov 10, 2026
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