Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added browser field as hint for JS bundlers #589

Merged
merged 1 commit into from
Mar 8, 2022
Merged

Added browser field as hint for JS bundlers #589

merged 1 commit into from
Mar 8, 2022

Conversation

nickedelenbos
Copy link
Contributor

Some JS bundlers prefer to have a specific browser key in the package.json file, in order to bundle files efficiently (as can be read at https://github.com/defunctzombie/package-browser-field-spec). This PR adds the browser/float16.js as main entry point in that field

@petamoriken
Copy link
Owner

IMHO, browser field is outdated and I recommend to use src directory for bundlers for tree shaking. Maybe modern bundlers use import field instead. Please show me which bundler uses browser field efficiently.

@nickedelenbos
Copy link
Contributor Author

@petamoriken
Copy link
Owner

@nickedelenbos

I didn't know liferay-npm-bundler.

Liferay NPM bundler does this; https://help.liferay.com/hc/en-us/articles/360017880812-Configuring-liferay-npm-bundler

I couldn't find about browser field in package.json from this document. Please tell me problems that this PR will solve specially.

@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #589 (751c34b) into master (8d48c8c) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #589   +/-   ##
=======================================
  Coverage   88.03%   88.03%           
=======================================
  Files          12       12           
  Lines         727      727           
  Branches      137      137           
=======================================
  Hits          640      640           
  Misses         43       43           
  Partials       44       44           
Flag Coverage Δ
unittests 88.03% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 24ddcc8...751c34b. Read the comment docs.

@petamoriken petamoriken force-pushed the master branch 6 times, most recently from dbf9c15 to b061fcc Compare February 11, 2022 05:58
@nickedelenbos
Copy link
Contributor Author

@petamoriken By default applications will look, as specified in https://docs.npmjs.com/cli/v8/configuring-npm/package-json#main, to the main key in the package.json. This main fields points to CommonJS modules, typically used in server side libraries. My PR proposes to add a browser field, which is typically used by client-side (browser) applications to resolve the library.

@petamoriken
Copy link
Owner

Make sense.

@petamoriken petamoriken merged commit 15e924c into petamoriken:master Mar 8, 2022
@nickedelenbos nickedelenbos deleted the patch-1 branch July 25, 2022 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants