1
Fork 0

typescript(option): build: edited the rollup config to read paths from package.json and show the filesize of the esm bundle

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-26 18:13:37 +02:00 committed by prescientmoon
parent 63ce76a552
commit b02a3f887f
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
5 changed files with 125 additions and 9 deletions

View file

@ -41,7 +41,7 @@ Both limitaions bellow come from the lack of nominal-typing offered by TypeScrip
npm install @adrielus/option npm install @adrielus/option
``` ```
(There is also an amd build at `/dist/bundle.amd.js` which uses the `Option` namespace) (There is also an amd build at `/dist/bundle.umd.js` which uses the `Option` namespace)
## Usage ## Usage

View file

@ -5,6 +5,7 @@
"main": "dist/bundle.cjs.js", "main": "dist/bundle.cjs.js",
"module": "dist/index.esm.js", "module": "dist/index.esm.js",
"typings": "dist/index.esm.d.ts", "typings": "dist/index.esm.d.ts",
"browser": "dist/bundle.umd.js",
"scripts": { "scripts": {
"prebuild": "rimraf dist", "prebuild": "rimraf dist",
"build": "rollup -c rollup.config.ts", "build": "rollup -c rollup.config.ts",
@ -50,6 +51,7 @@
"mocha": "^6.2.2", "mocha": "^6.2.2",
"rimraf": "^3.0.0", "rimraf": "^3.0.0",
"rollup": "^1.27.14", "rollup": "^1.27.14",
"rollup-plugin-filesize": "^6.2.1",
"rollup-plugin-terser": "^5.1.3", "rollup-plugin-terser": "^5.1.3",
"semantic-release": "^15.14.0", "semantic-release": "^15.14.0",
"sinon": "^8.0.1", "sinon": "^8.0.1",

View file

@ -13,6 +13,7 @@ devDependencies:
mocha: 6.2.2 mocha: 6.2.2
rimraf: 3.0.0 rimraf: 3.0.0
rollup: 1.27.14 rollup: 1.27.14
rollup-plugin-filesize: 6.2.1
rollup-plugin-terser: 5.1.3_rollup@1.27.14 rollup-plugin-terser: 5.1.3_rollup@1.27.14
semantic-release: 15.14.0_semantic-release@15.14.0 semantic-release: 15.14.0_semantic-release@15.14.0
sinon: 8.0.1 sinon: 8.0.1
@ -1174,6 +1175,12 @@ packages:
node: '>=8' node: '>=8'
resolution: resolution:
integrity: sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA== integrity: sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==
/ansi-align/3.0.0:
dependencies:
string-width: 3.1.0
dev: true
resolution:
integrity: sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw==
/ansi-colors/3.2.3: /ansi-colors/3.2.3:
dev: true dev: true
engines: engines:
@ -1291,6 +1298,21 @@ packages:
dev: true dev: true
resolution: resolution:
integrity: sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw== integrity: sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==
/boxen/4.2.0:
dependencies:
ansi-align: 3.0.0
camelcase: 5.3.1
chalk: 3.0.0
cli-boxes: 2.2.0
string-width: 4.2.0
term-size: 2.1.1
type-fest: 0.8.1
widest-line: 3.1.0
dev: true
engines:
node: '>=8'
resolution:
integrity: sha512-eB4uT9RGzg2odpER62bBwSLvUeGC+WbRjjyyFhGsKnc8wp/m0+hQsMUvUe3H2V0D5vw0nBdO1hCJoZo5mKeuIQ==
/brace-expansion/1.1.11: /brace-expansion/1.1.11:
dependencies: dependencies:
balanced-match: 1.0.0 balanced-match: 1.0.0
@ -1306,6 +1328,14 @@ packages:
node: '>=8' node: '>=8'
resolution: resolution:
integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
/brotli-size/4.0.0:
dependencies:
duplexer: 0.1.1
dev: true
engines:
node: '>= 10.16.0'
resolution:
integrity: sha512-uA9fOtlTRC0iqKfzff1W34DXUA3GyVqbUaeo3Rw3d4gd1eavKVCETXrn3NzO74W+UVkG3UHu8WxUi+XvKI/huA==
/browser-stdout/1.3.1: /browser-stdout/1.3.1:
dev: true dev: true
resolution: resolution:
@ -1405,6 +1435,15 @@ packages:
node: '>=4' node: '>=4'
resolution: resolution:
integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
/chalk/3.0.0:
dependencies:
ansi-styles: 4.2.0
supports-color: 7.1.0
dev: true
engines:
node: '>=8'
resolution:
integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
/check-error/1.0.2: /check-error/1.0.2:
dev: true dev: true
resolution: resolution:
@ -1415,6 +1454,12 @@ packages:
node: '>=6' node: '>=6'
resolution: resolution:
integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==
/cli-boxes/2.2.0:
dev: true
engines:
node: '>=6'
resolution:
integrity: sha512-gpaBrMAizVEANOpfZp/EEUixTXDyGt7DFzdK5hU+UbWt/J0lB0w20ncZj59Z9a93xHb9u12zF5BS6i9RKbtg4w==
/cli-table/0.3.1: /cli-table/0.3.1:
dependencies: dependencies:
colors: 1.0.3 colors: 1.0.3
@ -1467,6 +1512,12 @@ packages:
node: '>=0.1.90' node: '>=0.1.90'
resolution: resolution:
integrity: sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs= integrity: sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=
/colors/1.4.0:
dev: true
engines:
node: '>=0.1.90'
resolution:
integrity: sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==
/commander/2.20.3: /commander/2.20.3:
dev: true dev: true
resolution: resolution:
@ -1689,6 +1740,10 @@ packages:
node: '>=0.10.0' node: '>=0.10.0'
resolution: resolution:
integrity: sha1-G3CK8JSknJoOfbyteQq6U52sEXc= integrity: sha1-G3CK8JSknJoOfbyteQq6U52sEXc=
/duplexer/0.1.1:
dev: true
resolution:
integrity: sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=
/duplexer2/0.1.4: /duplexer2/0.1.4:
dependencies: dependencies:
readable-stream: 2.3.6 readable-stream: 2.3.6
@ -1858,6 +1913,12 @@ packages:
node: '>=8' node: '>=8'
resolution: resolution:
integrity: sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg== integrity: sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==
/filesize/4.2.1:
dev: true
engines:
node: '>= 0.4.0'
resolution:
integrity: sha512-bP82Hi8VRZX/TUBKfE24iiUGsB/sfm2WUrwTQyAzQrhO3V9IhcBBNBXMyzLY5orACxRyYJ3d2HeRVX+eFv4lmA==
/fill-range/7.0.1: /fill-range/7.0.1:
dependencies: dependencies:
to-regex-range: 5.0.1 to-regex-range: 5.0.1
@ -2029,6 +2090,15 @@ packages:
node: '>=4.x' node: '>=4.x'
resolution: resolution:
integrity: sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== integrity: sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==
/gzip-size/5.1.1:
dependencies:
duplexer: 0.1.1
pify: 4.0.1
dev: true
engines:
node: '>=6'
resolution:
integrity: sha512-FNHi6mmoHvs1mxZAds4PpdCS6QG8B4C1krxJsMutgxl5t3+GlRTzzI3NEkifXx2pVsOvJdOGSmIgDhQ55FwdPA==
/handlebars/4.5.3: /handlebars/4.5.3:
dependencies: dependencies:
neo-async: 2.6.1 neo-async: 2.6.1
@ -2477,6 +2547,10 @@ packages:
dev: true dev: true
resolution: resolution:
integrity: sha1-1SfftUVuynzJu5XV2ur4i6VKVFE= integrity: sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=
/lodash.merge/4.6.2:
dev: true
resolution:
integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
/lodash.set/4.3.2: /lodash.set/4.3.2:
dev: true dev: true
resolution: resolution:
@ -3196,6 +3270,12 @@ packages:
node: '>=4' node: '>=4'
resolution: resolution:
integrity: sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= integrity: sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=
/pify/4.0.1:
dev: true
engines:
node: '>=6'
resolution:
integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==
/pkg-conf/2.1.0: /pkg-conf/2.1.0:
dependencies: dependencies:
find-up: 2.1.0 find-up: 2.1.0
@ -3425,6 +3505,18 @@ packages:
hasBin: true hasBin: true
resolution: resolution:
integrity: sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg== integrity: sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg==
/rollup-plugin-filesize/6.2.1:
dependencies:
boxen: 4.2.0
brotli-size: 4.0.0
colors: 1.4.0
filesize: 4.2.1
gzip-size: 5.1.1
lodash.merge: 4.6.2
terser: 4.4.3
dev: true
resolution:
integrity: sha512-JQ2+NMoka81lCR2caGWyngqMKpvJCl7EkFYU7A+T0dA7U1Aml13FW5Ky0aiZIeU3/13cjsKQLRr35SQVmk6i/A==
/rollup-plugin-terser/5.1.3_rollup@1.27.14: /rollup-plugin-terser/5.1.3_rollup@1.27.14:
dependencies: dependencies:
'@babel/code-frame': 7.5.5 '@babel/code-frame': 7.5.5
@ -3838,6 +3930,12 @@ packages:
node: '>=8' node: '>=8'
resolution: resolution:
integrity: sha512-WrH/pui8YCwmeiAoxV+lpRH9HpRtgBhSR2ViBPgpGb/wnYDzp21R4MN45fsCGvLROvY67o3byhJRYRONJyImVQ== integrity: sha512-WrH/pui8YCwmeiAoxV+lpRH9HpRtgBhSR2ViBPgpGb/wnYDzp21R4MN45fsCGvLROvY67o3byhJRYRONJyImVQ==
/term-size/2.1.1:
dev: true
engines:
node: '>=8'
resolution:
integrity: sha512-UqvQSch04R+69g4RDhrslmGvGL3ucDRX/U+snYW0Mab4uCAyKSndUksaoqlJ81QKSpRnIsuOYQCbC2ZWx2896A==
/terser/4.4.3: /terser/4.4.3:
dependencies: dependencies:
commander: 2.20.3 commander: 2.20.3
@ -4061,6 +4159,14 @@ packages:
dev: true dev: true
resolution: resolution:
integrity: sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== integrity: sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==
/widest-line/3.1.0:
dependencies:
string-width: 4.2.0
dev: true
engines:
node: '>=8'
resolution:
integrity: sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==
/windows-release/3.2.0: /windows-release/3.2.0:
dependencies: dependencies:
execa: 1.0.0 execa: 1.0.0
@ -4201,6 +4307,7 @@ specifiers:
mocha: ^6.2.2 mocha: ^6.2.2
rimraf: ^3.0.0 rimraf: ^3.0.0
rollup: ^1.27.14 rollup: ^1.27.14
rollup-plugin-filesize: ^6.2.1
rollup-plugin-terser: ^5.1.3 rollup-plugin-terser: ^5.1.3
semantic-release: ^15.14.0 semantic-release: ^15.14.0
sinon: ^8.0.1 sinon: ^8.0.1

View file

@ -3,27 +3,29 @@ import { resolve } from 'path'
import ts from '@wessberg/rollup-plugin-ts' import ts from '@wessberg/rollup-plugin-ts'
import nodeResolve from '@rollup/plugin-node-resolve' import nodeResolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs' import commonjs from '@rollup/plugin-commonjs'
import _package from './package.json'
import filesize from 'rollup-plugin-filesize'
const outputDirectory = resolve(__dirname, 'dist') const outputDirectory = resolve(__dirname, 'dist')
const inputFile = resolve(__dirname, 'src/index.ts') const inputFile = resolve(__dirname, 'src/index.ts')
const dev = Boolean(process.env.ROLLUP_WATCH) const dev = Boolean(process.env.ROLLUP_WATCH)
const commonPlugins = [commonjs(), nodeResolve()] const commonPlugins = [nodeResolve(), commonjs()]
export default [ export default [
{ {
input: inputFile, input: inputFile,
output: [ output: [
{ {
file: `${outputDirectory}/index.cjs.js`, file: _package.main,
format: 'cjs', format: 'cjs',
sourcemap: true sourcemap: true
}, },
{ {
file: `${outputDirectory}/index.amd.js`, file: _package.browser,
sourcemap: true, sourcemap: true,
format: 'amd', format: 'umd',
name: 'Option' name: 'Option'
} }
], ],
@ -33,7 +35,7 @@ export default [
input: inputFile, input: inputFile,
output: [ output: [
{ {
file: `${outputDirectory}/index.esm.js`, file: _package.module,
format: 'esm', format: 'esm',
sourcemap: true sourcemap: true
} }
@ -48,7 +50,10 @@ export default [
] ]
} }
}), }),
!dev && terser() !dev && terser(),
filesize({
showBrotliSize: true
})
] ]
} }
] ]

View file

@ -6,8 +6,10 @@
"strictNullChecks": true, "strictNullChecks": true,
"sourceMap": true, "sourceMap": true,
"downlevelIteration": true, "downlevelIteration": true,
"target": "es6" "target": "es6",
"resolveJsonModule": true
}, },
"include": ["src", "sandbox", "test"], "include": ["src", "sandbox", "test", "package.json"],
"exclude": ["dist"] "exclude": ["dist"]
} }