From 1b837f2e2100714c68cf915c86ccd5c2985e5c8f Mon Sep 17 00:00:00 2001 From: Jason Staten Date: Fri, 6 Dec 2019 10:31:54 -0700 Subject: [PATCH] fix(build): Remove kcd-scripts BREAKING CHANGE: Node >= 10 support. No more UMD builds. --- .eslintrc.js | 21 +++++++++++++ .gitignore | 2 +- babel.config.js | 10 +++++++ jest.config.js | 6 ---- package.json | 76 +++++++++++++++++++++++++++++------------------- rollup.config.js | 17 +++++++++++ 6 files changed, 95 insertions(+), 37 deletions(-) create mode 100644 .eslintrc.js create mode 100644 babel.config.js delete mode 100644 jest.config.js create mode 100644 rollup.config.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..b397eaf --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,21 @@ +module.exports = { + env: { + node: true, + browser: true, + es6: true, + jest: true, + }, + extends: ['eslint:recommended'], + parser: 'babel-eslint', + rules: { + 'linebreak-style': ['error', 'unix'], + 'no-console': ['error', {allow: ['warn', 'error']}], + 'no-shadow': 'error', + 'no-duplicate-imports': 'error', + 'no-var': 'error', + 'prefer-const': 'error', + 'object-shorthand': 'error', + 'no-useless-rename': 'error', + 'no-use-before-define': ['error', {functions: false}], + }, +} diff --git a/.gitignore b/.gitignore index 5bb9fac..7ac65ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ node_modules coverage -dist +lib .opt-in .opt-out .DS_Store diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..55b3e29 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,10 @@ +module.exports = { + env: { + test: { + plugins: [ + '@babel/plugin-transform-modules-commonjs', + '@babel/plugin-proposal-class-properties', + ], + }, + }, +} diff --git a/jest.config.js b/jest.config.js deleted file mode 100644 index 57494f4..0000000 --- a/jest.config.js +++ /dev/null @@ -1,6 +0,0 @@ -const config = require('kcd-scripts/jest') - -module.exports = { - ...config, - testEnvironment: 'jsdom', -} diff --git a/package.json b/package.json index b7bc947..df84583 100644 --- a/package.json +++ b/package.json @@ -2,33 +2,48 @@ "name": "angularjs-testing-library", "version": "0.0.0-semantic-release", "description": "Simple and complete AngularJS testing utilities that encourage good testing practices.", - "main": "dist/index.js", - "module": "dist/angularjs-testing-library.esm.js", + "main": "lib/index.js", + "module": "lib/angularjs-testing-library.mjs", "engines": { - "node": ">=8" + "node": ">=10" }, "scripts": { - "prebuild": "rimraf dist", - "build": "npm-run-all --parallel build:main build:bundle:main build:bundle:pure", - "build:main": "kcd-scripts build --no-clean", - "build:bundle:main": "kcd-scripts build --bundle --no-clean", - "build:bundle:pure": "cross-env BUILD_FILENAME_SUFFIX=.pure BUILD_INPUT=src/pure.js kcd-scripts build --bundle --no-clean", - "lint": "kcd-scripts lint", - "test": "kcd-scripts test", - "test:update": "npm test -- --updateSnapshot --coverage", - "validate": "kcd-scripts validate", - "setup": "npm install && npm run validate -s" + "prebuild": "rimraf lib", + "build": "rollup -c", + "lint": "eslint --cache .", + "test": "jest", + "validate": "concurrently yarn:validate:*", + "validate:lnt": "yarn --silent lint", + "validate:bld": "yarn --silent build", + "validate:tst": "yarn --silent test" }, "husky": { "hooks": { - "pre-commit": "kcd-scripts pre-commit" + "pre-commit": "lint-staged" } }, + "lint-staged": { + "*.{js}": [ + "prettier --write", + "eslint", + "git add" + ], + "*.{json,css,md}": [ + "prettier --write", + "git add" + ], + "README.md": [ + "doctoc --maxlevel 3 --notitle" + ] + }, + "jest": { + "setupFilesAfterEnv": [ + "@testing-library/jest-dom/extend-expect" + ] + }, "files": [ - "dist", - "cleanup-after-each.js", - "dont-cleanup-after-each.js", - "pure.js" + "lib", + "dont-cleanup-after-each.js" ], "keywords": [ "testing", @@ -48,35 +63,36 @@ ], "license": "MIT", "dependencies": { - "@babel/runtime": "^7.6.0", "@testing-library/dom": "^6.3.0" }, "devDependencies": { + "@babel/core": "^7.7.5", + "@babel/plugin-proposal-class-properties": "^7.7.4", + "@babel/plugin-transform-modules-commonjs": "^7.7.5", "@semantic-release/git": "^7.0.17", "@testing-library/jest-dom": "^4.1.0", "angular": "^1.7.8", "angular-mocks": "^1.7.8", - "cross-env": "^6.0.0", - "kcd-scripts": "^1.7.0", - "npm-run-all": "^4.1.5", + "babel-eslint": "^10.0.3", + "babel-jest": "^24.9.0", + "concurrently": "^5.0.0", + "doctoc": "^1.4.0", + "eslint": "^6.7.2", + "husky": "^3.1.0", + "jest-cli": "^24.9.0", + "lint-staged": "^9.5.0", "rimraf": "^3.0.0", + "rollup": "^1.27.8", "semantic-release": "^15.13.30" }, "peerDependencies": { "angular": "*", "angular-mocks": "*" }, - "eslintConfig": { - "extends": "./node_modules/kcd-scripts/eslint.js", - "rules": { - "import/no-unassigned-import": "off", - "import/named": "off" - } - }, "eslintIgnore": [ "node_modules", "coverage", - "dist", + "lib", "*.d.ts" ], "repository": { diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..154eab4 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,17 @@ +import * as pkg from './package.json' + +const pkgDependencies = Object.keys({ + ...pkg.dependencies, + ...pkg.devDependencies, + ...pkg.peerDependencies, + ...pkg.optionalDependencies, +}) + +export default { + input: 'src/index', + output: [ + {file: pkg.main, format: 'cjs', sourcemap: true}, + {file: pkg.module, format: 'es', sourcemap: true}, + ], + external: [...pkgDependencies], +}