Github action for size tracking, better imports and building

This commit is contained in:
Tanner Linsley 2020-03-06 14:19:15 -07:00
parent 48d6fcd60d
commit c740a0c7af
9 changed files with 43 additions and 124 deletions

View File

@ -1,27 +0,0 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build-and-test:
name: '${{ matrix.platform }}: node.js ${{ matrix.node-version }}'
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10, 12]
runs-on: ${{ matrix.platform }}
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set up Node.js
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}
- name: Build and test
run: |
yarn install
yarn test

View File

@ -1,3 +0,0 @@
size-files:
- sizes-cjs.json
- sizes-es.json

15
.github/workflows/size-comments.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Compressed Size
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2-beta
with:
fetch-depth: 1
- uses: preactjs/compressed-size-action@v1
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'

View File

@ -1,40 +0,0 @@
{
"dist/index.js": {
"bundled": 130947,
"minified": 61370,
"gzipped": 15740
},
"dist/index.es.js": {
"bundled": 130005,
"minified": 60529,
"gzipped": 15565,
"treeshaked": {
"rollup": {
"code": 80,
"import_statements": 21
},
"webpack": {
"code": 7611
}
}
},
"dist\\index.js": {
"bundled": 113237,
"minified": 52528,
"gzipped": 13837
},
"dist\\index.es.js": {
"bundled": 112300,
"minified": 51692,
"gzipped": 13671,
"treeshaked": {
"rollup": {
"code": 80,
"import_statements": 21
},
"webpack": {
"code": 8461
}
}
}
}

5
index.js Normal file
View File

@ -0,0 +1,5 @@
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/react-table.production.min.js')
} else {
module.exports = require('./dist/react-table.development.js')
}

View File

@ -14,8 +14,7 @@
"react-table",
"datagrid"
],
"main": "dist/index.js",
"module": "dist/index.es.js",
"main": "index.js",
"scripts": {
"commit": "git add . && git-cz",
"test": "is-ci \"test:ci\" \"test:dev\"",

View File

@ -1,50 +1,44 @@
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import external from 'rollup-plugin-peer-deps-external'
import resolve from 'rollup-plugin-node-resolve'
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
import { terser } from 'rollup-plugin-terser'
import size from 'rollup-plugin-size'
import pkg from './package.json'
import externalDeps from 'rollup-plugin-peer-deps-external'
const external = ['react']
const globals = {
react: 'React',
}
export default [
{
input: 'src/index.js',
output: {
file: pkg.main,
format: 'cjs',
name: 'ReactQuery',
file: 'dist/react-table.development.js',
format: 'umd',
sourcemap: true,
globals,
},
plugins: [
external(),
babel(),
resolve(),
commonjs(),
size({
publish: true,
exclude: pkg.module,
filename: 'sizes-cjs.json',
writeFile: process.env.CI ? true : false,
}),
sizeSnapshot(),
],
external,
plugins: [babel(), externalDeps()],
},
{
input: 'src/index.js',
output: {
file: pkg.module,
format: 'es',
name: 'ReactQuery',
file: 'dist/react-table.production.min.js',
format: 'umd',
sourcemap: true,
globals,
},
external,
plugins: [
external(),
babel(),
externalDeps(),
terser(),
size({
publish: true,
exclude: pkg.main,
filename: 'sizes-es.json',
writeFile: process.env.CI ? true : false,
writeFile: false,
}),
sizeSnapshot(),
],
},
]

View File

@ -1,12 +0,0 @@
[
{
"timestamp": 1582926304566,
"files": [
{
"filename": "index.js",
"size": 26303,
"delta": 30
}
]
}
]

View File

@ -1,12 +0,0 @@
[
{
"timestamp": 1582926312489,
"files": [
{
"filename": "index.es.js",
"size": 26094,
"delta": 30
}
]
}
]