Skip to content

Commit

Permalink
feat(package): add rollup for build
Browse files Browse the repository at this point in the history
BREAKING CHANGE: add umd, cjs and es builds
  • Loading branch information
damusnet committed Apr 26, 2018
1 parent 8b9faf1 commit 319db5f
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
catalog/build
dist
coverage
node_modules
package-lock.json
yarn.lock
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"react/jsx-filename-extension": ["error", { "extensions": [".js"] }],
"import/no-extraneous-dependencies": [
"error",
{ "devDependencies": ["**/*.spec.js", "catalog/**/*"] }
{ "devDependencies": ["**/*.spec.js", "catalog/**/*", "config/**/*"] }
]
},
"globals": {
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.github
catalog
config
coverage
Expand Down
38 changes: 38 additions & 0 deletions config/rollup.dev.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import resolve from "rollup-plugin-node-resolve";
import babel from "rollup-plugin-babel";

export default {
input: "src/index.js",
output: [
{
file: "dist/index.umd.js",
format: "umd",
sourcemap: true,
name: "TicketmasterPrism",
globals: {
react: "React",
"prop-types": "PropTypes",
"styled-components": "styled"
}
},
{
file: "dist/index.cjs.js",
format: "cjs",
sourcemap: true
},
{
file: "dist/index.es.js",
format: "es",
sourcemap: true
}
],
plugins: [
resolve(),
babel({
presets: [["env", { modules: false }], "react"],
plugins: ["transform-object-rest-spread"],
babelrc: false
})
],
external: ["react", "prop-types", "styled-components"]
};
39 changes: 39 additions & 0 deletions config/rollup.prod.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import resolve from "rollup-plugin-node-resolve";
import babel from "rollup-plugin-babel";
import stripPropTypes from "rollup-plugin-strip-prop-types";
import uglify from "rollup-plugin-uglify";

export default {
input: "src/index.js",
output: [
{
file: "dist/index.umd.min.js",
format: "umd",
name: "TicketmasterPrism",
globals: {
react: "React",
"prop-types": "PropTypes",
"styled-components": "styled"
}
},
{
file: "dist/index.cjs.min.js",
format: "cjs"
},
{
file: "dist/index.es.min.js",
format: "es"
}
],
plugins: [
resolve(),
babel({
presets: [["env", { modules: false }], "react"],
plugins: ["transform-object-rest-spread"],
babelrc: false
}),
stripPropTypes({ sourceMap: false }),
uglify()
],
external: ["react", "prop-types", "styled-components"]
};
33 changes: 30 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@
"name": "@ticketmaster/prism",
"version": "0.0.0-semantically-released",
"description": "Shared UI Library for Ticketmaster",
"main": "dist/index.js",
"keywords": [
"react",
"styled-components",
"design-system",
"ui-library",
"ticketmaster"
],
"main": "dist/index.cjs.js",
"jsnext:main": "dist/index.es.js",
"module": "dist/index.es.js",
"files": ["dist"],
"engines": { "node": "> 8", "npm": "> 5" },
"license": "MIT",
"scripts": {
"build": "babel ./src --out-dir ./dist --ignore '__*__'",
"build": "npm run build:dev && npm run build:prod",
"build:dev": "rollup -c config/rollup.dev.config.js",
"build:prod": "rollup -c config/rollup.prod.config.js",
"catalog-start": "catalog start",
"catalog-build": "catalog build -u \"/prism\"",
"lint": "eslint \"{src,catalog}/**/*.{js,jsx}\"",
Expand All @@ -25,7 +38,15 @@
},
"jest": {
"setupTestFrameworkScriptFile": "./config/jest.config.js",
"collectCoverageFrom": ["src/**/*.js"]
"collectCoverageFrom": ["src/**/*.js"],
"coverageThreshold": {
"global": {
"branches": 80,
"functions": 80,
"lines": 80,
"statements": 80
}
}
},
"peerDependencies": {
"prop-types": ">=15",
Expand Down Expand Up @@ -56,8 +77,14 @@
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-test-renderer": "^16.3.2",
"rollup": "^0.58.2",
"rollup-plugin-babel": "^3.0.4",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-strip-prop-types": "^1.0.2",
"rollup-plugin-uglify": "^3.0.0",
"styled-components": "^3.2.6"
},
"homepage": "https://code.ticketmaster.com/prism/",
"repository": {
"type": "git",
"url": "https://github.com/Ticketmaster/prism.git"
Expand Down

0 comments on commit 319db5f

Please sign in to comment.