File tree Expand file tree Collapse file tree 7 files changed +448
-51
lines changed
packages/js-web-sdk/packages/js-web-sdk Expand file tree Collapse file tree 7 files changed +448
-51
lines changed Original file line number Diff line number Diff line change 1
1
dist
2
2
coverage
3
3
.nyc_output
4
+ .rpt2_cache
Original file line number Diff line number Diff line change 5
5
"author" : " Jordan Garcia <jordan@optimizely.com>" ,
6
6
"homepage" : " " ,
7
7
"license" : " ISC" ,
8
- "main" : " lib/index.js" ,
8
+ "main" : " dist/js-web-sdk.js" ,
9
+ "module" : " dist/js-web-sdk.mjs" ,
9
10
"typings" : " lib/index.d.ts" ,
10
11
"directories" : {
11
12
"lib" : " lib" ,
15
16
"tsc" : " tsc" ,
16
17
"test" : " karma start karma.conf.js --single-run" ,
17
18
"test:watch" : " karma start karma.conf.js" ,
18
- "build-browser-umd " : " rm -rf dist && webpack " ,
19
+ "build" : " rm -rf dist/ && node ./scripts/build.js " ,
19
20
"cover" : " nyc mocha test/**" ,
20
21
"coveralls" : " npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls" ,
21
22
"prepublishOnly" : " npm run build-browser-umd && npm test && npm run test-xbrowser"
38
39
"mocha-lcov-reporter" : " ^1.3.0" ,
39
40
"nyc" : " ^13.1.0" ,
40
41
"puppeteer" : " ^1.11.0" ,
42
+ "rollup" : " ^1.1.2" ,
43
+ "rollup-plugin-commonjs" : " ^9.2.0" ,
44
+ "rollup-plugin-node-resolve" : " ^4.0.0" ,
45
+ "rollup-plugin-replace" : " ^2.1.0" ,
46
+ "rollup-plugin-typescript2" : " ^0.19.2" ,
47
+ "rollup-plugin-uglify" : " ^6.0.1" ,
41
48
"sinon" : " ^7.2.3" ,
42
49
"ts-loader" : " ^5.3.3" ,
43
50
"typescript" : " ^3.1.6" ,
Original file line number Diff line number Diff line change
1
+ const fs = require ( "fs" ) ;
2
+ const path = require ( "path" ) ;
3
+ const execSync = require ( "child_process" ) . execSync ;
4
+
5
+ process . chdir ( path . resolve ( __dirname , ".." ) ) ;
6
+
7
+ function exec ( command , extraEnv ) {
8
+ return execSync ( command , {
9
+ stdio : "inherit" ,
10
+ env : Object . assign ( { } , process . env , extraEnv )
11
+ } ) ;
12
+ }
13
+
14
+ const packageName = 'js-web-sdk' ;
15
+ const umdName = 'jsWebSdk'
16
+
17
+ console . log ( "\nBuilding ES modules..." ) ;
18
+
19
+ exec ( `./node_modules/.bin/rollup -c scripts/config.js -f es -o dist/${ packageName } .mjs` ) ;
20
+
21
+ console . log ( "\nBuilding CommonJS modules..." ) ;
22
+
23
+ exec ( `./node_modules/.bin/rollup -c scripts/config.js -f cjs -o dist/${ packageName } .js` ) ;
24
+
25
+ console . log ( "\nBuilding UMD modules..." ) ;
26
+
27
+
28
+ exec (
29
+ `./node_modules/.bin/rollup -c scripts/config.js -f umd -n ${ umdName } -o dist/${ packageName } .browser.umd.js` ,
30
+ {
31
+ EXTERNALS : "peers" ,
32
+ BUILD_ENV : "development"
33
+ }
34
+ ) ;
35
+
36
+ exec (
37
+ `./node_modules/.bin/rollup -c scripts/config.js -f umd -n ${ umdName } -o dist/${ packageName } .browser.umd.min.js` ,
38
+ {
39
+ EXTERNALS : "peers" ,
40
+ BUILD_ENV : "production"
41
+ }
42
+ ) ;
Original file line number Diff line number Diff line change
1
+ const typescript = require ( "rollup-plugin-typescript2" ) ;
2
+ const commonjs = require ( "rollup-plugin-commonjs" ) ;
3
+ const replace = require ( "rollup-plugin-replace" ) ;
4
+ const resolve = require ( "rollup-plugin-node-resolve" ) ;
5
+ const { uglify } = require ( "rollup-plugin-uglify" ) ;
6
+
7
+ const packageDeps = require ( "../package.json" ) . dependencies || { } ;
8
+ const packagePeers = require ( "../package.json" ) . peerDependencies || { } ;
9
+
10
+ function getExternals ( externals ) {
11
+ return externals === "peers"
12
+ ? Object . keys ( packagePeers )
13
+ : Object . keys ( packageDeps ) . concat ( Object . keys ( packagePeers ) ) ;
14
+ }
15
+
16
+ function getPlugins ( env ) {
17
+ const plugins = [ resolve ( { browser : true } ) ] ;
18
+
19
+ if ( env ) {
20
+ plugins . push (
21
+ replace ( {
22
+ "process.env.NODE_ENV" : JSON . stringify ( env )
23
+ } )
24
+ ) ;
25
+ }
26
+
27
+ plugins . push (
28
+ typescript ( ) ,
29
+ commonjs ( {
30
+ include : / n o d e _ m o d u l e s /
31
+ } )
32
+ ) ;
33
+
34
+ if ( env === "production" ) {
35
+ plugins . push ( uglify ( ) ) ;
36
+ }
37
+
38
+ return plugins ;
39
+ }
40
+
41
+ const config = {
42
+ input : "src/index.ts" ,
43
+ external : getExternals ( process . env . EXTERNALS ) ,
44
+ plugins : getPlugins ( process . env . BUILD_ENV )
45
+ } ;
46
+
47
+ module . exports = config ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"extends" : " ../../tsconfig.json" ,
3
3
"compilerOptions" : {
4
+ "module" : " ES2015" ,
4
5
"outDir" : " ./lib"
5
6
},
6
7
"include" : [
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments