Skip to content

Commit 743ff07

Browse files
Adding es folder and es output js file
1 parent c50be7f commit 743ff07

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ samples/node/secrets.json
2222
samples/browser/src/secrets.js
2323
samples/browser/src/graph-js-sdk-core.js
2424
samples/browser/src/graph-js-sdk-web.js
25+
samples/browser/src/graph-es-sdk.js
2526

2627
spec/**/*.js
2728
spec/**/*.d.ts

browser-wrapper-es.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* -------------------------------------------------------------------------------------------
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4+
* See License in the project root for license information.
5+
* -------------------------------------------------------------------------------------------
6+
*/
7+
8+
/**
9+
* Adds exports in index.js to the MicrosoftGraph property in window object
10+
*/
11+
window.MicrosoftGraph = require("./lib/es/browser/index.js");

browserify-es.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* -------------------------------------------------------------------------------------------
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4+
* See License in the project root for license information.
5+
* -------------------------------------------------------------------------------------------
6+
*/
7+
8+
/**
9+
* Initializes browserify, adds a wrapper file and outputs the browserified file
10+
*/
11+
const Browserify = require("browserify");
12+
const browserify = Browserify();
13+
browserify.add("./browser-wrapper-es.js");
14+
browserify.exclude("isomorphic-fetch");
15+
browserify.exclude("es6-promise");
16+
browserify.bundle().pipe(process.stdout);

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "1.5.2",
55
"description": "Microsoft Graph Client Library",
66
"main": "lib/src/index.js",
7+
"module": "lib/es/index.js",
78
"typings": "lib/src/index",
89
"files": [
910
"lib/"
@@ -31,11 +32,13 @@
3132
"uglify-es": "^3.3.9"
3233
},
3334
"scripts": {
34-
"compile": "tsc",
3535
"web:js": "node browserify-with-dependencies.js > lib/graph-js-sdk-web.js && uglifyjs ./lib/graph-js-sdk-web.js --output ./lib/graph-js-sdk-web.js",
3636
"core:js": "node browserify.js > lib/graph-js-sdk-core.js && uglifyjs ./lib/graph-js-sdk-core.js --output ./lib/graph-js-sdk-core.js",
37-
"build": "npm run compile && npm run web:js && npm run core:js",
38-
"test": "npm run compile && mocha lib/spec/content && mocha lib/spec/core && mocha lib/spec/middleware && mocha lib/spec/tasks",
37+
"es:js": "node browserify-es.js > lib/graph-es-sdk.js && uglifyjs ./lib/graph-es-sdk.js --output ./lib/graph-es-sdk.js",
38+
"build:es": "tsc --p tsconfig-es.json && npm run es:js",
39+
"build:js": "tsc && npm run web:js && npm run core:js",
40+
"build": "npm run build:js && npm run build:es",
41+
"test": "tsc && mocha lib/spec/content && mocha lib/spec/core && mocha lib/spec/middleware && mocha lib/spec/tasks",
3942
"test:content": "tsc -p spec && mocha spec/content",
4043
"test:core": "tsc -p spec && mocha spec/core",
4144
"test:middleware": "tsc -p spec && mocha spec/middleware",

tsconfig-es.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"noEmitOnError": true,
5+
"noImplicitAny": false,
6+
"moduleResolution": "node",
7+
"importHelpers": true,
8+
"removeComments": false,
9+
"sourceMap": true,
10+
"target": "esnext",
11+
"lib": ["dom", "esnext"],
12+
"declaration": true,
13+
"outDir": "lib/es"
14+
},
15+
"exclude": ["node_modules", "lib", "samples", "spec/**"],
16+
"include": ["./src/**/*.ts"]
17+
}

0 commit comments

Comments
 (0)