Skip to content

Commit 29a3421

Browse files
committed
fix(app-vite): correctly get path for ESM only packages without a "main" field #17880
1 parent 95a3608 commit 29a3421

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

app-vite/lib/utils/get-package-path.js

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { createRequire } from 'node:module'
2+
import { resolvePathSync } from 'mlly'
23

4+
/**
5+
* Eventually replace by the native import.meta.resolve() method
6+
* when it is out of "experimental" status with no node flags required.
7+
*/
38
const require = createRequire(import.meta.url)
49

510
/**
@@ -11,6 +16,13 @@ export function getPackagePath (pkgName, dir) {
1116
process.exit(1)
1217
}
1318

19+
try {
20+
return resolvePathSync(pkgName, { url: dir })
21+
}
22+
catch (_) {
23+
/* do nothing, let the next method try as well */
24+
}
25+
1426
try {
1527
return require.resolve(pkgName, {
1628
paths: [ dir ]

app-vite/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"kolorist": "^1.8.0",
110110
"lodash": "^4.17.21",
111111
"minimist": "^1.2.8",
112+
"mlly": "^1.7.4",
112113
"open": "^10.1.0",
113114
"rollup-plugin-visualizer": "^5.13.1",
114115
"sass-embedded": "^1.83.0",

pnpm-lock.yaml

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)