From 52043f5b702aca699f62abf8054582286e258ba5 Mon Sep 17 00:00:00 2001 From: jgravois Date: Fri, 2 Mar 2018 17:21:21 -0800 Subject: [PATCH] feat(all packages): start shipping an unminified UMD for each package AFFECTS PACKAGES: @esri/arcgis-rest-auth @esri/arcgis-rest-feature-service @esri/arcgis-rest-geocoder @esri/arcgis-rest-groups @esri/arcgis-rest-items @esri/arcgis-rest-request ISSUES CLOSED: #135 --- packages/arcgis-rest-auth/package.json | 2 +- packages/arcgis-rest-feature-service/package.json | 2 +- packages/arcgis-rest-geocoder/package.json | 2 +- packages/arcgis-rest-groups/package.json | 2 +- packages/arcgis-rest-items/package.json | 2 +- packages/arcgis-rest-request/package.json | 2 +- rollup.config.umd.js => umd-base-profile.js | 14 +++++--------- umd-production-profile.js | 14 ++++++++++++++ 8 files changed, 25 insertions(+), 15 deletions(-) rename rollup.config.umd.js => umd-base-profile.js (86%) create mode 100644 umd-production-profile.js diff --git a/packages/arcgis-rest-auth/package.json b/packages/arcgis-rest-auth/package.json index ec2ba01710..98c29d465e 100644 --- a/packages/arcgis-rest-auth/package.json +++ b/packages/arcgis-rest-auth/package.json @@ -23,7 +23,7 @@ "prebuild": "rimraf dist", "build": "npm run build:node && npm run build:umd && npm run build:esm", "build:esm": "tsc --module es2015 --outDir ./dist/esm --declaration", - "build:umd": "rollup -c ../../rollup.config.umd.js", + "build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js", "build:node": "tsc --module commonjs --outDir ./dist/node" }, "publishConfig": { diff --git a/packages/arcgis-rest-feature-service/package.json b/packages/arcgis-rest-feature-service/package.json index 8b309598ff..320323dd50 100644 --- a/packages/arcgis-rest-feature-service/package.json +++ b/packages/arcgis-rest-feature-service/package.json @@ -24,7 +24,7 @@ "prepare": "npm run build", "build": "npm run build:node && npm run build:umd && npm run build:esm", "build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration", - "build:umd": "rollup -c ../../rollup.config.umd.js", + "build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js", "build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node" }, "publishConfig": { diff --git a/packages/arcgis-rest-geocoder/package.json b/packages/arcgis-rest-geocoder/package.json index ec3debb17b..6b3cc0a832 100644 --- a/packages/arcgis-rest-geocoder/package.json +++ b/packages/arcgis-rest-geocoder/package.json @@ -26,7 +26,7 @@ "prepare": "npm run build", "build": "npm run build:node && npm run build:umd && npm run build:esm", "build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration", - "build:umd": "rollup -c ../../rollup.config.umd.js", + "build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js", "build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node" }, "publishConfig": { diff --git a/packages/arcgis-rest-groups/package.json b/packages/arcgis-rest-groups/package.json index f99501c79e..a217b21daa 100644 --- a/packages/arcgis-rest-groups/package.json +++ b/packages/arcgis-rest-groups/package.json @@ -26,7 +26,7 @@ "prepare": "npm run build", "build": "npm run build:node && npm run build:umd && npm run build:esm", "build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration", - "build:umd": "rollup -c ../../rollup.config.umd.js", + "build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js", "build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node" }, "publishConfig": { diff --git a/packages/arcgis-rest-items/package.json b/packages/arcgis-rest-items/package.json index a3729caef9..d1c753c143 100644 --- a/packages/arcgis-rest-items/package.json +++ b/packages/arcgis-rest-items/package.json @@ -26,7 +26,7 @@ "prepare": "npm run build", "build": "npm run build:node && npm run build:umd && npm run build:esm", "build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration", - "build:umd": "rollup -c ../../rollup.config.umd.js", + "build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js", "build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node" }, "publishConfig": { diff --git a/packages/arcgis-rest-request/package.json b/packages/arcgis-rest-request/package.json index 468cf1d639..ac0b4fbe23 100644 --- a/packages/arcgis-rest-request/package.json +++ b/packages/arcgis-rest-request/package.json @@ -16,7 +16,7 @@ "prepare": "npm run build", "build": "npm run build:node && npm run build:umd && npm run build:esm", "build:esm": "tsc --module es2015 --outDir ./dist/esm --declaration", - "build:umd": "rollup -c ../../rollup.config.umd.js", + "build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js", "build:node": "tsc --module commonjs --outDir ./dist/node" }, "publishConfig": { diff --git a/rollup.config.umd.js b/umd-base-profile.js similarity index 86% rename from rollup.config.umd.js rename to umd-base-profile.js index 7e740ee129..0d7470ccd8 100644 --- a/rollup.config.umd.js +++ b/umd-base-profile.js @@ -2,8 +2,6 @@ import typescript from "rollup-plugin-typescript2"; import resolve from "rollup-plugin-node-resolve"; import commonjs from "rollup-plugin-commonjs"; import json from "rollup-plugin-json"; -import uglify from "rollup-plugin-uglify"; -import filesize from "rollup-plugin-filesize"; const path = require("path"); const fs = require("fs"); @@ -60,23 +58,21 @@ const globals = packageNames.reduce((globals, p) => { */ export default { input: "./src/index.ts", - output: [{ - file: `./dist/umd/${name.replace("@esri/", "")}.umd.js`, - sourcemap: `./dist/umd/${name.replace("@esri/", "")}.umd.js.map`, + output: { + file: `./dist/umd/${name.replace("@esri/", "")}.debug.umd.js`, + sourcemap: `./dist/umd/${name.replace("@esri/", "")}.debug.umd.js.map`, banner: copyright, format: "umd", name: moduleName, globals, extend: true // causes this module to extend the global specified by `moduleName` - }], + }, context: "window", external: packageNames, plugins: [ typescript(), json(), resolve(), - commonjs(), - uglify({ output: {comments: /Institute, Inc/} }), - filesize() + commonjs() ] }; diff --git a/umd-production-profile.js b/umd-production-profile.js new file mode 100644 index 0000000000..196a8fd19d --- /dev/null +++ b/umd-production-profile.js @@ -0,0 +1,14 @@ +import config from './umd-base-profile.js'; +import uglify from "rollup-plugin-uglify"; +import filesize from "rollup-plugin-filesize"; + +// remove 'debug' from the unminified UMD filename and sourcemap +config.output.file = config.output.file.replace(".debug.umd.", ".umd."); +config.output.sourcemap = config.output.sourcemap.replace(".debug.umd.", ".umd."); + +config.plugins.push(filesize()) +config.plugins.push(uglify({ + output: {comments: /Institute, Inc/} +})) + +export default config; \ No newline at end of file