Skip to content

Use browser field in package.json, remove graph-es-sdk.js file. #394

@nikithauc

Description

@nikithauc

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 -

  1. 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.
  1. 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.

  1. 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.js as we are shipping the ES modules. Currently, the entry points for the bundled graph-es-sdk.js file and the ES modules are different. We should have one source for the ES modules and the user can bundle as per their requirement.

AB#8194

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions