@rangojs/router 0.0.0-experimental.87 → 0.0.0-experimental.88
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.
- package/dist/vite/index.js +28 -9
- package/package.json +1 -1
- package/src/vite/rango.ts +15 -7
- package/src/vite/utils/package-resolution.ts +40 -0
package/dist/vite/index.js
CHANGED
|
@@ -1859,12 +1859,13 @@ function getVirtualVersionContent(version) {
|
|
|
1859
1859
|
|
|
1860
1860
|
// src/vite/utils/package-resolution.ts
|
|
1861
1861
|
import { existsSync } from "node:fs";
|
|
1862
|
+
import { createRequire } from "node:module";
|
|
1862
1863
|
import { resolve } from "node:path";
|
|
1863
1864
|
|
|
1864
1865
|
// package.json
|
|
1865
1866
|
var package_default = {
|
|
1866
1867
|
name: "@rangojs/router",
|
|
1867
|
-
version: "0.0.0-experimental.
|
|
1868
|
+
version: "0.0.0-experimental.88",
|
|
1868
1869
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
1869
1870
|
keywords: [
|
|
1870
1871
|
"react",
|
|
@@ -2041,6 +2042,7 @@ var package_default = {
|
|
|
2041
2042
|
};
|
|
2042
2043
|
|
|
2043
2044
|
// src/vite/utils/package-resolution.ts
|
|
2045
|
+
var require2 = createRequire(import.meta.url);
|
|
2044
2046
|
var VIRTUAL_PACKAGE_NAME = "@rangojs/router";
|
|
2045
2047
|
function getPublishedPackageName() {
|
|
2046
2048
|
return package_default.name;
|
|
@@ -2081,6 +2083,20 @@ function getPackageAliases() {
|
|
|
2081
2083
|
}
|
|
2082
2084
|
return aliases;
|
|
2083
2085
|
}
|
|
2086
|
+
function getVendorAliases() {
|
|
2087
|
+
const specs = [
|
|
2088
|
+
"@vitejs/plugin-rsc/vendor/react-server-dom/client.edge",
|
|
2089
|
+
"@vitejs/plugin-rsc/vendor/react-server-dom/server.edge"
|
|
2090
|
+
];
|
|
2091
|
+
const aliases = {};
|
|
2092
|
+
for (const spec of specs) {
|
|
2093
|
+
try {
|
|
2094
|
+
aliases[spec] = require2.resolve(spec);
|
|
2095
|
+
} catch {
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
return aliases;
|
|
2099
|
+
}
|
|
2084
2100
|
|
|
2085
2101
|
// src/build/route-types/param-extraction.ts
|
|
2086
2102
|
function extractParamsFromPattern(pattern) {
|
|
@@ -3260,7 +3276,7 @@ function createCjsToEsmPlugin() {
|
|
|
3260
3276
|
import { createServer as createViteServer } from "vite";
|
|
3261
3277
|
import { resolve as resolve8 } from "node:path";
|
|
3262
3278
|
import { readFileSync as readFileSync6 } from "node:fs";
|
|
3263
|
-
import { createRequire, register } from "node:module";
|
|
3279
|
+
import { createRequire as createRequire2, register } from "node:module";
|
|
3264
3280
|
import { pathToFileURL } from "node:url";
|
|
3265
3281
|
|
|
3266
3282
|
// src/vite/plugins/virtual-stub-plugin.ts
|
|
@@ -4844,7 +4860,7 @@ async function resolveBuildEnv(option, factoryCtx) {
|
|
|
4844
4860
|
);
|
|
4845
4861
|
}
|
|
4846
4862
|
try {
|
|
4847
|
-
const userRequire =
|
|
4863
|
+
const userRequire = createRequire2(
|
|
4848
4864
|
resolve8(factoryCtx.root, "package.json")
|
|
4849
4865
|
);
|
|
4850
4866
|
const wranglerPath = userRequire.resolve("wrangler");
|
|
@@ -5398,15 +5414,18 @@ async function rango(options) {
|
|
|
5398
5414
|
const preset = resolvedOptions.preset ?? "node";
|
|
5399
5415
|
const showBanner = resolvedOptions.banner ?? true;
|
|
5400
5416
|
const plugins = [];
|
|
5401
|
-
const rangoAliases = getPackageAliases();
|
|
5417
|
+
const rangoAliases = { ...getPackageAliases(), ...getVendorAliases() };
|
|
5402
5418
|
const excludeDeps = [
|
|
5403
5419
|
...getExcludeDeps(),
|
|
5404
|
-
//
|
|
5405
|
-
//
|
|
5406
|
-
// .
|
|
5420
|
+
// plugin-rsc itself injects these into the client env's
|
|
5421
|
+
// optimizeDeps.include, which overrides exclude for the dep's own
|
|
5422
|
+
// pre-bundle entry. What exclude still controls is how *other*
|
|
5423
|
+
// pre-bundled deps treat imports of these specs (external vs inlined)
|
|
5424
|
+
// via esbuildCjsExternalPlugin. The cjs-to-esm transform in
|
|
5425
|
+
// plugins/cjs-to-esm.ts is the fallback for strict-pnpm consumers,
|
|
5426
|
+
// where client.browser's bare include fails to resolve and Vite ends up
|
|
5427
|
+
// serving the raw CJS file at dev-serve time.
|
|
5407
5428
|
"@vitejs/plugin-rsc/browser",
|
|
5408
|
-
// Keep the browser RSDW client out of Vite's dep optimizer so our
|
|
5409
|
-
// cjs-to-esm transform can patch the real file.
|
|
5410
5429
|
"@vitejs/plugin-rsc/vendor/react-server-dom/client.browser"
|
|
5411
5430
|
];
|
|
5412
5431
|
const pkg = getPublishedPackageName();
|
package/package.json
CHANGED
package/src/vite/rango.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getExcludeDeps,
|
|
14
14
|
getPackageAliases,
|
|
15
15
|
getPublishedPackageName,
|
|
16
|
+
getVendorAliases,
|
|
16
17
|
} from "./utils/package-resolution.js";
|
|
17
18
|
import { findRouterFiles } from "../build/generate-route-types.js";
|
|
18
19
|
import { createVersionPlugin } from "./plugins/version-plugin.js";
|
|
@@ -60,16 +61,23 @@ export async function rango(options?: RangoOptions): Promise<PluginOption[]> {
|
|
|
60
61
|
|
|
61
62
|
const plugins: PluginOption[] = [];
|
|
62
63
|
|
|
63
|
-
// Get package resolution info (workspace vs npm install)
|
|
64
|
-
|
|
64
|
+
// Get package resolution info (workspace vs npm install).
|
|
65
|
+
// Vendor aliases redirect the bare plugin-rsc vendor specs (which plugin-rsc
|
|
66
|
+
// itself injects into optimizeDeps.include) to absolute paths resolved from
|
|
67
|
+
// this package — so strict-pnpm consumers don't hit "Failed to resolve
|
|
68
|
+
// dependency" warnings when those deps aren't hoisted to their app root.
|
|
69
|
+
const rangoAliases = { ...getPackageAliases(), ...getVendorAliases() };
|
|
65
70
|
const excludeDeps = [
|
|
66
71
|
...getExcludeDeps(),
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
// .
|
|
72
|
+
// plugin-rsc itself injects these into the client env's
|
|
73
|
+
// optimizeDeps.include, which overrides exclude for the dep's own
|
|
74
|
+
// pre-bundle entry. What exclude still controls is how *other*
|
|
75
|
+
// pre-bundled deps treat imports of these specs (external vs inlined)
|
|
76
|
+
// via esbuildCjsExternalPlugin. The cjs-to-esm transform in
|
|
77
|
+
// plugins/cjs-to-esm.ts is the fallback for strict-pnpm consumers,
|
|
78
|
+
// where client.browser's bare include fails to resolve and Vite ends up
|
|
79
|
+
// serving the raw CJS file at dev-serve time.
|
|
70
80
|
"@vitejs/plugin-rsc/browser",
|
|
71
|
-
// Keep the browser RSDW client out of Vite's dep optimizer so our
|
|
72
|
-
// cjs-to-esm transform can patch the real file.
|
|
73
81
|
"@vitejs/plugin-rsc/vendor/react-server-dom/client.browser",
|
|
74
82
|
];
|
|
75
83
|
|
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
9
10
|
import { resolve } from "node:path";
|
|
10
11
|
import packageJson from "../../../package.json";
|
|
11
12
|
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
|
|
12
15
|
/**
|
|
13
16
|
* The canonical name used in virtual entries (without scope)
|
|
14
17
|
*/
|
|
@@ -119,3 +122,40 @@ export function getPackageAliases(): Record<string, string> {
|
|
|
119
122
|
|
|
120
123
|
return aliases;
|
|
121
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Plugin-rsc pushes bare specs like
|
|
128
|
+
* `@vitejs/plugin-rsc/vendor/react-server-dom/client.edge` into
|
|
129
|
+
* `optimizeDeps.include` for the ssr and rsc environments. In strict pnpm
|
|
130
|
+
* consumer apps, `@vitejs/plugin-rsc` is only reachable from @rangojs/router's
|
|
131
|
+
* node_modules, so Vite's optimizer — which resolves from the project root —
|
|
132
|
+
* can't find them and emits "Failed to resolve dependency" warnings.
|
|
133
|
+
*
|
|
134
|
+
* We resolve those specs from this plugin's location (where plugin-rsc is
|
|
135
|
+
* guaranteed to be installed as our dep) and expose them as `resolve.alias`
|
|
136
|
+
* entries. The optimizer's resolver honors aliases, so the bare specs map to
|
|
137
|
+
* absolute paths and resolve cleanly.
|
|
138
|
+
*/
|
|
139
|
+
export function getVendorAliases(): Record<string, string> {
|
|
140
|
+
// client.browser is intentionally NOT aliased. plugin-rsc injects it into
|
|
141
|
+
// the client env's optimizeDeps.include; Vite's manual-include path resolves
|
|
142
|
+
// and pre-bundles regardless of optimizeDeps.exclude, so aliasing would
|
|
143
|
+
// trigger esbuild pre-bundling of the CJS vendor file and bypass the
|
|
144
|
+
// cjs-to-esm transform that patches `require('react'|'react-dom')` into
|
|
145
|
+
// real ESM imports. The consumer may still see a single "Failed to resolve"
|
|
146
|
+
// warning for client.browser; runtime resolution from plugin-rsc's own
|
|
147
|
+
// importer works because Vite resolves relative to the importer (not root).
|
|
148
|
+
const specs = [
|
|
149
|
+
"@vitejs/plugin-rsc/vendor/react-server-dom/client.edge",
|
|
150
|
+
"@vitejs/plugin-rsc/vendor/react-server-dom/server.edge",
|
|
151
|
+
];
|
|
152
|
+
const aliases: Record<string, string> = {};
|
|
153
|
+
for (const spec of specs) {
|
|
154
|
+
try {
|
|
155
|
+
aliases[spec] = require.resolve(spec);
|
|
156
|
+
} catch {
|
|
157
|
+
// Spec unresolvable (unexpected but non-fatal — Vite will warn as before).
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return aliases;
|
|
161
|
+
}
|