Skip to content

Commit

Permalink
Move all build tasks to Rollup (#306)
Browse files Browse the repository at this point in the history
* Move all build tasks to Rollup

* Run tests before publishing

* Add check task running tsc
  • Loading branch information
kitten authored and andyrichardson committed Jun 18, 2019
1 parent 2e34a5b commit b4f62a9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .sail.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ workflow:
- install
- sail:parallel:
- build
- check
- lint
- test
- e2e
Expand Down Expand Up @@ -36,6 +37,12 @@ tasks:
- yarn
args:
- build
check:
image: node:10
command:
- yarn
args:
- check
e2e:
image: cypress/browsers:node10.2.1-chrome74
command:
Expand Down
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
"exchanges"
],
"scripts": {
"prebuild": "rimraf dist",
"build": "run-p build:types build:bundle",
"build:clean": "rimraf dist",
"build:types": "tsc -d --emitDeclarationOnly --outDir dist/types",
"build:bundle": "rollup -c rollup.config.js",
"build:prune": "rimraf dist/types/**/*.test.d.ts dist/types/test-utils",
"clean": "rimraf ./dist ./node_modules/.cache",
"build": "rollup -c rollup.config.js",
"watch": "rollup -w -c rollup.config.js",
"check": "tsc --noEmit",
"test": "jest",
"coverage": "jest --coverage",
"lint": "eslint . --ext .ts,.tsx",
"check-formatting": "prettier --write src/**/*.{ts,tsx}",
"prepublishOnly": "run-s build build:prune",
"prepublishOnly": "run-s clean test build",
"codecov": "codecov"
},
"author": "Formidable",
Expand Down
22 changes: 15 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const terserMinified = terser({
}
});

const plugins = [
const makePlugins = (isProduction = false) => [
nodeResolve({
mainFields: ['module', 'jsnext', 'main'],
browser: true
Expand All @@ -84,14 +84,21 @@ const plugins = [
typescript({
typescript: require('typescript'),
cacheRoot: './node_modules/.cache/.rts2_cache',
useTsconfigDeclarationDir: true,
tsconfigDefaults: {
compilerOptions: {
sourceMap: true,
declaration: true
sourceMap: true
},
},
tsconfigOverride: {
compilerOptions: {
exclude: [
'src/**/*.test.ts',
'src/**/*.test.tsx',
'src/**/test-utils/*'
],
compilerOptions: {
declaration: !isProduction,
declarationDir: './dist/types/',
target: 'es6',
},
},
Expand Down Expand Up @@ -123,7 +130,8 @@ const plugins = [
externalHelpers: true
}]
]
})
}),
isProduction ? terserMinified : terserPretty
];

const config = {
Expand All @@ -137,7 +145,7 @@ const config = {
export default [
{
...config,
plugins: [...plugins, terserPretty],
plugins: makePlugins(false),
output: [
{
sourcemap: true,
Expand All @@ -158,7 +166,7 @@ export default [
]
}, {
...config,
plugins: [...plugins, terserMinified],
plugins: makePlugins(true),
output: [
{
sourcemap: true,
Expand Down

0 comments on commit b4f62a9

Please sign in to comment.