@rpcbase/vite 0.72.0 → 0.74.0
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/index.js +59 -7
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -21,14 +21,33 @@ import { posthogSourcemapsPlugin } from "./posthogSourcemapsPlugin.js"
|
|
|
21
21
|
|
|
22
22
|
const require = createRequire(import.meta.url)
|
|
23
23
|
|
|
24
|
+
const splitPackageSpecifier = (specifier) => {
|
|
25
|
+
if (!specifier) return { pkgName: specifier, subpath: "" }
|
|
26
|
+
|
|
27
|
+
if (specifier.startsWith("@")) {
|
|
28
|
+
const segments = specifier.split("/")
|
|
29
|
+
if (segments.length < 2) return { pkgName: specifier, subpath: "" }
|
|
30
|
+
return {
|
|
31
|
+
pkgName: `${segments[0]}/${segments[1]}`,
|
|
32
|
+
subpath: segments.slice(2).join("/"),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const [pkgName, ...rest] = specifier.split("/")
|
|
37
|
+
return { pkgName, subpath: rest.join("/") }
|
|
38
|
+
}
|
|
39
|
+
|
|
24
40
|
const resolvePackageRoot = (pkg) => {
|
|
41
|
+
const { pkgName } = splitPackageSpecifier(pkg)
|
|
42
|
+
if (!pkgName) return pkg
|
|
43
|
+
|
|
25
44
|
// 1) chemin rapide: si le package exporte son package.json
|
|
26
45
|
try {
|
|
27
|
-
const pkgJson = require.resolve(`${
|
|
46
|
+
const pkgJson = require.resolve(`${pkgName}/package.json`)
|
|
28
47
|
return path.dirname(pkgJson)
|
|
29
48
|
} catch (err) {
|
|
30
49
|
// 2) fallback: résoudre l'entrée du package puis remonter jusqu'à sa racine
|
|
31
|
-
const entry = require.resolve(
|
|
50
|
+
const entry = require.resolve(pkgName) // ex: .../node_modules/<pkg>/dist/...
|
|
32
51
|
let dir = path.dirname(entry)
|
|
33
52
|
|
|
34
53
|
// remonter jusqu'à un package.json dont "name" === pkg
|
|
@@ -37,7 +56,7 @@ const resolvePackageRoot = (pkg) => {
|
|
|
37
56
|
if (existsSync(pkgJsonPath)) {
|
|
38
57
|
try {
|
|
39
58
|
const json = JSON.parse(readFileSync(pkgJsonPath, "utf8"))
|
|
40
|
-
if (json && json.name ===
|
|
59
|
+
if (json && json.name === pkgName) return dir
|
|
41
60
|
} catch {
|
|
42
61
|
// ignore parsing errors
|
|
43
62
|
}
|
|
@@ -52,7 +71,7 @@ const resolvePackageRoot = (pkg) => {
|
|
|
52
71
|
const idx = entry.lastIndexOf(nmMarker)
|
|
53
72
|
if (idx !== -1) {
|
|
54
73
|
const nmRoot = entry.slice(0, idx + nmMarker.length)
|
|
55
|
-
return path.join(nmRoot,
|
|
74
|
+
return path.join(nmRoot, pkgName)
|
|
56
75
|
}
|
|
57
76
|
|
|
58
77
|
// si vraiment rien trouvé, relancer l'erreur d'origine
|
|
@@ -62,6 +81,36 @@ const resolvePackageRoot = (pkg) => {
|
|
|
62
81
|
|
|
63
82
|
const withTrailingSep = p => (p.endsWith(path.sep) ? p : p + path.sep)
|
|
64
83
|
|
|
84
|
+
const resolveIntegratedPackagePath = (specifier) => {
|
|
85
|
+
const { pkgName, subpath } = splitPackageSpecifier(specifier)
|
|
86
|
+
if (!pkgName) return specifier
|
|
87
|
+
|
|
88
|
+
const root = resolvePackageRoot(pkgName)
|
|
89
|
+
if (!subpath) {
|
|
90
|
+
return withTrailingSep(root)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const subDir = path.join(root, subpath)
|
|
94
|
+
const pkgJsonPath = path.join(subDir, "package.json")
|
|
95
|
+
if (existsSync(pkgJsonPath)) {
|
|
96
|
+
try {
|
|
97
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"))
|
|
98
|
+
const entry = pkgJson.module || pkgJson.main
|
|
99
|
+
if (entry) {
|
|
100
|
+
return path.join(subDir, entry)
|
|
101
|
+
}
|
|
102
|
+
} catch {
|
|
103
|
+
// ignore parsing errors
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
return require.resolve(specifier)
|
|
109
|
+
} catch {
|
|
110
|
+
return withTrailingSep(subDir)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
65
114
|
|
|
66
115
|
// const isCI = process.env.CI === "true"
|
|
67
116
|
|
|
@@ -99,14 +148,17 @@ const integratedPackages = [
|
|
|
99
148
|
"axios",
|
|
100
149
|
"libphonenumber-js",
|
|
101
150
|
"posthog-js",
|
|
151
|
+
"posthog-js/react",
|
|
102
152
|
"posthog-node",
|
|
103
|
-
"react-
|
|
153
|
+
"react-router",
|
|
154
|
+
"react-hook-form",
|
|
155
|
+
"react-use"
|
|
104
156
|
]
|
|
105
157
|
|
|
106
158
|
// Add each integrated package to resolveAliases
|
|
107
159
|
integratedPackages.forEach(pkg => {
|
|
108
|
-
const
|
|
109
|
-
resolveAliases[pkg] =
|
|
160
|
+
const resolved = resolveIntegratedPackagePath(pkg)
|
|
161
|
+
resolveAliases[pkg] = resolved
|
|
110
162
|
})
|
|
111
163
|
|
|
112
164
|
export {resolveAliases}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"react": "19.2.0",
|
|
39
39
|
"react-dom": "19.2.0",
|
|
40
40
|
"react-hook-form": "7.66.0",
|
|
41
|
-
"
|
|
41
|
+
"react-router": "7.9.5",
|
|
42
|
+
"react-use": "17.6.0",
|
|
42
43
|
"tailwindcss": "4.1.17",
|
|
43
44
|
"validator": "13.15.23",
|
|
44
45
|
"vite": "7.2.2",
|