Skip to content

Commit 59faab4

Browse files
authored
Only use string of the remote/web/package.json browser field (microsoft#165163)
fix(build): Close microsoft#165162, only use string of the package.json `browser` field
1 parent 57a5507 commit 59faab4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

build/lib/util.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ function acquireWebNodePaths() {
302302
for (const key of Object.keys(webPackages)) {
303303
const packageJSON = path.join(root, 'node_modules', key, 'package.json');
304304
const packageData = JSON.parse(fs.readFileSync(packageJSON, 'utf8'));
305-
let entryPoint = packageData.browser ?? packageData.main;
305+
// Only cases where the browser is a string are handled
306+
let entryPoint = typeof packageData.browser === 'string' ? packageData.browser : packageData.main;
306307
// On rare cases a package doesn't have an entrypoint so we assume it has a dist folder with a min.js
307308
if (!entryPoint) {
308309
// TODO @lramos15 remove this when jschardet adds an entrypoint so we can warn on all packages w/out entrypoint

build/lib/util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ export function acquireWebNodePaths() {
371371
for (const key of Object.keys(webPackages)) {
372372
const packageJSON = path.join(root, 'node_modules', key, 'package.json');
373373
const packageData = JSON.parse(fs.readFileSync(packageJSON, 'utf8'));
374-
let entryPoint: string = packageData.browser ?? packageData.main;
374+
// Only cases where the browser is a string are handled
375+
let entryPoint: string = typeof packageData.browser === 'string' ? packageData.browser : packageData.main;
375376

376377
// On rare cases a package doesn't have an entrypoint so we assume it has a dist folder with a min.js
377378
if (!entryPoint) {

0 commit comments

Comments
 (0)