Only use string of the remote/web/package.json browser field (#165163)

fix(build): Close #165162, only use string of the package.json `browser` field
This commit is contained in:
易良
2022-11-08 23:30:02 +08:00
committed by GitHub
parent 57a5507e0b
commit 59faab44cd
2 changed files with 4 additions and 2 deletions

View File

@@ -371,7 +371,8 @@ export function acquireWebNodePaths() {
for (const key of Object.keys(webPackages)) {
const packageJSON = path.join(root, 'node_modules', key, 'package.json');
const packageData = JSON.parse(fs.readFileSync(packageJSON, 'utf8'));
let entryPoint: string = packageData.browser ?? packageData.main;
// Only cases where the browser is a string are handled
let entryPoint: string = typeof packageData.browser === 'string' ? packageData.browser : packageData.main;
// On rare cases a package doesn't have an entrypoint so we assume it has a dist folder with a min.js
if (!entryPoint) {