Skip to content

Commit

Permalink
chore: use rollup to decrease build size
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-oles committed May 9, 2020
1 parent 19c74ed commit 2f81cc4
Show file tree
Hide file tree
Showing 12 changed files with 312 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ $RECYCLE.BIN/

# Artifacts
lib
dist
coverage
*.tsbuildinfo

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"scripts": {
"postinstall": "lerna bootstrap",
"clean": "lerna run --parallel clean",
"dev": "lerna run --parallel dev",
"build": "lerna run build",
"release": "auto shipit -vv",
"precommit": "lint-staged && yarn build && yarn test",
Expand Down Expand Up @@ -47,6 +46,8 @@
"@auto-it/conventional-commits": "^9.26.8",
"@auto-it/first-time-contributor": "^9.26.8",
"@commitlint/config-conventional": "^8.3.4",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@stryker-mutator/core": "^3.1.0",
"@stryker-mutator/jest-runner": "^3.1.0",
"@stryker-mutator/typescript": "^3.1.0",
Expand All @@ -55,6 +56,7 @@
"@typescript-eslint/parser": "^2.27.0",
"auto": "^9.26.8",
"commitlint": "^8.3.5",
"dts-bundle": "^0.7.3",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-prettier": "^3.1.2",
Expand All @@ -66,6 +68,7 @@
"lerna": "^3.20.2",
"lint-staged": "^10.1.3",
"prettier": "^2.0.4",
"rollup": "^2.8.2",
"ts-jest": "^25.3.1",
"typescript": "^3.8.3"
},
Expand Down
13 changes: 7 additions & 6 deletions packages/ast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
"author": "Piotr Oleś <piotrek.oles@gmail.com>",
"version": "0.0.0",
"sideEffects": false,
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.esm.js",
"browser": "dist/index.umd.js",
"files": [
"lib"
"dist"
],
"keywords": [
"rsql",
"fiql",
"ast"
],
"scripts": {
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo",
"compile": "tsc -b tsconfig.json",
"dev": "yarn compile --watch --preserveWatchOutput",
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo && rm -rf ./dist",
"compile": "tsc -b tsconfig.json && rollup -c && dts-bundle --name \"@rsql/ast\" --main lib/index.d.ts --out ../dist/index.d.ts",
"build": "yarn clean && yarn compile"
},
"engines": {
Expand Down
24 changes: 24 additions & 0 deletions packages/ast/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import pkg from "./package.json";

export default [
// browser-friendly UMD build
{
input: "lib/index.js",
output: {
name: "RSQLAst",
file: pkg.browser,
format: "umd",
},
plugins: [resolve(), commonjs()],
},
// CommonJS (for Node) and ES module (for bundlers) build.
{
input: "lib/index.js",
output: [
{ file: pkg.main, format: "cjs" },
{ file: pkg.module, format: "es" },
],
},
];
13 changes: 7 additions & 6 deletions packages/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
"author": "Piotr Oleś <piotrek.oles@gmail.com>",
"version": "0.0.0",
"sideEffects": false,
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.esm.js",
"browser": "dist/index.umd.js",
"files": [
"lib"
"dist"
],
"keywords": [
"rsql",
"fiql",
"builder"
],
"scripts": {
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo",
"compile": "tsc -b tsconfig.json",
"dev": "yarn compile --watch --preserveWatchOutput",
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo && rm -rf ./dist",
"compile": "tsc -b tsconfig.json && rollup -c && dts-bundle --name \"@rsql/builder\" --main lib/index.d.ts --out ../dist/index.d.ts",
"build": "yarn clean && yarn compile"
},
"engines": {
Expand Down
25 changes: 25 additions & 0 deletions packages/builder/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import pkg from "./package.json";

export default [
// browser-friendly UMD build
{
input: "lib/index.js",
output: {
name: "RSQLBuilder",
file: pkg.browser,
format: "umd",
},
plugins: [resolve(), commonjs()],
},
// CommonJS (for Node) and ES module (for bundlers) build.
{
input: "lib/index.js",
external: Object.keys(pkg.dependencies),
output: [
{ file: pkg.main, format: "cjs" },
{ file: pkg.module, format: "es" },
],
},
];
13 changes: 7 additions & 6 deletions packages/emitter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
"author": "Piotr Oleś <piotrek.oles@gmail.com>",
"version": "0.0.0",
"sideEffects": false,
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.esm.js",
"browser": "dist/index.umd.js",
"files": [
"lib"
"dist"
],
"keywords": [
"rsql",
"fiql",
"emitter"
],
"scripts": {
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo",
"compile": "tsc -b tsconfig.json",
"dev": "yarn compile --watch --preserveWatchOutput",
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo && rm -rf ./dist",
"compile": "tsc -b tsconfig.json && rollup -c && dts-bundle --name \"@rsql/emitter\" --main lib/index.d.ts --out ../dist/index.d.ts",
"build": "yarn clean && yarn compile"
},
"engines": {
Expand Down
25 changes: 25 additions & 0 deletions packages/emitter/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import pkg from "./package.json";

export default [
// browser-friendly UMD build
{
input: "lib/index.js",
output: {
name: "RSQLEmitter",
file: pkg.browser,
format: "umd",
},
plugins: [resolve(), commonjs()],
},
// CommonJS (for Node) and ES module (for bundlers) build.
{
input: "lib/index.js",
external: Object.keys(pkg.dependencies),
output: [
{ file: pkg.main, format: "cjs" },
{ file: pkg.module, format: "es" },
],
},
];
13 changes: 7 additions & 6 deletions packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
"author": "Piotr Oleś <piotrek.oles@gmail.com>",
"version": "0.0.0",
"sideEffects": false,
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.esm.js",
"browser": "dist/index.umd.js",
"files": [
"lib"
"dist"
],
"keywords": [
"rsql",
"fiql",
"parser"
],
"scripts": {
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo",
"compile": "tsc -b tsconfig.json",
"dev": "yarn compile --watch --preserveWatchOutput",
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo && rm -rf ./dist",
"compile": "tsc -b tsconfig.json && rollup -c && dts-bundle --name \"@rsql/parser\" --main lib/index.d.ts --out ../dist/index.d.ts",
"build": "yarn clean && yarn compile"
},
"engines": {
Expand Down
25 changes: 25 additions & 0 deletions packages/parser/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import pkg from "./package.json";

export default [
// browser-friendly UMD build
{
input: "lib/index.js",
output: {
name: "RSQLParser",
file: pkg.browser,
format: "umd",
},
plugins: [resolve(), commonjs()],
},
// CommonJS (for Node) and ES module (for bundlers) build.
{
input: "lib/index.js",
external: Object.keys(pkg.dependencies),
output: [
{ file: pkg.main, format: "cjs" },
{ file: pkg.module, format: "es" },
],
},
];
9 changes: 4 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": ["es5", "scripthost"],
"moduleResolution": "node",
"target": "ES5",
"module": "ESNext",
"lib": ["ES5", "ScriptHost"],
"moduleResolution": "Node",
"esModuleInterop": true,
"importHelpers": false,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"strict": true,
"baseUrl": ".",
"composite": true,
"incremental": true,
"declaration": true
}
}
Loading

0 comments on commit 2f81cc4

Please sign in to comment.