diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..7464ec0ca --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +catalog/build +dist +coverage +node_modules +package-lock.json +yarn.lock diff --git a/.eslintrc.json b/.eslintrc.json index 7e3fbe5ae..2a66ca2f4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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": { diff --git a/.npmignore b/.npmignore index ab590e127..9994219e0 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,4 @@ +.github catalog config coverage diff --git a/config/rollup.dev.config.js b/config/rollup.dev.config.js new file mode 100644 index 000000000..ab8666fa0 --- /dev/null +++ b/config/rollup.dev.config.js @@ -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"] +}; diff --git a/config/rollup.prod.config.js b/config/rollup.prod.config.js new file mode 100644 index 000000000..baa83281e --- /dev/null +++ b/config/rollup.prod.config.js @@ -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"] +}; diff --git a/package.json b/package.json index 25b1040ab..c2a1bd46c 100644 --- a/package.json +++ b/package.json @@ -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}\"", @@ -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", @@ -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"