-
Notifications
You must be signed in to change notification settings - Fork 233
Closed
Description
The browser field is provided by a module author as a hint to javascript bundlers or component tools when packaging modules for client side use. The field is found in a package.json file (described here) usually located at the root of a project source tree.
https://github.com/defunctzombie/package-browser-field-spec
https://docs.npmjs.com/cli/v7/configuring-npm/package-json#browser
msgraph-sdk-javascript is an isomorphic library.
Use the browser field for the following -
- We currently have two entry files, src/index.ts and src/browser/index.ts.
- Use the browser field to indicate the browser entry point.
Example -
"browser":
{ "lib/es/index.node.js": "lib/es/index.browser.js" }
- Currently, we have only "module": "lib/es/index.js" in the package.json. This will remain the same.
- Better way to handle environment specific implementation. For example, using the browser field we can indicate as follows -
"browser":
{ "lib/es/featureNode.js": "lib/es/featureBrowser.js" }
The browser specific implementation should be exported in the browser entry point.
- We currently use rollup.js to bundle our library into IIFE and ES formats for browser use. The src/browser/index.ts is the entry point for rollup.js
- The process of bundling library in IIFE format should continue with some updates.
- I suggest we can remove the
graph-es-sdk.jsas we are shipping the ES modules. Currently, the entry points for the bundledgraph-es-sdk.jsfile and the ES modules are different. We should have one source for the ES modules and the user can bundle as per their requirement.