From 432bf07785d051f61c90904cb0198ec2b2bf1d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 17 May 2018 15:37:17 +0200 Subject: [PATCH] Build UMD dist file with Rollup --- .gitignore | 1 + Makefile | 5 ++++- package.json | 6 +++++- rollup.config.js | 8 ++++++++ test/test.html | 2 +- test/worker.js | 2 +- 6 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 rollup.config.js diff --git a/.gitignore b/.gitignore index d65f9407..69b0a491 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .env package-lock.json +dist/ bower_components/ node_modules/ sauce_connect/ diff --git a/Makefile b/Makefile index 4372e5a2..3d3f2e72 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ -test: node_modules/ lint +test: lint dist/fetch.umd.js ./script/test lint: node_modules/ ./node_modules/.bin/eslint --report-unused-disable-directives *.js test/*.js +dist/fetch.umd.js: fetch.js rollup.config.js node_modules/ + ./node_modules/.bin/rollup -c + node_modules/: npm install diff --git a/package.json b/package.json index b056d01e..5b1d9ab9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "whatwg-fetch", "description": "A window.fetch polyfill.", "version": "2.0.3", - "main": "fetch.js", + "main": "./dist/fetch.umd.js", + "module": "./fetch.js", "repository": "github/fetch", "license": "MIT", "devDependencies": { @@ -12,13 +13,16 @@ "mocha": "2.1.0", "mocha-phantomjs-core": "2.0.1", "promise-polyfill": "6.0.2", + "rollup": "^0.59.1", "url-search-params": "0.6.1" }, "files": [ "LICENSE", + "dist/fetch.umd.js", "fetch.js" ], "scripts": { + "prepublish": "make dist/fetch.umd.js", "test": "make" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 00000000..d4297335 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,8 @@ +export default { + input: 'fetch.js', + output: { + file: 'dist/fetch.umd.js', + format: 'umd', + name: 'WHATWGFetch' + } +} diff --git a/test/test.html b/test/test.html index 8a1e48f1..338a191f 100644 --- a/test/test.html +++ b/test/test.html @@ -34,7 +34,7 @@ - +