Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(router-core): moving the router core into separate package #3171

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

birkskyum
Copy link

@birkskyum birkskyum commented Jan 14, 2025

This is a preparation step for:

It moves pieces of shared logic from react-router to router-core, and imports it from there.

The exports in react-router/src/index.tsx are kept as is, by re-exporting functions from router-core, to avoid breaking changes.

@birkskyum birkskyum force-pushed the router-core branch 2 times, most recently from 1a7588d to 780faf6 Compare January 14, 2025 23:17
@birkskyum birkskyum changed the title extract parts of react-router to router-core Extract parts of react-router to an agnostic router-core package Jan 14, 2025
@birkskyum birkskyum changed the title Extract parts of react-router to an agnostic router-core package Extract parts of react-router to shared router-core package Jan 14, 2025
SeanCassiere

This comment was marked as resolved.

@SeanCassiere SeanCassiere marked this pull request as draft January 15, 2025 00:07
@SeanCassiere
Copy link
Member

@schiller-manuel @chorobin any idea how this affects the global module declaration merging that we use for type-safety.

@birkskyum

This comment was marked as outdated.

Copy link

nx-cloud bot commented Jan 16, 2025

View your CI Pipeline Execution ↗ for commit a5de1ba.

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 5m 42s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 23s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-16 19:02:49 UTC

Copy link

pkg-pr-new bot commented Jan 16, 2025

Open in Stackblitz

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@3171

@tanstack/create-start

npm i https://pkg.pr.new/@tanstack/create-start@3171

@tanstack/create-router

npm i https://pkg.pr.new/@tanstack/create-router@3171

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/@tanstack/directive-functions-plugin@3171

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@3171

@tanstack/react-cross-context

npm i https://pkg.pr.new/@tanstack/react-cross-context@3171

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@3171

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@3171

@tanstack/react-router-with-query

npm i https://pkg.pr.new/@tanstack/react-router-with-query@3171

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@3171

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@3171

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@3171

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@3171

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@3171

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@3171

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/@tanstack/server-functions-plugin@3171

@tanstack/start

npm i https://pkg.pr.new/@tanstack/start@3171

@tanstack/start-plugin

npm i https://pkg.pr.new/@tanstack/start-plugin@3171

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@3171

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@3171

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@3171

commit: a5de1ba

@birkskyum

This comment was marked as resolved.

@SeanCassiere
Copy link
Member

@schiller-manuel @chorobin any thoughts as to where this declaration merge type error is coming from?
https://cloud.nx.app/runs/W720HeqFWm/task/%40router-mono-simple%2Frouter%3Abuild

@SeanCassiere SeanCassiere changed the title Extract parts of react-router to shared router-core package refactor(router-core): moving the router core into separate package Jan 16, 2025
@birkskyum
Copy link
Author

birkskyum commented Jan 16, 2025

@SeanCassiere , I find it helps to add "@tanstack/router-core": "^1.97.1", to the deps of

examples/react/router-monorepo-react-query/packages/router/package.json

@SeanCassiere
Copy link
Member

@SeanCassiere , I find it helps to add "@tanstack/router-core": "^1.97.1", to the deps of

The problem here is that it shouldn't require this.

  • this'd be considered a breaking change.

@birkskyum
Copy link
Author

birkskyum commented Jan 17, 2025

@SeanCassiere , right. I've looked at how query does it, but it's using tsup /esbuild rather than vite / rollup. I don't think the setup from query is better at this, it might just be less strict, similar to if the examples/../router/tsconfig.json had an include: ["src"] and thus didn't conflict with the output in the /dist folder.

I went down a rabit hole with dts / https://api-extractor.com/ and the bundledPackages, and I couldn't make it give the right result. Then there's the @tanstack/config with the preserveModules too, which I could worry is also working against this attempt to inline the shared package. In query the svelte-query, solid-query doesn't use tanstack/config, but are there some other "agnostic" projects that does?

Basically, the only solution I've been able to make work here, that doesn't carbon-copy the router-core into e.g. react-router putting us where we started, is to have a symlink doing the same thing. I.e. a link from react-router/src/core -> router-core/src, so that instead of the dependency on @tanstack/router-core, the react-router just imports from './core/index'.

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