Skip to content

Commit

Permalink
Change build system and update Jest (#747)
Browse files Browse the repository at this point in the history
<!--
Thanks for your interest in the project. I appreciate bugs filed and PRs submitted!

Please make sure that you are familiar with and follow the Code of Conduct for
this project (found in the CODE_OF_CONDUCT.md file).

Also, please make sure you're familiar with and follow the instructions in the
contributing guidelines (found in the CONTRIBUTING.md file).

If you're new to contributing to open source projects, you might find this free
video course helpful: http://kcd.im/pull-request

Please fill out the information below to expedite the review and (hopefully)
merge of your pull request!
-->

<!-- What changes are being made? (What feature/bug is being fixed here?) -->
**What**:
This changes the build system from some npm scripts to some node scripts that run rollup on every package. This is extracted from /~https://github.com/emotion-js/next

This also moves the site out of the packages folder into the root directory because I wanted to make the packages folder only contain packages that are published to npm. The benchmarks package was also moved to the new scripts folder for the same reason.
<!-- Why are these changes necessary? -->
**Why**:

- Faster builds since a new process doesn't need to be started for each build
- Everything runs through the same build system

<!-- How were these changes implemented? -->
**How**:

<!-- Have you done all of these things?  -->
**Checklist**:
<!-- add "N/A" to the end of each line that's irrelevant to your changes -->
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
- [ ] Documentation N/A
- [x] Tests
- [x] Code complete

<!-- feel free to add additional comments -->

<!-- Please add a `Tag:` prefixed label from the labels so that this PR shows up in the changelog -->
  • Loading branch information
emmatown authored Jul 2, 2018
1 parent 06a4abc commit aa8c4e4
Show file tree
Hide file tree
Showing 149 changed files with 1,626 additions and 1,711 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/coverage
/demo/dist
dist/
lib/
node_modules/
*.log
.idea
Expand Down
8 changes: 3 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Prerequisites

- [Node.js](http://nodejs.org/) >= v7 must be installed.

- [Yarn](https://yarnpkg.com/en/docs/install)

## Installation
Expand All @@ -12,15 +11,14 @@
## Running Tests

- `yarn test` will run the tests once.

- `yarn test:coverage` will run the tests and produce a coverage report in `coverage/`.

- `yarn coverage` will run the tests and produce a coverage report in `coverage/`.
- `yarn test:watch` will run the tests on every change.

## Building

- Run `yarn build` in the root directory to build the modules. (Required before publishing)
- `yarn clean` will delete built resources.
- Run `yarn build PACKAGE_NAME ANOTHER_PACKAGE_NAME` to only build certain packages.
- Run `yarn build:watch` to build packages on every change.

## Documentation Website Development

Expand Down
9 changes: 8 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ module.exports = {
'\\.css$': '<rootDir>/test/styleTransform.js',
'^.+\\.js?$': 'babel-jest'
},
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname'
],
moduleNameMapper: lernaAliases(),
setupTestFrameworkScriptFile: '<rootDir>/test/testSetup.js',
coveragePathIgnorePatterns: ['<rootDir>/packages/emotion-utils/src/stylis.js']
coveragePathIgnorePatterns: [
'/node_modules/',
'<rootDir>/packages/babel-plugin-emotion/test/util.js'
]
}
6 changes: 3 additions & 3 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[build]
command = "npm run build && npm run build:site"
publish = "packages/site/public"
publish = "site/public"

[build.environment]
NODE_VERSION = "8"
YARN_VERSION = "1.3.2"
NODE_VERSION = "10"
YARN_VERSION = "1.7.0"
YARN_FLAGS = "--frozen-lockfile"
61 changes: 31 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,43 @@
"private": true,
"version": "7.0.13",
"scripts": {
"build:watch": "npm run build -- -w",
"build": "lerna run build --parallel",
"test:size": "npm-run-all clean rollup size",
"clean": "lerna run clean --parallel",
"build:watch": "node scripts/build/watch",
"build": "node scripts/build",
"test:size": "npm-run-all build size",
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --watch",
"test": "npm-run-all -p lint:check coverage test:size test:typescript flow && npm run test:prod",
"test:typescript": "lerna run test:typescript --parallel",
"coverage": "jest --coverage --no-cache --ci --runInBand",
"test:prod": "npm run build && jest -c jest.dist.js --no-cache --ci --runInBand",
"lint:check": "eslint .",
"test:watch": "jest --watch --no-cache",
"rollup": "lerna run rollup --parallel",
"size": "bundlesize",
"release": "npm run build && lerna publish",
"lint": "eslint . --fix",
"benchmark": "lerna exec --scope benchmarks npm run benchmark",
"start:site": "lerna exec --scope emotion-site npm run start:site",
"build:site": "lerna exec --scope emotion-site npm run build:site",
"watch": "lerna run --parallel watch",
"bootstrap": "lerna bootstrap",
"flow": "flow check"
},
"resolutions": {
"**/react": "^16.3.2",
"**/react-dom": "^16.3.2"
"**/react-dom": "^16.3.2",
"**/browserslist": "^3.2.8"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.40",
"@babel/plugin-external-helpers": "7.0.0-beta.40",
"@babel/preset-env": "7.0.0-beta.40",
"@babel/preset-flow": "7.0.0-beta.40",
"@babel/preset-react": "7.0.0-beta.40",
"@babel/preset-stage-0": "7.0.0-beta.40",
"@babel/core": "7.0.0-beta.51",
"@babel/plugin-external-helpers": "7.0.0-beta.51",
"@babel/preset-env": "7.0.0-beta.51",
"@babel/preset-flow": "7.0.0-beta.51",
"@babel/preset-react": "7.0.0-beta.51",
"@babel/preset-stage-0": "7.0.0-beta.51",
"babel-check-duplicated-nodes": "^1.0.0",
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-eslint": "^8.2.3",
"babel-flow-types": "^1.2.3",
"babel-jest": "^20.0.3",
"babel-jest": "^23.2.0",
"babel-plugin-closure-elimination": "^1.3.0",
"babel-plugin-codegen": "^1.2.0",
"babel-plugin-external-helpers": "^6.22.0",
Expand Down Expand Up @@ -71,11 +70,10 @@
"gatsby-react-router-scroll": "^1.0.7",
"get-lerna-packages": "^0.1.0",
"hoist-non-react-statics": "^2.3.1",
"jest": "^21.2.1",
"jest-cli": "^20.0.4",
"jest-glamor-react": "^3.1.1",
"jest": "^23.2.0",
"jest-in-case": "^1.0.2",
"jest-serializer-html": "^4.0.1",
"jest-watch-typeahead": "^0.1.0",
"jsdom": "^11.3.0",
"lerna": "^2.2.0",
"lerna-alias": "^3.0.1",
Expand All @@ -87,16 +85,7 @@
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-router-dom": "^4.2.2",
"react-test-renderer": "^16.3.2",
"rimraf": "^2.6.1",
"rollup": "^0.60.1",
"rollup-plugin-alias": "^1.3.1",
"rollup-plugin-babel": "4.0.0-beta.4",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^4.0.0",
"rollup-watch": "^4.3.1"
"react-test-renderer": "^16.3.2"
},
"author": "Kye Hohenberger",
"homepage": "/~https://github.com/tkh44/emotion#readme",
Expand Down Expand Up @@ -133,24 +122,36 @@
"standard/computed-property-even-spacing": 0,
"no-template-curly-in-string": 0,
"camelcase": 0,
"import/no-duplicates":0
"import/no-duplicates": 0
},
"env": {
"browser": true
},
"overrides": [
{
"files": [
"*.test.js"
"*.test.js",
"**/__tests__/*"
],
"env": {
"jest": true
}
},
{
"files": [
"**/packages/*/src/*",
"**/packages/*/src/**/*"
],
"rules": {
"import/no-commonjs": 2
}
}
]
},
"workspaces": [
"packages/*"
"packages/*",
"site",
"scripts/*"
],
"bugs": {
"url": "/~https://github.com/tkh44/emotion/issues"
Expand Down
2 changes: 2 additions & 0 deletions packages/babel-plugin-emotion/lib/macro-styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// this can be removed in emotion@10
module.exports = require('babel-plugin-emotion').macros.styled
2 changes: 2 additions & 0 deletions packages/babel-plugin-emotion/lib/macro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// this can be removed in emotion@10
module.exports = require('babel-plugin-emotion').macros.emotion
16 changes: 3 additions & 13 deletions packages/babel-plugin-emotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@
"name": "babel-plugin-emotion",
"version": "9.2.4",
"description": "A recommended babel preprocessing plugin for emotion, The Next Generation of CSS-in-JS.",
"main": "lib/index.js",
"main": "dist/index.js",
"files": [
"src",
"lib"
],
"scripts": {
"build": "npm-run-all clean babel",
"babel": "babel src -d lib",
"watch": "babel src -d lib --watch",
"clean": "rimraf lib"
},
"dependencies": {
"@babel/helper-module-imports": "7.0.0-beta.40",
"@babel/helper-module-imports": "7.0.0-beta.51",
"@emotion/babel-utils": "^0.6.4",
"@emotion/hash": "^0.6.2",
"@emotion/memoize": "^0.6.1",
Expand All @@ -28,11 +22,7 @@
"touch": "^1.0.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.40",
"babel-check-duplicated-nodes": "^1.0.0",
"babel-cli": "^6.24.1",
"npm-run-all": "^4.0.2",
"rimraf": "^2.6.1"
"babel-check-duplicated-nodes": "^1.0.0"
},
"author": "Kye Hohenberger",
"homepage": "https://emotion.sh",
Expand Down
7 changes: 7 additions & 0 deletions packages/babel-plugin-emotion/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ import { addSourceMaps } from './source-map'

import cssProps from './css-prop'
import { getExpressionsFromTemplateLiteral } from '@emotion/babel-utils'
import emotionMacro from './macro'
import styledMacro from './macro-styled'

export const macros = {
emotion: emotionMacro,
styled: styledMacro
}

export type BabelPath = any

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-emotion/src/macro-styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { buildMacroRuntimeNode, omit } from './babel-utils'
import emotionMacro from './macro'
import { createMacro } from 'babel-plugin-macros'

module.exports = createMacro(macro)
export default createMacro(macro)

function macro(options) {
const { references, state, babel: { types: t } } = options
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-emotion/src/macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { replaceCssWithCallExpression } from './index'
import { buildMacroRuntimeNode, addRuntimeImports } from './babel-utils'
import { createMacro } from 'babel-plugin-macros'

module.exports = createMacro(macro)
export default createMacro(macro)

function macro({ references, state, babel: { types: t } }) {
Object.keys(references).forEach(referenceKey => {
Expand Down
Loading

0 comments on commit aa8c4e4

Please sign in to comment.