From c740a0c7af3ad2bb717e63b0cdcd9769ce9ec07b Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 6 Mar 2020 14:19:15 -0700 Subject: [PATCH] Github action for size tracking, better imports and building --- .github/_workflows/ci.yml | 27 ---------------- .github/size-plugin.yml | 3 -- .github/workflows/size-comments.yml | 15 +++++++++ .size-snapshot.json | 40 ----------------------- index.js | 5 +++ package.json | 3 +- rollup.config.js | 50 +++++++++++++---------------- sizes-cjs.json | 12 ------- sizes-es.json | 12 ------- 9 files changed, 43 insertions(+), 124 deletions(-) delete mode 100644 .github/_workflows/ci.yml delete mode 100644 .github/size-plugin.yml create mode 100644 .github/workflows/size-comments.yml delete mode 100644 .size-snapshot.json create mode 100644 index.js delete mode 100644 sizes-cjs.json delete mode 100644 sizes-es.json diff --git a/.github/_workflows/ci.yml b/.github/_workflows/ci.yml deleted file mode 100644 index df6b0e0..0000000 --- a/.github/_workflows/ci.yml +++ /dev/null @@ -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 diff --git a/.github/size-plugin.yml b/.github/size-plugin.yml deleted file mode 100644 index de41898..0000000 --- a/.github/size-plugin.yml +++ /dev/null @@ -1,3 +0,0 @@ -size-files: - - sizes-cjs.json - - sizes-es.json diff --git a/.github/workflows/size-comments.yml b/.github/workflows/size-comments.yml new file mode 100644 index 0000000..5bb07f0 --- /dev/null +++ b/.github/workflows/size-comments.yml @@ -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 }}' diff --git a/.size-snapshot.json b/.size-snapshot.json deleted file mode 100644 index 4f29fdb..0000000 --- a/.size-snapshot.json +++ /dev/null @@ -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 - } - } - } -} diff --git a/index.js b/index.js new file mode 100644 index 0000000..08b295b --- /dev/null +++ b/index.js @@ -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') +} diff --git a/package.json b/package.json index e48597c..891063e 100644 --- a/package.json +++ b/package.json @@ -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\"", diff --git a/rollup.config.js b/rollup.config.js index 9b5f88f..8213c0f 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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(), ], }, ] diff --git a/sizes-cjs.json b/sizes-cjs.json deleted file mode 100644 index 76bd0d1..0000000 --- a/sizes-cjs.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "timestamp": 1582926304566, - "files": [ - { - "filename": "index.js", - "size": 26303, - "delta": 30 - } - ] - } -] \ No newline at end of file diff --git a/sizes-es.json b/sizes-es.json deleted file mode 100644 index eb7686a..0000000 --- a/sizes-es.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "timestamp": 1582926312489, - "files": [ - { - "filename": "index.es.js", - "size": 26094, - "delta": 30 - } - ] - } -] \ No newline at end of file