Skip to content

Commit

Permalink
add umd build
Browse files Browse the repository at this point in the history
  • Loading branch information
awmleer committed Sep 18, 2019
1 parent 5f25f21 commit 8873fc5
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 13 deletions.
24 changes: 21 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
const gulp = require('gulp')
const del = require('del')
const rollupConfig = require('./rollup.config')
const rollup = require('rollup')
const ts = require('gulp-typescript')

gulp.task('clean-lib', function (callback) {
const tsProject = ts.createProject('tsconfig.json')

gulp.task('clean-lib', function(callback) {
del('lib/**')
callback()
})

gulp.task('prebuild', gulp.series('clean-lib', function() {
gulp.task('copy-files', function() {
return gulp
.src(['package.json', 'README.md', 'LICENSE'])
.pipe(gulp.dest('lib/'))
}))
})

gulp.task('ts', function(callback) {
return tsProject.src()
.pipe(tsProject())
.pipe(gulp.dest('lib'))
})

gulp.task('rollup', async function(callback) {
const bundle = await rollup.rollup(rollupConfig)
return await bundle.write(rollupConfig.output)
})

gulp.task('build', gulp.series('clean-lib', 'copy-files', 'ts', 'rollup'))
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reto",
"version": "0.3.1",
"version": "0.4.0",
"main": "index.js",
"repository": "https://github.com/awmleer/reto",
"description": "React store with hooks.",
Expand All @@ -11,9 +11,10 @@
"react": "^16.8.0"
},
"scripts": {
"build": "gulp prebuild && tsc",
"build": "gulp build",
"test": "jest",
"lint": "tslint -p tsconfig.json"
"lint": "tslint -p tsconfig.json",
"umd": "rollup --config rollup.config.js"
},
"devDependencies": {
"@testing-library/jest-dom": "^4.0.0",
Expand All @@ -25,10 +26,12 @@
"@types/react-test-renderer": "^16.8.0",
"del": "^5.0.0",
"gulp": "^4.0.2",
"gulp-typescript": "^5.0.1",
"jest": "^24.1.0",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"react-test-renderer": "^16.8.0",
"rollup": "^1.21.4",
"ts-jest": "^24.0.2",
"tslint": "^5.18.0",
"typescript": "^3.4.5"
Expand Down
15 changes: 15 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
external: [
'react',
'reflect-metadata',
],
input: 'lib/index.js',
output: {
name: 'reto',
globals: {
react: 'React'
},
file: 'lib/umd/reto.js',
format: 'umd'
}
}
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"sourceMap": false,
"declaration": true,
"noImplicitAny": true,
"target": "es5",
"module": "commonjs",
"target": "es6",
"module": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
"jsx": "react",
"lib": ["es6"],
"outDir": "./lib"
Expand Down
84 changes: 79 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@
dependencies:
"@babel/types" "^7.3.0"

"@types/[email protected]":
version "0.0.39"
resolved "https://registry.npm.taobao.org/@types/estree/download/@types/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
integrity sha1-4Xfmme4bjCLSMXTKqnQiZEOJUJ8=

"@types/events@*":
version "3.0.0"
resolved "https://registry.npm.taobao.org/@types/events/download/@types/events-3.0.0.tgz?cache=0&sync_timestamp=1567532284800&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fevents%2Fdownload%2F%40types%2Fevents-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
Expand Down Expand Up @@ -443,7 +448,7 @@
resolved "https://registry.npm.taobao.org/@types/minimatch/download/@types/minimatch-3.0.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fminimatch%2Fdownload%2F%40types%2Fminimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha1-PcoOPzOyAPx9ETnAzZbBJoyt/Z0=

"@types/node@*":
"@types/node@*", "@types/node@^12.7.5":
version "12.7.5"
resolved "https://registry.npm.taobao.org/@types/node/download/@types/node-12.7.5.tgz#e19436e7f8e9b4601005d73673b6dc4784ffcc2f"
integrity sha1-4ZQ25/jptGAQBdc2c7bcR4T/zC8=
Expand Down Expand Up @@ -530,6 +535,11 @@ acorn@^6.0.1:
resolved "https://registry.npm.taobao.org/acorn/download/acorn-6.3.0.tgz#0087509119ffa4fc0a0041d1e93a417e68cb856e"
integrity sha1-AIdQkRn/pPwKAEHR6TpBfmjLhW4=

acorn@^7.0.0:
version "7.0.0"
resolved "https://registry.npm.taobao.org/acorn/download/acorn-7.0.0.tgz#26b8d1cd9a9b700350b71c0905546f64d1284e7a"
integrity sha1-JrjRzZqbcANQtxwJBVRvZNEoTno=

aggregate-error@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/aggregate-error/download/aggregate-error-3.0.0.tgz#5b5a3c95e9095f311c9ab16c19fb4f3527cd3f79"
Expand All @@ -555,6 +565,11 @@ ansi-colors@^1.0.1:
dependencies:
ansi-wrap "^0.1.0"

ansi-colors@^3.0.5:
version "3.2.4"
resolved "https://registry.npm.taobao.org/ansi-colors/download/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf"
integrity sha1-46PaS/uubIapwoViXeEkojQCb78=

ansi-escapes@^3.0.0:
version "3.2.0"
resolved "https://registry.npm.taobao.org/ansi-escapes/download/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b"
Expand Down Expand Up @@ -2022,6 +2037,18 @@ gulp-cli@^2.2.0:
v8flags "^3.0.1"
yargs "^7.1.0"

gulp-typescript@^5.0.1:
version "5.0.1"
resolved "https://registry.npm.taobao.org/gulp-typescript/download/gulp-typescript-5.0.1.tgz#96c6565a6eb31e08c2aae1c857b1a079e6226d94"
integrity sha1-lsZWWm6zHgjCquHIV7GgeeYibZQ=
dependencies:
ansi-colors "^3.0.5"
plugin-error "^1.0.1"
source-map "^0.7.3"
through2 "^3.0.0"
vinyl "^2.1.0"
vinyl-fs "^3.0.3"

gulp@^4.0.2:
version "4.0.2"
resolved "https://registry.npm.taobao.org/gulp/download/gulp-4.0.2.tgz#543651070fd0f6ab0a0650c6a3e6ff5a7cb09caa"
Expand Down Expand Up @@ -3802,6 +3829,16 @@ pkg-dir@^3.0.0:
dependencies:
find-up "^3.0.0"

plugin-error@^1.0.1:
version "1.0.1"
resolved "https://registry.npm.taobao.org/plugin-error/download/plugin-error-1.0.1.tgz#77016bd8919d0ac377fdcdd0322328953ca5781c"
integrity sha1-dwFr2JGdCsN3/c3QMiMolTyleBw=
dependencies:
ansi-colors "^1.0.1"
arr-diff "^4.0.0"
arr-union "^3.1.0"
extend-shallow "^3.0.2"

pn@^1.1.0:
version "1.1.0"
resolved "https://registry.npm.taobao.org/pn/download/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
Expand Down Expand Up @@ -3977,6 +4014,15 @@ read-pkg@^3.0.0:
normalize-package-data "^2.3.2"
path-type "^3.0.0"

"readable-stream@2 || 3":
version "3.4.0"
resolved "https://registry.npm.taobao.org/readable-stream/download/readable-stream-3.4.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freadable-stream%2Fdownload%2Freadable-stream-3.4.0.tgz#a51c26754658e0a3c21dbf59163bd45ba6f447fc"
integrity sha1-pRwmdUZY4KPCHb9ZFjvUW6b0R/w=
dependencies:
inherits "^2.0.3"
string_decoder "^1.1.1"
util-deprecate "^1.0.1"

readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.6:
version "2.3.6"
resolved "https://registry.npm.taobao.org/readable-stream/download/readable-stream-2.3.6.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freadable-stream%2Fdownload%2Freadable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
Expand Down Expand Up @@ -4210,6 +4256,15 @@ rimraf@^3.0.0:
dependencies:
glob "^7.1.3"

rollup@^1.21.4:
version "1.21.4"
resolved "https://registry.npm.taobao.org/rollup/download/rollup-1.21.4.tgz#00a41a30f90095db890301b226cbe2918e4cf54d"
integrity sha1-AKQaMPkAlduJAwGyJsvikY5M9U0=
dependencies:
"@types/estree" "0.0.39"
"@types/node" "^12.7.5"
acorn "^7.0.0"

rsvp@^4.8.4:
version "4.8.5"
resolved "https://registry.npm.taobao.org/rsvp/download/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
Expand All @@ -4220,7 +4275,7 @@ run-parallel@^1.1.9:
resolved "https://registry.npm.taobao.org/run-parallel/download/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679"
integrity sha1-yd06fPn0ssS2JE4XOm7YZuYd1nk=

safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2:
safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@~5.2.0:
version "5.2.0"
resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.0.tgz?cache=0&sync_timestamp=1562377642757&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsafe-buffer%2Fdownload%2Fsafe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519"
integrity sha1-t02uxJsRSPiMZLaNSbHoFcHy9Rk=
Expand Down Expand Up @@ -4403,6 +4458,11 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha1-dHIq8y6WFOnCh6jQu95IteLxomM=

source-map@^0.7.3:
version "0.7.3"
resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha1-UwL4FpAxc1ImVECS5kmB91F1A4M=

sparkles@^1.0.0:
version "1.0.1"
resolved "https://registry.npm.taobao.org/sparkles/download/sparkles-1.0.1.tgz#008db65edce6c50eec0c5e228e1945061dd0437c"
Expand Down Expand Up @@ -4544,6 +4604,13 @@ string.prototype.trimright@^2.0.0:
define-properties "^1.1.3"
function-bind "^1.1.1"

string_decoder@^1.1.1:
version "1.3.0"
resolved "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e"
integrity sha1-QvEUWUpGzxqOMLCoT1bHjD7awh4=
dependencies:
safe-buffer "~5.2.0"

string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
Expand Down Expand Up @@ -4672,6 +4739,13 @@ through2@^2.0.0, through2@^2.0.3, through2@~2.0.0:
readable-stream "~2.3.6"
xtend "~4.0.1"

through2@^3.0.0:
version "3.0.1"
resolved "https://registry.npm.taobao.org/through2/download/through2-3.0.1.tgz#39276e713c3302edf9e388dd9c812dd3b825bd5a"
integrity sha1-OSducTwzAu3544jdnIEt07glvVo=
dependencies:
readable-stream "2 || 3"

time-stamp@^1.0.0:
version "1.1.0"
resolved "https://registry.npm.taobao.org/time-stamp/download/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3"
Expand Down Expand Up @@ -4923,7 +4997,7 @@ use@^3.1.0:
resolved "https://registry.npm.taobao.org/use/download/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
integrity sha1-1QyMrHmhn7wg8pEfVuuXP04QBw8=

util-deprecate@~1.0.1:
util-deprecate@^1.0.1, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.npm.taobao.org/util-deprecate/download/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
Expand Down Expand Up @@ -4970,7 +5044,7 @@ [email protected]:
core-util-is "1.0.2"
extsprintf "^1.2.0"

vinyl-fs@^3.0.0:
vinyl-fs@^3.0.0, vinyl-fs@^3.0.3:
version "3.0.3"
resolved "https://registry.npm.taobao.org/vinyl-fs/download/vinyl-fs-3.0.3.tgz#c85849405f67428feabbbd5c5dbdd64f47d31bc7"
integrity sha1-yFhJQF9nQo/qu71cXb3WT0fTG8c=
Expand Down Expand Up @@ -5006,7 +5080,7 @@ vinyl-sourcemap@^1.1.0:
remove-bom-buffer "^3.0.0"
vinyl "^2.0.0"

vinyl@^2.0.0:
vinyl@^2.0.0, vinyl@^2.1.0:
version "2.2.0"
resolved "https://registry.npm.taobao.org/vinyl/download/vinyl-2.2.0.tgz#d85b07da96e458d25b2ffe19fece9f2caa13ed86"
integrity sha1-2FsH2pbkWNJbL/4Z/s6fLKoT7YY=
Expand Down

0 comments on commit 8873fc5

Please sign in to comment.