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
340 changes: 129 additions & 211 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,35 @@
"@babel/core": "^7.24.4",
"@babel/preset-env": "^7.24.4",
"@babel/preset-typescript": "^7.23.3",
"@nativescript-community/solid-js": "^0.1.2",
"@nativescript-community/react": "^19.0.0",
"@nativescript-community/solid-js": "^2.0.1",
"@nativescript-dom/core-types": "1.0.32",
"@nativescript-dom/solidjs-types": "1.0.25",
"@nativescript/angular": "^19.0.0",
"@nativescript/core": "~9.0.0",
"@nativescript/core": "~9.1.4",
"@nativescript/plugin-tools": "5.5.3",
"@nativescript/tailwind": "~2.1.0",
"@nativescript/types": "~9.0.0",
"@nativescript/webpack": "~5.0.31",
"@ngtools/webpack": "^19.0.0",
"@tanstack/history": "^1.161.6",
"@tanstack/router-core": "^1.169.1",
"@tanstack/solid-router": "^1.169.1",
"@tanstack/react-router": "^1.169.1",
"@solidjs/universal": "^2.0.3",
"@solidjs/web": "^2.0.3",
"@tanstack/history": "1.162.5",
"@tanstack/react-router": "^1.170.46",
"@tanstack/router-core": "1.171.39",
"@tanstack/solid-router": "2.0.0-rc.12",
"@triniwiz/nativescript-image-cache-it": "^8.0.1",
"@types/react": "^19.0.0",
"react": "^19.0.0",
"react-reconciler": "^0.32.0",
"babel-loader": "^9.1.3",
"babel-preset-solid": "^1.8.19",
"dominative": "^0.1.3",
"husky": "~9.0.0",
"jsdom": "^29.1.1",
"ng-packagr": "^19.0.0",
"react": "^19.0.0",
"react-reconciler": "^0.32.0",
"rxjs": "~7.8.0",
"sass": "1.53.0",
"solid-js": "^1.9.11",
"solid-refresh": "^0.7.5",
"solid-js": "^2.0.3",
"tailwindcss": "~3.4.3",
"tsup": "^8.3.5",
"typescript": "~5.8.0",
Expand Down
39 changes: 39 additions & 0 deletions packages/tanstack-router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
## 0.2.1 (2026-11-23)

The 0.2.0 tarball on npm was built before the following changes landed; 0.2.1 publishes them.

### ⚠️ Breaking Changes

- `nativescript.vite.mjs` no longer registers the TanStack router plugin, and `@tanstack/router-plugin` is no longer a dependency. Apps using file-based routes add `tanstackRouter({ target: 'solid', autoCodeSplitting: false })` from `@tanstack/router-plugin/vite` to their own Vite config. With `@nativescript/vite` applying dependency plugins, shipping it here would register the plugin twice.

### 🩹 Fixes

- Modal routers no longer replace the app router registered on `globalThis.__ns_router`, so HMR keeps patching the live router after a modal opens.
- `scrollTo` is stubbed as a no-op global: router-core resets window scroll after every render and threw `ReferenceError: scrollTo is not defined` on each navigation.
- The provider's navigation signal is seeded without a top-level reactive read (no `STRICT_READ_UNTRACKED` dev warnings).

## 0.2.0 (2026-11-23)

### ⚠️ Breaking Changes

- The Solid flavor now targets Solid 2 only: `solid-js` 2.x, `@solidjs/web` 2.x, `@nativescript-community/solid-js` 2.x and `@tanstack/solid-router` 2.x (`>=2.0.0-rc.12`). Solid 1 is no longer supported.
- `NativeScriptRouterProviderProps.actionBar` and `Link`'s `children` are typed with Solid 2's `Element` instead of `JSX.Element`.
- `solid-js-jsx-runtime-shim.js` is no longer shipped; the Solid sources are compiled without JSX.
- `nativescript.vite.mjs` no longer registers the TanStack router plugin, and `@tanstack/router-plugin` is no longer a dependency. Apps using file-based routes add `tanstackRouter({ target: 'solid', autoCodeSplitting: false })` from `@tanstack/router-plugin/vite` to their own Vite config.

### 🚀 Features

