Skip to content

Commit

Permalink
Only use string of the remote/web/package.json browser field (#16…
Browse files Browse the repository at this point in the history
…5163)

fix(build): Close #165162, only use string of the package.json `browser` field
  • Loading branch information
yiliang114 authored Nov 8, 2022
1 parent 57a5507 commit 59faab4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion build/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ 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 = packageData.browser ?? packageData.main;
// Only cases where the browser is a string are handled
let entryPoint = 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) {
// TODO @lramos15 remove this when jschardet adds an entrypoint so we can warn on all packages w/out entrypoint
Expand Down
3 changes: 2 additions & 1 deletion build/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 59faab4

Please sign in to comment.