@bleedingdev/modern-js-plugin-tanstack 3.9.0-ultramodern.5 → 3.9.0-ultramodern.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,10 +30,8 @@ __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
31
  tanstackRouterProviderFactory: ()=>tanstackRouterProviderFactory
32
32
  });
33
- const router_provider_namespaceObject = require("@modern-js/runtime-extensions/router-provider");
34
33
  const external_plugin_js_namespaceObject = require("./plugin.js");
35
34
  const tanstackRouterProviderFactory = (userConfig)=>(0, external_plugin_js_namespaceObject.tanstackRouterPlugin)(userConfig);
36
- (0, router_provider_namespaceObject.registerRouterProvider)('tanstack', tanstackRouterProviderFactory);
37
35
  exports.tanstackRouterProviderFactory = __webpack_exports__.tanstackRouterProviderFactory;
38
36
  for(var __rspack_i in __webpack_exports__)if (-1 === [
39
37
  "tanstackRouterProviderFactory"
@@ -1,5 +1,3 @@
1
- import { registerRouterProvider } from "@modern-js/runtime-extensions/router-provider";
2
1
  import { tanstackRouterPlugin } from "./plugin.mjs";
3
2
  const tanstackRouterProviderFactory = (userConfig)=>tanstackRouterPlugin(userConfig);
4
- registerRouterProvider('tanstack', tanstackRouterProviderFactory);
5
3
  export { tanstackRouterProviderFactory };
@@ -1,6 +1,4 @@
1
1
  import "node:module";
2
- import { registerRouterProvider } from "@modern-js/runtime-extensions/router-provider";
3
2
  import { tanstackRouterPlugin } from "./plugin.mjs";
4
3
  const tanstackRouterProviderFactory = (userConfig)=>tanstackRouterPlugin(userConfig);
5
- registerRouterProvider('tanstack', tanstackRouterProviderFactory);
6
4
  export { tanstackRouterProviderFactory };
@@ -1,10 +1,2 @@
1
- /**
2
- * Registers TanStack in the @modern-js/runtime compatibility registry.
3
- * Runtime entries bind the exported local factory into their own provider
4
- * realm; registration remains for older runtime wrappers and mixed cohorts.
5
- *
6
- * This module is intentionally side-effectful (see `sideEffects` in
7
- * package.json).
8
- */
9
1
  import { type RouterProviderFactory } from '@modern-js/runtime-extensions/router-provider';
10
2
  export declare const tanstackRouterProviderFactory: RouterProviderFactory;
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "modern.js",
19
19
  "tanstack-router"
20
20
  ],
21
- "version": "3.9.0-ultramodern.5",
21
+ "version": "3.9.0-ultramodern.6",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -94,19 +94,19 @@
94
94
  }
95
95
  },
96
96
  "dependencies": {
97
- "@modern-js/i18n-runtime-extensions": "npm:@bleedingdev/modern-js-i18n-runtime-extensions@3.9.0-ultramodern.5",
98
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.5",
99
- "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.5",
100
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.5",
101
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.5",
102
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.5",
97
+ "@modern-js/i18n-runtime-extensions": "npm:@bleedingdev/modern-js-i18n-runtime-extensions@3.9.0-ultramodern.6",
98
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.6",
99
+ "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.6",
100
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.6",
101
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.6",
102
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.6",
103
103
  "@swc/helpers": "^0.5.23",
104
104
  "@tanstack/react-router": "1.170.33",
105
105
  "@tanstack/router-core": "1.171.28"
106
106
  },
107
107
  "peerDependencies": {
108
- "@modern-js/app-tools": "3.9.0-ultramodern.5",
109
- "@modern-js/runtime": "3.9.0-ultramodern.5",
108
+ "@modern-js/app-tools": "3.9.0-ultramodern.6",
109
+ "@modern-js/runtime": "3.9.0-ultramodern.6",
110
110
  "react": "^19.2.8",
111
111
  "react-dom": "^19.2.8",
112
112
  "react-server-dom-rspack": "0.1.0"
@@ -117,9 +117,9 @@
117
117
  }
118
118
  },
119
119
  "devDependencies": {
120
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.5",
121
- "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.0-ultramodern.5",
122
- "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.0-ultramodern.5",
120
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.6",
121
+ "@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.9.0-ultramodern.6",
122
+ "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.0-ultramodern.6",
123
123
  "@rslib/core": "1.0.0",
124
124
  "@scripts/rstest-config": "2.66.0",
125
125
  "@tanstack/history": "1.162.2",
package/rstest.config.mts CHANGED
@@ -1,4 +1,3 @@
1
- import path from 'node:path';
2
1
  import type { ProjectConfig } from '@rstest/core';
3
2
  import { withTestPreset } from '@scripts/rstest-config';
4
3
 
@@ -42,20 +41,6 @@ export default {
42
41
  ],
43
42
  extends: commonConfig,
44
43
  }),
45
- withTestPreset({
46
- name: 'plugin-tanstack-router-compatibility',
47
- testEnvironment: 'node',
48
- include: ['tests/router/routerCompatibility.test.ts'],
49
- resolve: {
50
- alias: {
51
- '@modern-js/runtime/router/internal': path.resolve(
52
- __dirname,
53
- 'tests/router/fixtures/legacyRuntimeRouter.ts',
54
- ),
55
- },
56
- },
57
- extends: commonConfig,
58
- }),
59
44
  withTestPreset({
60
45
  name: 'plugin-tanstack-client',
61
46
  testEnvironment: 'happy-dom',
@@ -1,15 +1,6 @@
1
- /**
2
- * Registers TanStack in the @modern-js/runtime compatibility registry.
3
- * Runtime entries bind the exported local factory into their own provider
4
- * realm; registration remains for older runtime wrappers and mixed cohorts.
5
- *
6
- * This module is intentionally side-effectful (see `sideEffects` in
7
- * package.json).
8
- */
9
1
  import {
10
2
  type RouterProviderFactory,
11
3
  type RouterProviderPlugin,
12
- registerRouterProvider,
13
4
  } from '@modern-js/runtime-extensions/router-provider';
14
5
  import { tanstackRouterPlugin } from './plugin';
15
6
 
@@ -22,5 +13,3 @@ import { tanstackRouterPlugin } from './plugin';
22
13
  export const tanstackRouterProviderFactory: RouterProviderFactory =
23
14
  userConfig =>
24
15
  tanstackRouterPlugin(userConfig) as unknown as RouterProviderPlugin;
25
-
26
- registerRouterProvider('tanstack', tanstackRouterProviderFactory);
@@ -2,11 +2,6 @@ import type { RouterProviderFactory } from '@modern-js/runtime-extensions/router
2
2
  import { rstest } from '@rstest/core';
3
3
  import type { RouterExtendsHooks } from '../src/runtime/hooks';
4
4
 
5
- const REGISTRY_SLOT: unique symbol = Symbol.for(
6
- '@modern-js/runtime:router-providers:v3',
7
- );
8
- const host = globalThis as { [REGISTRY_SLOT]?: unknown };
9
-
10
5
  type RuntimeContextModule = typeof import('@modern-js/runtime/context');
11
6
  type RouterModule = typeof import('../src/runtime/router');
12
7
 
@@ -71,7 +66,6 @@ function setupRouterWrapper(vertical: Vertical) {
71
66
 
72
67
  describe('TanStack provider runtime-realm isolation', () => {
73
68
  beforeEach(() => {
74
- delete host[REGISTRY_SLOT];
75
69
  rstest.resetModules();
76
70
  (
77
71
  globalThis as typeof globalThis & {
@@ -81,7 +75,6 @@ describe('TanStack provider runtime-realm isolation', () => {
81
75
  });
82
76
 
83
77
  afterEach(() => {
84
- delete host[REGISTRY_SLOT];
85
78
  rstest.resetModules();
86
79
  });
87
80
 
@@ -104,15 +97,6 @@ describe('TanStack provider runtime-realm isolation', () => {
104
97
  expect(routerB.useMatches).toBe(verticalB.useMatches);
105
98
  expect(routerB.Link).not.toBe(verticalA.Link);
106
99
  expect(routerB.useMatches).not.toBe(verticalA.useMatches);
107
-
108
- // Mixed-version callers that do not supply a realm still see the shared
109
- // keep-first fallback, but production wrappers no longer consume it.
110
- expect(verticalB.providers.resolveRouterProvider('tanstack')).toBe(
111
- verticalA.factory,
112
- );
113
- expect(warnSpy).toHaveBeenCalledWith(
114
- expect.stringMatching(/keeping the first registration/),
115
- );
116
100
  } finally {
117
101
  warnSpy.mockRestore();
118
102
  }
@@ -1,10 +0,0 @@
1
- let invocationCount = 0;
2
-
3
- export const routerPlugin = (
4
- _userConfig: Record<string, unknown> = {},
5
- ): { name?: string; setup?: (...args: unknown[]) => unknown } => {
6
- invocationCount += 1;
7
- throw new Error('The legacy global router wrapper must not be invoked.');
8
- };
9
-
10
- export const getLegacyRouterPluginInvocationCount = () => invocationCount;
@@ -1,8 +0,0 @@
1
- import { resolveRouterProvider } from '@modern-js/runtime-extensions/router-provider';
2
- import '../../src/runtime/register';
3
-
4
- describe("'@modern-js/plugin-tanstack/runtime' import side effects", () => {
5
- it('registers the tanstack router provider', () => {
6
- expect(typeof resolveRouterProvider('tanstack')).toBe('function');
7
- });
8
- });
@@ -1,262 +0,0 @@
1
- import { execFileSync } from 'node:child_process';
2
- import {
3
- mkdirSync,
4
- mkdtempSync,
5
- readFileSync,
6
- rmSync,
7
- writeFileSync,
8
- } from 'node:fs';
9
- import { tmpdir } from 'node:os';
10
- import path from 'node:path';
11
-
12
- const REGISTRY_SLOT: unique symbol = Symbol.for(
13
- '@modern-js/runtime:router-providers:v3',
14
- );
15
- const registryHost = globalThis as { [REGISTRY_SLOT]?: unknown };
16
- const webpackHost = globalThis as typeof globalThis & {
17
- __webpack_require__?: { u: (chunkId: unknown) => string };
18
- };
19
- const installWebpackRequire = () => {
20
- webpackHost.__webpack_require__ = { u: chunkId => String(chunkId) };
21
- };
22
-
23
- type LegacyRuntimeRouterModule = {
24
- getLegacyRouterPluginInvocationCount: () => number;
25
- routerPlugin: (...args: unknown[]) => unknown;
26
- };
27
-
28
- type CompatibilityGraph = {
29
- factory: (...args: any[]) => any;
30
- Link: unknown;
31
- hooks: Record<string, unknown>;
32
- legacyRuntimeRouter: LegacyRuntimeRouterModule;
33
- resolveRouterProvider: (
34
- framework?: string,
35
- ) => (...args: unknown[]) => unknown;
36
- routerPlugin: (...args: any[]) => any;
37
- };
38
-
39
- async function loadCompatibilityGraph(): Promise<CompatibilityGraph> {
40
- rstest.resetModules();
41
- installWebpackRequire();
42
-
43
- const legacyRuntimeRouter = (await import(
44
- '@modern-js/runtime/router/internal'
45
- )) as unknown as LegacyRuntimeRouterModule;
46
- const { routerPlugin } = await import('../../src/runtime/router');
47
- const { tanstackRouterProviderFactory } = await import(
48
- '../../src/runtime/register'
49
- );
50
- const { resolveRouterProvider } = await import(
51
- '@modern-js/runtime-extensions/router-provider'
52
- );
53
- const { routerProviderRegistryHooks } = await import(
54
- '../../src/runtime/hooks'
55
- );
56
- const { Link } = await import('../../src/runtime/prefetchLink');
57
-
58
- return {
59
- factory: tanstackRouterProviderFactory,
60
- Link,
61
- hooks: routerProviderRegistryHooks,
62
- legacyRuntimeRouter,
63
- resolveRouterProvider,
64
- routerPlugin,
65
- };
66
- }
67
-
68
- function initializeRouter(graph: CompatibilityGraph) {
69
- const beforeRender: ((context: any, interrupt: () => void) => unknown)[] = [];
70
- const plugin = graph.routerPlugin({ framework: 'tanstack' });
71
- plugin.setup({
72
- getHooks: () => graph.hooks,
73
- getRuntimeConfig: () => ({ router: { framework: 'tanstack' } }),
74
- onAfterCreateRouter: () => undefined,
75
- onBeforeRender: (
76
- callback: (context: any, interrupt: () => void) => unknown,
77
- ) => beforeRender.push(callback),
78
- wrapRoot: () => undefined,
79
- });
80
- const context: any = {};
81
- for (const callback of beforeRender) callback(context, () => {});
82
- return context.router as { Link: unknown };
83
- }
84
-
85
- function resolveTsgoBin(): string {
86
- const packageJsonPath = require.resolve(
87
- '@typescript/native-preview/package.json',
88
- );
89
- const packageDirectory = path.dirname(packageJsonPath);
90
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {
91
- bin?: string | { tsgo?: string };
92
- };
93
- const binEntry =
94
- typeof packageJson.bin === 'string'
95
- ? packageJson.bin
96
- : packageJson.bin?.tsgo;
97
-
98
- return path.resolve(packageDirectory, binEntry ?? 'bin/tsgo.js');
99
- }
100
-
101
- function runTsgo(tsgoBin: string, configPath: string): void {
102
- try {
103
- execFileSync(process.execPath, [tsgoBin, '-p', configPath], {
104
- stdio: 'pipe',
105
- });
106
- } catch (error) {
107
- const result = error as { stderr?: Buffer; stdout?: Buffer };
108
- throw new Error(
109
- `TS-Go compatibility check failed:\n${String(result.stdout ?? '')}${String(
110
- result.stderr ?? '',
111
- )}`,
112
- );
113
- }
114
- }
115
-
116
- installWebpackRequire();
117
-
118
- describe('runtime router compatibility', () => {
119
- beforeEach(() => {
120
- delete registryHost[REGISTRY_SLOT];
121
- rstest.resetModules();
122
- installWebpackRequire();
123
- });
124
-
125
- afterEach(() => {
126
- delete registryHost[REGISTRY_SLOT];
127
- });
128
-
129
- it('uses the app-local factory instead of the legacy global wrapper', async () => {
130
- const graph = await loadCompatibilityGraph();
131
-
132
- expect('createRouterPlugin' in graph.legacyRuntimeRouter).toBe(false);
133
- expect(initializeRouter(graph).Link).toBe(graph.Link);
134
- expect(
135
- graph.legacyRuntimeRouter.getLegacyRouterPluginInvocationCount(),
136
- ).toBe(0);
137
- });
138
-
139
- it('keeps independently evaluated legacy module graphs app-local', async () => {
140
- const graphA = await loadCompatibilityGraph();
141
- const graphB = await loadCompatibilityGraph();
142
-
143
- expect(graphB.factory).not.toBe(graphA.factory);
144
- expect(graphB.routerPlugin).not.toBe(graphA.routerPlugin);
145
- expect(graphB.resolveRouterProvider('tanstack')).toBe(graphA.factory);
146
- expect(initializeRouter(graphA).Link).toBe(graphA.Link);
147
- expect(initializeRouter(graphB).Link).toBe(graphB.Link);
148
- expect(
149
- graphA.legacyRuntimeRouter.getLegacyRouterPluginInvocationCount(),
150
- ).toBe(0);
151
- expect(
152
- graphB.legacyRuntimeRouter.getLegacyRouterPluginInvocationCount(),
153
- ).toBe(0);
154
- });
155
-
156
- it('emits declarations compatible with the oldest runtime router shape', () => {
157
- const packageRoot = path.resolve(__dirname, '../..');
158
- const sourcePath = path.join(packageRoot, 'src/runtime/router.ts');
159
- const legacyFixturePath = path.join(
160
- __dirname,
161
- 'fixtures/legacyRuntimeRouter.ts',
162
- );
163
- const tempRoot = mkdtempSync(
164
- path.join(tmpdir(), 'plugin-tanstack-router-compatibility-'),
165
- );
166
- const sourceRoot = path.join(tempRoot, 'src');
167
- const emittedRoot = path.join(tempRoot, 'types');
168
- const tsgoBin = resolveTsgoBin();
169
-
170
- try {
171
- mkdirSync(sourceRoot, { recursive: true });
172
- writeFileSync(
173
- path.join(sourceRoot, 'router.ts'),
174
- readFileSync(sourcePath, 'utf8'),
175
- );
176
- writeFileSync(
177
- path.join(sourceRoot, 'register.ts'),
178
- [
179
- 'export declare const tanstackRouterProviderFactory:',
180
- ' (userConfig?: Record<string, unknown>) => { name?: string };',
181
- ].join('\n'),
182
- );
183
- writeFileSync(
184
- path.join(tempRoot, 'currentRuntimeRouter.d.ts'),
185
- [
186
- 'export type RouterPluginFactory =',
187
- ' (userConfig?: Record<string, unknown>) => { name?: string };',
188
- 'export declare const routerPlugin: RouterPluginFactory;',
189
- 'export declare const createRouterPlugin:',
190
- ' (providers: readonly unknown[]) => RouterPluginFactory;',
191
- ].join('\n'),
192
- );
193
- writeFileSync(
194
- path.join(tempRoot, 'emit.json'),
195
- JSON.stringify(
196
- {
197
- compilerOptions: {
198
- declaration: true,
199
- emitDeclarationOnly: true,
200
- module: 'Preserve',
201
- moduleResolution: 'Bundler',
202
- noCheck: true,
203
- outDir: emittedRoot,
204
- paths: {
205
- '@modern-js/runtime/router/internal': [
206
- './currentRuntimeRouter.d.ts',
207
- ],
208
- },
209
- rootDir: sourceRoot,
210
- skipLibCheck: false,
211
- strict: true,
212
- target: 'ESNext',
213
- types: [],
214
- },
215
- files: [path.join(sourceRoot, 'router.ts')],
216
- },
217
- null,
218
- 2,
219
- ),
220
- );
221
-
222
- runTsgo(tsgoBin, path.join(tempRoot, 'emit.json'));
223
-
224
- const declarationPath = path.join(emittedRoot, 'router.d.ts');
225
- writeFileSync(
226
- path.join(tempRoot, 'legacyRuntimeRouter.ts'),
227
- readFileSync(legacyFixturePath, 'utf8'),
228
- );
229
- writeFileSync(
230
- path.join(tempRoot, 'compatibility.json'),
231
- JSON.stringify(
232
- {
233
- compilerOptions: {
234
- module: 'Preserve',
235
- moduleResolution: 'Bundler',
236
- noEmit: true,
237
- paths: {
238
- '@modern-js/runtime/router/internal': [
239
- './legacyRuntimeRouter.ts',
240
- ],
241
- },
242
- skipLibCheck: false,
243
- strict: true,
244
- target: 'ESNext',
245
- types: [],
246
- },
247
- files: [
248
- declarationPath,
249
- path.join(tempRoot, 'legacyRuntimeRouter.ts'),
250
- ],
251
- },
252
- null,
253
- 2,
254
- ),
255
- );
256
-
257
- runTsgo(tsgoBin, path.join(tempRoot, 'compatibility.json'));
258
- } finally {
259
- rmSync(tempRoot, { force: true, recursive: true });
260
- }
261
- });
262
- });