Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/source-names-locations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/vite-plugin": patch
---

`sourceNames` gains a `locations` kind: a `file:line:col` next to every component, binding and primitive label — `createComponent(Home, props, "Home", "src/App.tsx:12:5")`, `createSignal(0, { name: "count", loc: "src/store.ts:3:22" })` — so diagnostics, `whyDidRun` chains and devtools point at the line that declared the node. On in dev; off for `observe` and production builds unless set (`{ locations: true }` or `sourceNames: true`), since those are shipped bundles. The plugin passes the resolved Vite root to both JSX compilers and to the primitives pass as `root`, so paths are root-relative and `http://localhost:5173/<path>` opens the file in the browser's sources panel. Requires the `@solidjs/compiler` release that takes the option; the plugin probes the installed compiler and, on an older one, keeps passing the names without locations (warning once when `locations` was asked for explicitly).
3 changes: 3 additions & 0 deletions .github/workflows/vitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Install project dependencies
run: pnpm i

- name: Run unit tests
run: pnpm run test:unit

- name: Install playwright browser
working-directory: examples/${{ matrix.example }}
run: pnpm exec playwright install chromium
Expand Down
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,9 @@ here is merged over them and applied to whichever backend is selected.

##### options.solid.sourceNames

- Type: `boolean | { components?: boolean; bindings?: boolean; primitives?: boolean }`
- Default: on in dev and under `observe`, off in production builds
- Type:
`boolean | { components?: boolean; bindings?: boolean; primitives?: boolean; locations?: boolean }`
- Default: on in dev and under `observe`, off in production builds; `locations` on in dev only

Which names as written in source are carried into output so the dev and observe runtimes
can label the reactive graph after minification — in diagnostics, `whyDidRun` chains, error
Expand All @@ -1024,6 +1025,13 @@ owner paths, and the Chrome performance tracks. Three kinds:
are declared as (`count`, `doubled`, `todos.title`), prefixed with the enclosing
non-component function for composed primitives (`createCounter.value`). An explicit
`name` option is never overridden.
- `locations` adds a `file:line:col` next to every name the other kinds emit —
`createComponent(Home, props, "Home", "src/App.tsx:12:5")`,
`createSignal(0, { name: "count", loc: "src/store.ts:3:22" })` — so a diagnostic report, a
`whyDidRun` chain, or a devtools entry points at the line that declared the node. Paths are
relative to the Vite root, so under `vite dev` the console's
`http://localhost:5173/src/App.tsx:12:5` opens the file in the browser's sources panel. A
location is only emitted where its name is.

The kinds come from two different places. `components` and `bindings` are the JSX compiler's
own `sourceNames` option, passed through to whichever backend compiles your JSX
Expand All @@ -1036,10 +1044,23 @@ too.
The default follows the posture: on whenever the plugin compiles for the dev runtime (the
same `dev` flag it hands the compilers — `vite dev`, or `dev: true`) and for `observe`
builds; off for production builds, whose runtime ignores the names anyway, so production
output is unchanged. `sourceNames: false` turns every kind off, in dev too; `true` turns every
kind on, production builds included. The object form sets the listed kinds and leaves the
rest at the posture default — `{ primitives: false }` keeps component and binding names in
dev but skips the primitives pass.
output is unchanged. `locations` is the one kind that does not follow `observe`: an observe
build is a production bundle, and a source path inside it is an opt-in, so it is on in dev
only. `sourceNames: false` turns every kind off, in dev too; `true` turns every kind on,
production builds included. The object form sets the listed kinds and leaves the rest at the
posture default — `{ primitives: false }` keeps component and binding names in dev but skips
the primitives pass; `{ locations: true }` ships locations in an observe build.

| `sourceNames` | dev | `observe` build | production build |
| ---------------------- | ---------------------- | ---------------------------- | --------------------------- |
| (unset) | all on | names on, `locations` off | all off |
| `true` | all on | all on | all on |
| `false` | all off | all off | all off |
| `{ kind: true/false }` | as given; the rest on | as given; the rest as unset | as given; the rest off |

`locations` needs a compiler release that takes the option; on an older `@solidjs/compiler`
the names keep coming without locations, with a one-time warning when it was asked for
explicitly.

#### options.typescript

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"prepublishOnly": "pnpm build",
"release": "pnpm build && changeset publish",
"check": "package-check",
"test": "node scripts/test-examples.ts"
"test": "node scripts/test-examples.ts",
"test:unit": "vitest run"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -88,7 +89,8 @@
"rollup-plugin-cleaner": "^1.0.0",
"solid-js": "^2.0.0-rc.14",
"typescript": "^5.2.2",
"vite": "^8.2.1"
"vite": "^8.2.1",
"vitest": "^4.1.11"
},
"peerDependencies": {
"@solidjs/start-devtools": "^1.0.0-next.2",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading