@bleedingdev/modern-js-plugin-i18n 3.2.0-ultramodern.12 → 3.2.0-ultramodern.120

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.
Files changed (117) hide show
  1. package/README.md +221 -11
  2. package/dist/cjs/cli/index.js +32 -5
  3. package/dist/cjs/runtime/I18nLink.js +17 -28
  4. package/dist/cjs/runtime/Link.js +252 -0
  5. package/dist/cjs/runtime/canonicalRoutes.js +18 -0
  6. package/dist/cjs/runtime/context.js +41 -10
  7. package/dist/cjs/runtime/hooks.js +17 -10
  8. package/dist/cjs/runtime/i18n/backend/config.js +9 -5
  9. package/dist/cjs/runtime/i18n/backend/defaults.js +15 -10
  10. package/dist/cjs/runtime/i18n/backend/defaults.node.js +16 -11
  11. package/dist/cjs/runtime/i18n/backend/index.js +9 -5
  12. package/dist/cjs/runtime/i18n/backend/middleware.common.js +9 -5
  13. package/dist/cjs/runtime/i18n/backend/middleware.js +9 -5
  14. package/dist/cjs/runtime/i18n/backend/middleware.node.js +13 -9
  15. package/dist/cjs/runtime/i18n/backend/sdk-backend.js +9 -5
  16. package/dist/cjs/runtime/i18n/backend/sdk-event.js +16 -11
  17. package/dist/cjs/runtime/i18n/detection/config.js +9 -5
  18. package/dist/cjs/runtime/i18n/detection/index.js +9 -5
  19. package/dist/cjs/runtime/i18n/detection/middleware.js +9 -5
  20. package/dist/cjs/runtime/i18n/detection/middleware.node.js +9 -5
  21. package/dist/cjs/runtime/i18n/index.js +9 -5
  22. package/dist/cjs/runtime/i18n/instance.js +17 -37
  23. package/dist/cjs/runtime/i18n/react-i18next.js +53 -0
  24. package/dist/cjs/runtime/i18n/utils.js +9 -17
  25. package/dist/cjs/runtime/index.js +50 -15
  26. package/dist/cjs/runtime/localizedPaths.js +105 -0
  27. package/dist/cjs/runtime/routerAdapter.js +167 -0
  28. package/dist/cjs/runtime/utils.js +87 -97
  29. package/dist/cjs/server/index.js +69 -13
  30. package/dist/cjs/shared/deepMerge.js +12 -8
  31. package/dist/cjs/shared/detection.js +9 -5
  32. package/dist/cjs/shared/localisedUrls.js +271 -0
  33. package/dist/cjs/shared/utils.js +15 -11
  34. package/dist/esm/cli/index.mjs +23 -0
  35. package/dist/esm/runtime/I18nLink.mjs +7 -22
  36. package/dist/esm/runtime/Link.mjs +209 -0
  37. package/dist/esm/runtime/canonicalRoutes.mjs +0 -0
  38. package/dist/esm/runtime/context.mjs +34 -7
  39. package/dist/esm/runtime/hooks.mjs +9 -6
  40. package/dist/esm/runtime/i18n/backend/defaults.mjs +1 -1
  41. package/dist/esm/runtime/i18n/backend/defaults.node.mjs +2 -2
  42. package/dist/esm/runtime/i18n/backend/middleware.node.mjs +3 -3
  43. package/dist/esm/runtime/i18n/instance.mjs +1 -19
  44. package/dist/esm/runtime/i18n/react-i18next.mjs +15 -0
  45. package/dist/esm/runtime/i18n/utils.mjs +0 -12
  46. package/dist/esm/runtime/index.mjs +23 -13
  47. package/dist/esm/runtime/localizedPaths.mjs +58 -0
  48. package/dist/esm/runtime/routerAdapter.mjs +129 -0
  49. package/dist/esm/runtime/utils.mjs +25 -30
  50. package/dist/esm/server/index.mjs +53 -7
  51. package/dist/esm/shared/localisedUrls.mjs +212 -0
  52. package/dist/esm-node/cli/index.mjs +23 -0
  53. package/dist/esm-node/runtime/I18nLink.mjs +7 -22
  54. package/dist/esm-node/runtime/Link.mjs +210 -0
  55. package/dist/esm-node/runtime/canonicalRoutes.mjs +1 -0
  56. package/dist/esm-node/runtime/context.mjs +34 -7
  57. package/dist/esm-node/runtime/hooks.mjs +9 -6
  58. package/dist/esm-node/runtime/i18n/backend/defaults.mjs +1 -1
  59. package/dist/esm-node/runtime/i18n/backend/defaults.node.mjs +2 -2
  60. package/dist/esm-node/runtime/i18n/backend/middleware.node.mjs +3 -3
  61. package/dist/esm-node/runtime/i18n/instance.mjs +1 -19
  62. package/dist/esm-node/runtime/i18n/react-i18next.mjs +16 -0
  63. package/dist/esm-node/runtime/i18n/utils.mjs +0 -12
  64. package/dist/esm-node/runtime/index.mjs +23 -13
  65. package/dist/esm-node/runtime/localizedPaths.mjs +59 -0
  66. package/dist/esm-node/runtime/routerAdapter.mjs +130 -0
  67. package/dist/esm-node/runtime/utils.mjs +25 -30
  68. package/dist/esm-node/server/index.mjs +53 -7
  69. package/dist/esm-node/shared/localisedUrls.mjs +213 -0
  70. package/dist/types/cli/index.d.ts +1 -0
  71. package/dist/types/runtime/I18nLink.d.ts +6 -0
  72. package/dist/types/runtime/Link.d.ts +56 -0
  73. package/dist/types/runtime/canonicalRoutes.d.ts +60 -0
  74. package/dist/types/runtime/context.d.ts +3 -0
  75. package/dist/types/runtime/hooks.d.ts +4 -2
  76. package/dist/types/runtime/i18n/backend/middleware.node.d.ts +1 -1
  77. package/dist/types/runtime/i18n/instance.d.ts +4 -6
  78. package/dist/types/runtime/i18n/react-i18next.d.ts +7 -0
  79. package/dist/types/runtime/index.d.ts +6 -1
  80. package/dist/types/runtime/localizedPaths.d.ts +39 -0
  81. package/dist/types/runtime/routerAdapter.d.ts +26 -0
  82. package/dist/types/runtime/types.d.ts +1 -1
  83. package/dist/types/runtime/utils.d.ts +13 -9
  84. package/dist/types/server/index.d.ts +6 -0
  85. package/dist/types/shared/localisedUrls.d.ts +21 -0
  86. package/dist/types/shared/type.d.ts +12 -0
  87. package/package.json +24 -28
  88. package/rstest.config.mts +39 -0
  89. package/src/cli/index.ts +44 -1
  90. package/src/runtime/I18nLink.tsx +14 -51
  91. package/src/runtime/Link.tsx +414 -0
  92. package/src/runtime/canonicalRoutes.ts +93 -0
  93. package/src/runtime/context.tsx +45 -7
  94. package/src/runtime/hooks.ts +13 -4
  95. package/src/runtime/i18n/backend/defaults.node.ts +2 -2
  96. package/src/runtime/i18n/backend/defaults.ts +3 -1
  97. package/src/runtime/i18n/backend/middleware.node.ts +1 -1
  98. package/src/runtime/i18n/instance.ts +3 -30
  99. package/src/runtime/i18n/react-i18next.ts +25 -0
  100. package/src/runtime/i18n/utils.ts +4 -26
  101. package/src/runtime/index.tsx +47 -12
  102. package/src/runtime/localizedPaths.ts +118 -0
  103. package/src/runtime/routerAdapter.tsx +333 -0
  104. package/src/runtime/types.ts +1 -1
  105. package/src/runtime/utils.ts +44 -37
  106. package/src/server/index.ts +117 -10
  107. package/src/shared/localisedUrls.ts +453 -0
  108. package/src/shared/type.ts +12 -0
  109. package/tests/i18nUtils.test.ts +52 -0
  110. package/tests/link.test.tsx +475 -0
  111. package/tests/linkTypes.test.ts +28 -0
  112. package/tests/localisedUrls.test.ts +312 -0
  113. package/tests/routerAdapter.test.tsx +452 -0
  114. package/tests/type-fixture/linkTypes.fixture.tsx +51 -0
  115. package/tests/type-fixture/tsconfig.json +15 -0
  116. package/dist/esm/rslib-runtime.mjs +0 -18
  117. package/dist/esm-node/rslib-runtime.mjs +0 -19
