-
Notifications
You must be signed in to change notification settings - Fork 233
Nikithauc/publish doc #396
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| ##### This design document focuses on the following - | ||
| 1. Separate entry points for node and browser. | ||
| 2. Specifying the browser field in package.json. | ||
| 3. Changes in the bundling process. | ||
|
|
||
| ##### Terms - | ||
|
|
||
| * bundler - Module bundlers are tools frontend developers used to bundle JavaScript modules into a single JavaScript files that can be executed in the browser. | ||
|
|
||
| * rollup - rollup.js is the module bundler that the JS SDK uses. | ||
|
|
||
| * package.json fields - | ||
| * main - The main field is a module ID that is the primary entry point to your program. Points to the CJS modules. | ||
|
|
||
| * module - The module field is not an official npm feature but a common convention among bundlers to designate how to import an ESM version of a library. Points to the ES modules. | ||
|
|
||
| * browser - If the module is meant to be used client-side, the browser field should be used instead of the main field. | ||
|
|
||
| ##### Current set up - | ||
|
|
||
| 1. | ||
| TypeScript Source Code | ||
| / \ | ||
| Transpiles into JavaScript | ||
| 'lib' folder | ||
| / \ | ||
| CJS module ES modules | ||
| 2. main - `lib/src/index.js` | ||
| module - `lib/es/src/index.js` | ||
|
|
||
| 3. Rollup bundling output | ||
| * `graph-js-sdk.js` - Bundled and minified file in IIFE format. This file can be directly used in the browser with a `<script>` tag. | ||
| * `graph-es-sdk.js` - Bundled file in ES format. | ||
| 4. Entry point for rollup - `lib/es/src/browser/index.js`. | ||
|
|
||
| ##### Difference between src/index.js and src/browser/index.js | ||
| 1. `src/browser/index.js` does not export `RedirectHandler` and `RedirectHandlerOptions`. Redirection is handled by the browser. | ||
| 2. `src/browser/index.js` exports `src/browser/ImplicitMsalProvider`. | ||
| 3. `src/browser/ImplicitMsalProvider` does not import or require 'msal' dependency. While, | ||
| `src/ImplicitMsalProvider` imports or requires 'msal' in the implementation. | ||
| 4. My assumtion is that `src/browser/ImplicitMsalProvider` is implemented specifically for the rollup process and to skip the rollup external dependency while using `graph-js-sdk.js` in the browser. | ||
|
|
||
| Note - Browser applications using the ES modules from the npm package of the JS SDK refer to the `module` entry point - `lib/es/src/index.js`(not the browser entry point). Example - Graph Explorer. | ||
|
|
||
| ##### Upcoming changes - | ||
|
|
||
| 1. Use the browser field for the following - | ||
|
|
||
| * The Graph JS SDK currently has two entry files, `src/index` and `src/browser/index`. | ||
| Use the browser field to indicate the browser entry point. | ||
| Example - | ||
| ```json | ||
| "browser": | ||
| { "lib/es/src/index.js": "lib/es/src/browser/index.js" } | ||
baywet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
| Currently, the main and "module field in the package.json. This will remain the same. | ||
| * Better way to handle environment specific implementation. For example, using the `browser` field as follows - | ||
| "browser": | ||
| ```json | ||
| { | ||
| "stream": "stream-browserify", | ||
| "Feature-Node.js": "Feature-Browser.js" | ||
| } | ||
| ``` | ||
|
|
||
| 2. Remove export of `src/browser/ImplicitMsalProvider` from `src/browser/index`. | ||
| * Till `ImplicitMsalProvider` is maintained in the repo, maintain a separate entry point say `rollup-index` for the rollup process which exports `src/browser/index` and `src/browser/ImplicitMsalProvider`. | ||
| * Continue rolling up the `src/browser/ImplicitMsalProvider` as it is currently done and not introduce breaking changes here as it is going to be deprecated. | ||
| * Remove the separate entry point once `ImplicitMsalProvider` is removed and use the browser entry point for roll up thereafter. The goal is to maintain a consistent entry point or usage for browser applications using the JS SDK and the rollup/bundling process. | ||
|
|
||
| 3. Bundle the authproviders separately as they are optional. | ||
baywet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 4. Stop bundling in ES format, that is remove `graph-es-sdk.js` as the ES modules are being shipped. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.