- `solid-web-shim.js` now stands in for `@solidjs/web` (aliased by `nativescript.vite.mjs` and `nativescript.webpack.js`), binding the router's renderer helpers (`insert`, `spread`, `effect`, `memo`, `Dynamic`, ...) to the universal renderer of `@nativescript-community/solid-js`.
- React flavor updated to `@tanstack/react-router` 1.170 / `@tanstack/router-core` 1.171.

### 🩹 Fixes

- Pages render under `Errored` and keep their views through the native pop animation while their reactivity is torn down.
- Initial and history-driven loads run outside Solid owners, and Frame navigation runs after (not inside) the navigation effect, as Solid 2 requires.
- Modal routers no longer replace the app router registered on `globalThis.__ns_router`, so HMR keeps patching the live router after a modal opens.
- `scrollTo` is stubbed as a no-op global: router-core resets window scroll after every render and threw `ReferenceError: scrollTo is not defined` on each navigation.

### 🔧 Chores

- Drop solid-refresh proxy unwrapping from the HMR remount path; `@nativescript/vite` patches route components directly.

## 0.1.2 (2026-05-03)

### 🧪 Tests
Expand Down
30 changes: 26 additions & 4 deletions packages/tanstack-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,36 @@ The package is structured to support any framework (`react`, `vue`, `svelte`, `a
## Install

```bash
npm install @nativescript/tanstack-router @tanstack/solid-router @tanstack/history
npm install @nativescript/tanstack-router @tanstack/solid-router@^2.0.0-rc.12 @tanstack/history
```

Peer dependencies expected in the host app:
The Solid flavor targets Solid 2. Peer dependencies expected in the host app:

- `@nativescript/core`
- `@nativescript-community/solid-js`
- `solid-js`
- `@nativescript-community/solid-js` (2.x)
- `solid-js` and `@solidjs/web` (2.x)

`@tanstack/solid-router` takes its renderer helpers from `@solidjs/web`. The package's
`nativescript.vite.mjs` (picked up automatically by `@nativescript/vite`) and
`nativescript.webpack.js` alias `@solidjs/web` to a NativeScript stand-in backed by
`@nativescript-community/solid-js`, so router internals and app JSX share one renderer.

The router's built-in DOM fallbacks (default error / not-found components) cannot render
in NativeScript; supply NativeScript components through `defaultErrorComponent` /
`defaultNotFoundComponent` (or per-route `errorComponent` / `notFoundComponent`) when
you render nested routes through `<Outlet />`.

## File-Based Routes

Register the TanStack router plugin in the app's own Vite config, before the Solid plugin. It reads
`tsr.config.json` and regenerates the route tree:

```ts
import { tanstackRouter } from '@tanstack/router-plugin/vite'

// inside defineConfig(...).plugins
tanstackRouter({ target: 'solid', autoCodeSplitting: false }),
```

## Import Paths

Expand Down
106 changes: 5 additions & 101 deletions packages/tanstack-router/nativescript.vite.mjs
Original file line number Diff line number Diff line change
@@ -1,109 +1,13 @@
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import { existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { tanstackRouter } from '@tanstack/router-plugin/vite';

const require = createRequire(import.meta.url);
const projectRoot = process.cwd();

let solidJsRuntimePath;
let solidJsHPath;
const solidWebShimPath = fileURLToPath(new URL('./solid-web-shim.js', import.meta.url));
const jsxRuntimeShimPath = fileURLToPath(new URL('./solid-js-jsx-runtime-shim.js', import.meta.url));
const tsrConfigPath = join(projectRoot, 'tsr.config.json');
const defaultRoutesDirectory = join(projectRoot, 'src', 'routes');

function hasFileBasedRoutingConfig() {
return existsSync(tsrConfigPath) || existsSync(defaultRoutesDirectory);
}

function forcePreEnforce(plugin) {
if (!plugin || typeof plugin !== 'object') {
return plugin;
}

if (Array.isArray(plugin)) {
return plugin.map(forcePreEnforce);
}

return {
...plugin,
enforce: plugin.enforce ?? 'pre',
};
}

function getRouterPlugins() {
if (!hasFileBasedRoutingConfig()) {
return [];
}

const plugin = tanstackRouter({
// with other frameworks, we can embed different configs
target: 'solid',
autoCodeSplitting: false,
enableRouteGeneration: true,
});

const normalized = forcePreEnforce(plugin);
return Array.isArray(normalized) ? normalized : [normalized];
}

try {
const solidJsPackagePath = require.resolve('solid-js/package.json');
const solidJsRoot = dirname(solidJsPackagePath);

const candidateRuntimePath = join(solidJsRoot, 'h', 'jsx-runtime', 'dist', 'jsx.js');
const candidateHPath = join(solidJsRoot, 'h', 'dist', 'h.js');

if (existsSync(candidateRuntimePath)) {
solidJsRuntimePath = candidateRuntimePath;
}

if (existsSync(candidateHPath)) {
solidJsHPath = candidateHPath;
}

if (!solidJsRuntimePath || !solidJsHPath) {
console.warn(
'[nativescript/tanstack-router] Could not resolve one or more SolidJS runtime alias paths for Vite.',
{
runtimeFound: !!solidJsRuntimePath,
hFound: !!solidJsHPath,
solidJsRoot,
},
);
}
} catch (error) {
console.warn(
'[nativescript/tanstack-router] Failed to resolve SolidJS package location for Vite aliases.',
error instanceof Error ? error.message : error,
);
}

export default () => ({
plugins: [...getRouterPlugins()],
resolve: {
alias: {
// Keep Vite behavior aligned with nativescript.webpack.js integration.
'solid-js/web': solidWebShimPath,
// NOTE: do NOT alias `solid-js/jsx-runtime` / `solid-js/jsx-dev-runtime` to a
// shim file INSIDE this package. @nativescript/vite (solid flavor) already provides
// its own jsx-runtime shim and serves it over HTTP. When this alias pointed at
// `./solid-js-jsx-runtime-shim.js` (a subpath of this vendored runtime plugin), the
// @nativescript/vite device rewriter collapsed that subpath to the vendor-package
// ROOT binding — `jsx = __nsPick("@nativescript/tanstack-router", "jsx")` — and the
// root has no `jsx` export, so `jsx` was `undefined`. Every `jsx(...)` call in the
// bundled router JSX (e.g. renderPage's `<RouterContextProvider><SafeRouteView/>`)
// then threw "jsx is not a function", the route Page never rendered, the Frame stayed
// empty, and the app showed a blank screen under HMR. Letting @nativescript/vite's
// HTTP-served shim resolve these keeps `jsx` a real function. (The webpack path still
// aliases them via nativescript.webpack.js, which has its own shim handling.)
...(solidJsHPath
? {
'solid-js/h': solidJsHPath,
}
: {}),
},
alias: [
// Anchored: `@solidjs/web/*` subpaths (server-functions, storage) are
// renderer-independent and must keep resolving to the real package.
{ find: /^@solidjs\/web$/, replacement: solidWebShimPath },
],
},
});
23 changes: 4 additions & 19 deletions packages/tanstack-router/nativescript.webpack.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
const path = require('path');
const Webpack = require('webpack');

/**
* @param {typeof import('@nativescript/webpack')} webpack
*/
module.exports = (webpack) => {
webpack.mergeWebpack((config) => {
const shimPath = path.resolve(__dirname, 'solid-web-shim.js');
const jsxRuntimeShimPath = path.resolve(__dirname, 'solid-js-jsx-runtime-shim.js');

if (!config.resolve) {
config.resolve = {};
}

if (!config.resolve.alias) {
config.resolve.alias = {};
}

config.resolve.alias['solid-js/web$'] = shimPath;
config.resolve.alias['solid-js/web'] = shimPath;
config.resolve.alias['solid-js/jsx-runtime$'] = jsxRuntimeShimPath;
config.resolve.alias['solid-js/jsx-dev-runtime$'] = jsxRuntimeShimPath;

config.plugins = config.plugins || [];
config.plugins.push(new Webpack.NormalModuleReplacementPlugin(/^solid-js\/web$/, shimPath));
config.plugins.push(new Webpack.NormalModuleReplacementPlugin(/^solid-js\/jsx-runtime$/, jsxRuntimeShimPath));
config.plugins.push(new Webpack.NormalModuleReplacementPlugin(/^solid-js\/jsx-dev-runtime$/, jsxRuntimeShimPath));
config.resolve = config.resolve || {};
config.resolve.alias = config.resolve.alias || {};
// `$` keeps the match exact so `@solidjs/web/*` subpaths resolve normally.
config.resolve.alias['@solidjs/web$'] = shimPath;
});
};
27 changes: 14 additions & 13 deletions packages/tanstack-router/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "@nativescript/tanstack-router",
"version": "0.1.7",
"version": "0.2.1",
"description": "TanStack Router for NativeScript",
"main": "index.cjs",
"types": "index.d.ts",
"files": [
"index.cjs",
"index.mjs",
"index.d.ts",
"*.d.ts",
"*.d.mts",
"solid",
"react",
"nativescript.vite.mjs",
"nativescript.webpack.js",
"solid-web-shim.js",
"solid-js-jsx-runtime-shim.js",
"README.md",
"LICENSE"
],
Expand Down Expand Up @@ -74,16 +74,14 @@
"license": "Apache-2.0",
"homepage": "https://github.com/NativeScript/tanstack",
"readmeFilename": "README.md",
"dependencies": {
"@tanstack/router-plugin": "~1.167.0"
},
"peerDependencies": {
"@nativescript-community/solid-js": ">=0.1.0",
"@nativescript-community/solid-js": ">=2.0.0",
"@nativescript-community/react": ">=0.1.0",
"@nativescript/core": ">=9.0.0",
"solid-js": ">=1.9.0",
"solid-js": ">=2.0.0 <3.0.0",
"@solidjs/web": ">=2.0.0 <3.0.0",
"react": ">=19.0.0",
"@tanstack/solid-router": ">=1.169.0",
"@tanstack/solid-router": ">=2.0.0-rc.12 <3.0.0",
"@tanstack/react-router": ">=1.169.0",
"@tanstack/history": ">=1.161.0"
},
Expand All @@ -97,6 +95,9 @@
"solid-js": {
"optional": true
},
"@solidjs/web": {
"optional": true
},
"react": {
"optional": true
},
Expand All @@ -112,9 +113,9 @@
"typescript": "~5.9.0",
"vitest": "^4.1.5",
"@types/react": "^19.0.0",
"@tanstack/solid-router": "~1.169.0",
"@tanstack/react-router": "~1.169.0",
"@tanstack/history": "~1.161.0",
"@tanstack/router-core": "~1.169.0"
"@tanstack/solid-router": "2.0.0-rc.12",
"@tanstack/react-router": "~1.170.46",
"@tanstack/history": "1.162.5",
"@tanstack/router-core": "1.171.39"
}
}
13 changes: 1 addition & 12 deletions packages/tanstack-router/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,7 @@
"build": {
"executor": "nx:run-commands",
"options": {
"commands": [
"rm -rf dist/packages/tanstack-router",
"tsc -p packages/tanstack-router/tsconfig.json --noEmit",
"tsup --config packages/tanstack-router/tsup.config.ts",
"cp packages/tanstack-router/package.json dist/packages/tanstack-router/package.json",
"cp packages/tanstack-router/README.md dist/packages/tanstack-router/README.md",
"cp packages/tanstack-router/nativescript.vite.mjs dist/packages/tanstack-router/nativescript.vite.mjs",
"cp packages/tanstack-router/nativescript.webpack.js dist/packages/tanstack-router/nativescript.webpack.js",
"cp packages/tanstack-router/solid-web-shim.js dist/packages/tanstack-router/solid-web-shim.js",
"cp packages/tanstack-router/solid-js-jsx-runtime-shim.js dist/packages/tanstack-router/solid-js-jsx-runtime-shim.js",
"cp LICENSE dist/packages/tanstack-router/LICENSE"
],
"commands": ["rm -rf dist/packages/tanstack-router", "tsc -p packages/tanstack-router/tsconfig.json --noEmit", "tsup --config packages/tanstack-router/tsup.config.ts", "cp packages/tanstack-router/package.json dist/packages/tanstack-router/package.json", "cp packages/tanstack-router/README.md dist/packages/tanstack-router/README.md", "cp packages/tanstack-router/nativescript.vite.mjs dist/packages/tanstack-router/nativescript.vite.mjs", "cp packages/tanstack-router/nativescript.webpack.js dist/packages/tanstack-router/nativescript.webpack.js", "cp packages/tanstack-router/solid-web-shim.js dist/packages/tanstack-router/solid-web-shim.js", "cp LICENSE dist/packages/tanstack-router/LICENSE"],
"parallel": false
},
"outputs": ["{workspaceRoot}/dist/packages/tanstack-router"]
Expand Down
20 changes: 0 additions & 20 deletions packages/tanstack-router/solid-js-jsx-runtime-shim.js

This file was deleted.

Loading
Loading