@@ -0,0 +1,452 @@
1
+ import {
2
+ InternalRuntimeContext,
3
+ RuntimeContext,
4
+ } from '@modern-js/runtime/context';
5
+ import type React from 'react';
6
+ import type { ComponentType, PropsWithChildren } from 'react';
7
+ import { act } from 'react';
8
+ import { createRoot, type Root } from 'react-dom/client';
9
+ import { i18nPlugin } from '../src/runtime';
10
+ import { ModernI18nProvider, useModernI18n } from '../src/runtime/context';
11
+ import { I18nLink } from '../src/runtime/I18nLink';
12
+ import type { I18nInstance } from '../src/runtime/i18n';
13
+ import { getReactI18nextIntegration } from '../src/runtime/i18n/react-i18next';
14
+
15
+ (
16
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
17
+ ).IS_REACT_ACT_ENVIRONMENT = true;
18
+
19
+ const localisedUrls = {
20
+ '/terms-of-service': {
21
+ en: '/terms-of-service',
22
+ cs: '/podminky-pouzivani',
23
+ },
24
+ };
25
+
26
+ const requestContext = {
27
+ request: {},
28
+ response: {},
29
+ };
30
+
31
+ const capturedTanstackLinkProps: any[] = [];
32
+
33
+ const TanstackLink = ({ to, children, ...props }: any) => {
34
+ capturedTanstackLinkProps.push({ to, ...props });
35
+ const { prefetch: _prefetch, preload: _preload, ...anchorProps } = props;
36
+
37
+ return (
38
+ <a href={to} data-router-link="tanstack" {...anchorProps}>
39
+ {children}
40
+ </a>
41
+ );
42
+ };
43
+
44
+ function createI18nInstance(language = 'en'): I18nInstance {
45
+ return {
46
+ language,
47
+ isInitialized: true,
48
+ init: () => Promise.resolve(undefined),
49
+ use: () => {},
50
+ createInstance: () => createI18nInstance(language),
51
+ setLang: rstest.fn(async () => undefined),
52
+ changeLanguage: rstest.fn(async () => undefined),
53
+ services: {},
54
+ options: {},
55
+ };
56
+ }
57
+
58
+ function createRuntimeContext(
59
+ router: unknown,
60
+ framework: 'tanstack' | 'react-router',
61
+ ) {
62
+ return {
63
+ isBrowser: true,
64
+ requestContext,
65
+ context: requestContext,
66
+ routerFramework: framework,
67
+ routerInstance: router,
68
+ routerRuntime: {
69
+ framework,
70
+ instance: router,
71
+ },
72
+ router: {
73
+ ...(framework === 'tanstack'
74
+ ? { Link: TanstackLink, useRouter: () => router }
75
+ : { useLocation: () => undefined, useHref: () => undefined }),
76
+ },
77
+ } as any;
78
+ }
79
+
80
+ function createTanstackRuntimeContext(router: unknown) {
81
+ return createRuntimeContext(router, 'tanstack');
82
+ }
83
+
84
+ function createReactRouterRuntimeContext(router: unknown) {
85
+ return createRuntimeContext(router, 'react-router');
86
+ }
87
+
88
+ function collectI18nWrapRoot() {
89
+ let wrapRoot: ((App: ComponentType<any>) => ComponentType<any>) | undefined;
90
+
91
+ i18nPlugin({
92
+ reactI18next: false,
93
+ localeDetection: {
94
+ fallbackLanguage: 'en',
95
+ },
96
+ }).setup?.({
97
+ getRuntimeConfig: () => ({}),
98
+ onBeforeRender: () => undefined,
99
+ wrapRoot: (callback: (App: ComponentType<any>) => ComponentType<any>) => {
100
+ wrapRoot = callback;
101
+ },
102
+ } as any);
103
+
104
+ if (!wrapRoot) {
105
+ throw new Error('Expected i18n runtime plugin to register wrapRoot');
106
+ }
107
+
108
+ return wrapRoot;
109
+ }
110
+
111
+ function createTanstackRouter(pathname = '/en/terms-of-service', lang = 'en') {
112
+ const url = new URL(pathname, 'https://modernjs.test');
113
+
114
+ return {
115
+ navigate: rstest.fn(async () => undefined),
116
+ state: {
117
+ location: {
118
+ pathname: url.pathname,
119
+ searchStr: url.search,
120
+ hash: url.hash,
121
+ },
122
+ matches: [
123
+ {
124
+ params: {
125
+ lang,
126
+ },
127
+ },
128
+ ],
129
+ },
130
+ };
131
+ }
132
+
133
+ async function renderI18nRoot(node: React.ReactNode) {
134
+ const container = document.createElement('div');
135
+ document.body.appendChild(container);
136
+ const root = createRoot(container);
137
+
138
+ await act(async () => {
139
+ root.render(
140
+ <RuntimeContext.Provider
141
+ value={{
142
+ isBrowser: true,
143
+ requestContext,
144
+ context: requestContext,
145
+ }}
146
+ >
147
+ {node}
148
+ </RuntimeContext.Provider>,
149
+ );
150
+ });
151
+
152
+ return {
153
+ container,
154
+ root,
155
+ };
156
+ }
157
+
158
+ async function renderWithRuntime(
159
+ node: React.ReactNode,
160
+ runtimeContext: ReturnType<typeof createTanstackRuntimeContext>,
161
+ ) {
162
+ const container = document.createElement('div');
163
+ document.body.appendChild(container);
164
+ const root = createRoot(container);
165
+
166
+ await act(async () => {
167
+ root.render(
168
+ <InternalRuntimeContext.Provider value={runtimeContext}>
169
+ {node}
170
+ </InternalRuntimeContext.Provider>,
171
+ );
172
+ });
173
+
174
+ return {
175
+ container,
176
+ root,
177
+ };
178
+ }
179
+
180
+ function cleanup(rendered?: { container: HTMLElement; root: Root }) {
181
+ if (!rendered) {
182
+ return;
183
+ }
184
+ act(() => {
185
+ rendered.root.unmount();
186
+ });
187
+ rendered.container.remove();
188
+ }
189
+
190
+ describe('i18n runtime wrapRoot', () => {
191
+ let rendered: { container: HTMLElement; root: Root } | undefined;
192
+
193
+ afterEach(() => {
194
+ cleanup(rendered);
195
+ rendered = undefined;
196
+ });
197
+
198
+ test('renders children when no root App exists yet', async () => {
199
+ const wrapRoot = collectI18nWrapRoot();
200
+ const I18nRoot = wrapRoot(undefined as unknown as ComponentType<any>);
201
+
202
+ rendered = await renderI18nRoot(
203
+ <I18nRoot>
204
+ <main>router content</main>
205
+ </I18nRoot>,
206
+ );
207
+
208
+ expect(rendered.container.textContent).toContain('router content');
209
+ });
210
+
211
+ test('preserves App props and children', async () => {
212
+ const wrapRoot = collectI18nWrapRoot();
213
+ const App = ({ children, label }: PropsWithChildren<{ label: string }>) => (
214
+ <main data-label={label}>{children}</main>
215
+ );
216
+ const I18nRoot = wrapRoot(App);
217
+
218
+ rendered = await renderI18nRoot(
219
+ <I18nRoot label="root">
220
+ <span>router content</span>
221
+ </I18nRoot>,
222
+ );
223
+
224
+ expect(
225
+ rendered.container.querySelector('main')?.getAttribute('data-label'),
226
+ ).toBe('root');
227
+ expect(rendered.container.textContent).toContain('router content');
228
+ });
229
+ });
230
+
231
+ describe('i18n react-i18next integration', () => {
232
+ test('loads the bundled react-i18next integration', async () => {
233
+ const integration = await getReactI18nextIntegration();
234
+
235
+ expect(integration.I18nextProvider).toEqual(expect.any(Function));
236
+ expect(integration.initReactI18next).toBeDefined();
237
+ });
238
+ });
239
+
240
+ describe('i18n router adapter', () => {
241
+ let rendered: { container: HTMLElement; root: Root } | undefined;
242
+
243
+ afterEach(() => {
244
+ cleanup(rendered);
245
+ rendered = undefined;
246
+ capturedTanstackLinkProps.length = 0;
247
+ window.history.replaceState(null, '', '/');
248
+ });
249
+
250
+ test('uses the TanStack router Link for I18nLink rendering', async () => {
251
+ const router = createTanstackRouter('/cs/podminky-pouzivani', 'cs');
252
+ rendered = await renderWithRuntime(
253
+ <ModernI18nProvider
254
+ value={{
255
+ language: 'cs',
256
+ i18nInstance: createI18nInstance('cs'),
257
+ languages: ['en', 'cs'],
258
+ localePathRedirect: true,
259
+ localisedUrls,
260
+ }}
261
+ >
262
+ <I18nLink to="/terms-of-service" data-testid="terms-link">
263
+ Terms
264
+ </I18nLink>
265
+ </ModernI18nProvider>,
266
+ createTanstackRuntimeContext(router),
267
+ );
268
+
269
+ const link = rendered.container.querySelector<HTMLAnchorElement>(
270
+ '[data-testid="terms-link"]',
271
+ );
272
+ expect(link?.getAttribute('href')).toBe('/cs/podminky-pouzivani');
273
+ expect(link?.getAttribute('data-router-link')).toBe('tanstack');
274
+ });
275
+
276
+ test('forwards warmup props through I18nLink with a localized string target', async () => {
277
+ const router = createTanstackRouter('/cs/podminky-pouzivani', 'cs');
278
+ rendered = await renderWithRuntime(
279
+ <ModernI18nProvider
280
+ value={{
281
+ language: 'cs',
282
+ i18nInstance: createI18nInstance('cs'),
283
+ languages: ['en', 'cs'],
284
+ localePathRedirect: true,
285
+ localisedUrls,
286
+ }}
287
+ >
288
+ <I18nLink
289
+ to="/terms-of-service"
290
+ data-testid="terms-link"
291
+ prefetch="viewport"
292
+ preload="intent"
293
+ >
294
+ Terms
295
+ </I18nLink>
296
+ </ModernI18nProvider>,
297
+ createTanstackRuntimeContext(router),
298
+ );
299
+
300
+ const linkProps = capturedTanstackLinkProps.at(-1);
301
+ expect(linkProps).toMatchObject({
302
+ to: '/cs/podminky-pouzivani',
303
+ prefetch: 'viewport',
304
+ preload: 'intent',
305
+ });
306
+ });
307
+
308
+ test('does not leak warmup props to fallback anchors', async () => {
309
+ rendered = await renderI18nRoot(
310
+ <ModernI18nProvider
311
+ value={{
312
+ language: 'cs',
313
+ i18nInstance: createI18nInstance('cs'),
314
+ languages: ['en', 'cs'],
315
+ localePathRedirect: true,
316
+ localisedUrls,
317
+ }}
318
+ >
319
+ <I18nLink
320
+ to="/terms-of-service"
321
+ data-testid="terms-link"
322
+ prefetch="none"
323
+ preload={false}
324
+ >
325
+ Terms
326
+ </I18nLink>
327
+ </ModernI18nProvider>,
328
+ );
329
+
330
+ const link = rendered.container.querySelector<HTMLAnchorElement>(
331
+ '[data-testid="terms-link"]',
332
+ );
333
+ expect(link?.getAttribute('href')).toBe('/cs/podminky-pouzivani');
334
+ expect(link?.hasAttribute('prefetch')).toBe(false);
335
+ expect(link?.hasAttribute('preload')).toBe(false);
336
+ });
337
+
338
+ test('uses TanStack-shaped replacement when changeLanguage updates the URL', async () => {
339
+ window.history.replaceState(
340
+ null,
341
+ '',
342
+ '/en/terms-of-service?from=test#section',
343
+ );
344
+
345
+ const router = createTanstackRouter(
346
+ '/en/terms-of-service?from=test#section',
347
+ );
348
+ let changeLanguagePromise: Promise<void> | undefined;
349
+
350
+ const Harness = () => {
351
+ const { changeLanguage } = useModernI18n();
352
+ return (
353
+ <button
354
+ type="button"
355
+ onClick={() => {
356
+ changeLanguagePromise = changeLanguage('cs');
357
+ }}
358
+ >
359
+ Change language
360
+ </button>
361
+ );
362
+ };
363
+
364
+ rendered = await renderWithRuntime(
365
+ <ModernI18nProvider
366
+ value={{
367
+ language: 'en',
368
+ i18nInstance: createI18nInstance('en'),
369
+ languages: ['en', 'cs'],
370
+ localePathRedirect: true,
371
+ localisedUrls,
372
+ }}
373
+ >
374
+ <Harness />
375
+ </ModernI18nProvider>,
376
+ createTanstackRuntimeContext(router),
377
+ );
378
+
379
+ const button = rendered.container.querySelector('button');
380
+
381
+ await act(async () => {
382
+ button?.dispatchEvent(
383
+ new MouseEvent('click', {
384
+ bubbles: true,
385
+ cancelable: true,
386
+ button: 0,
387
+ }),
388
+ );
389
+ await changeLanguagePromise;
390
+ });
391
+
392
+ expect(router.navigate).toHaveBeenCalledWith({
393
+ to: '/cs/podminky-pouzivani?from=test#section',
394
+ replace: true,
395
+ });
396
+ });
397
+
398
+ test('keeps React Router positional replacement when changeLanguage updates the URL', async () => {
399
+ window.history.replaceState(null, '', '/en/terms-of-service');
400
+
401
+ const router = {
402
+ navigate: rstest.fn(async () => undefined),
403
+ };
404
+ let changeLanguagePromise: Promise<void> | undefined;
405
+
406
+ const Harness = () => {
407
+ const { changeLanguage } = useModernI18n();
408
+ return (
409
+ <button
410
+ type="button"
411
+ onClick={() => {
412
+ changeLanguagePromise = changeLanguage('cs');
413
+ }}
414
+ >
415
+ Change language
416
+ </button>
417
+ );
418
+ };
419
+
420
+ rendered = await renderWithRuntime(
421
+ <ModernI18nProvider
422
+ value={{
423
+ language: 'en',
424
+ i18nInstance: createI18nInstance('en'),
425
+ languages: ['en', 'cs'],
426
+ localePathRedirect: true,
427
+ localisedUrls,
428
+ }}
429
+ >
430
+ <Harness />
431
+ </ModernI18nProvider>,
432
+ createReactRouterRuntimeContext(router),
433
+ );
434
+
435
+ const button = rendered.container.querySelector('button');
436
+
437
+ await act(async () => {
438
+ button?.dispatchEvent(
439
+ new MouseEvent('click', {
440
+ bubbles: true,
441
+ cancelable: true,
442
+ button: 0,
443
+ }),
444
+ );
445
+ await changeLanguagePromise;
446
+ });
447
+
448
+ expect(router.navigate).toHaveBeenCalledWith('/cs/podminky-pouzivani', {
449
+ replace: true,
450
+ });
451
+ });
452
+ });
@@ -0,0 +1,51 @@
1
+ import { Link } from '@modern-js/plugin-i18n/runtime';
2
+
3
+ declare module '@modern-js/plugin-i18n/runtime' {
4
+ interface UltramodernCanonicalRoutes {
5
+ '/': Record<string, never>;
6
+ '/talks': Record<string, never>;
7
+ '/talks/$slug': { slug: string };
8
+ }
9
+ }
10
+
11
+ // --- valid uses ---
12
+
13
+ // Known route with required params: must compile.
14
+ const _a = <Link to="/talks/$slug" params={{ slug: 'x' }} />;
15
+
16
+ // Known route without params: must compile.
17
+ const _b = <Link to="/talks" />;
18
+
19
+ // Root route: must compile.
20
+ const _c = <Link to="/" />;
21
+
22
+ // Canonical path with hash suffix: must compile.
23
+ const _d = <Link to="/#work-with-me" />;
24
+
25
+ // Canonical path with query and hash: must compile.
26
+ const _e = <Link to="/talks?tag=x#abstract" />;
27
+
28
+ // Bare hash: must compile.
29
+ const _f = <Link to="#hash" />;
30
+
31
+ // External HTTPS URL: must compile.
32
+ const _g = <Link to="https://example.com" />;
33
+
34
+ // Dynamic (computed) value — escape hatch: must compile.
35
+ declare function compute(): string;
36
+ const dynamic: string = compute();
37
+ const _h = <Link to={dynamic} />;
38
+
39
+ // --- invalid uses (each preceded by @ts-expect-error) ---
40
+
41
+ // Unknown route.
42
+ // @ts-expect-error
43
+ const _i = <Link to="/talkz" />;
44
+
45
+ // Known param route but params prop is missing.
46
+ // @ts-expect-error
47
+ const _j = <Link to="/talks/$slug" />;
48
+
49
+ // Known route without params but params are provided (forbidden).
50
+ // @ts-expect-error
51
+ const _k = <Link to="/talks" params={{ slug: 'x' }} />;
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx",
4
+ "strict": true,
5
+ "moduleResolution": "Bundler",
6
+ "module": "Preserve",
7
+ "noEmit": true,
8
+ "skipLibCheck": true,
9
+ "lib": ["ESNext", "DOM"],
10
+ "paths": {
11
+ "@modern-js/plugin-i18n/runtime": ["../../src/runtime/index.tsx"]
12
+ }
13
+ },
14
+ "include": ["*.tsx", "*.ts"]
15
+ }
@@ -1,18 +0,0 @@
1
- var __webpack_modules__ = {};
2
- var __webpack_module_cache__ = {};
3
- function __webpack_require__(moduleId) {
4
- var cachedModule = __webpack_module_cache__[moduleId];
5
- if (void 0 !== cachedModule) return cachedModule.exports;
6
- var module = __webpack_module_cache__[moduleId] = {
7
- exports: {}
8
- };
9
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
10
- return module.exports;
11
- }
12
- __webpack_require__.m = __webpack_modules__;
13
- (()=>{
14
- __webpack_require__.add = function(modules) {
15
- Object.assign(__webpack_require__.m, modules);
16
- };
17
- })();
18
- export { __webpack_require__ };
@@ -1,19 +0,0 @@
1
- import "node:module";
2
- var __webpack_modules__ = {};
3
- var __webpack_module_cache__ = {};
4
- function __webpack_require__(moduleId) {
5
- var cachedModule = __webpack_module_cache__[moduleId];
6
- if (void 0 !== cachedModule) return cachedModule.exports;
7
- var module = __webpack_module_cache__[moduleId] = {
8
- exports: {}
9
- };
10
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
11
- return module.exports;
12
- }
13
- __webpack_require__.m = __webpack_modules__;
14
- (()=>{
15
- __webpack_require__.add = function(modules) {
16
- Object.assign(__webpack_require__.m, modules);
17
- };
18
- })();
19
- export { __webpack_require__ };