Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change build system and update Jest #747

Merged
merged 41 commits into from
Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e9315c6
Start changing build stuff
emmatown May 5, 2018
ef6dd5c
Fix stuff
emmatown May 5, 2018
2ee93eb
Merge branch 'master' into change-build
emmatown Jun 28, 2018
1a46819
Move site and benchmarks
emmatown Jun 28, 2018
46b2750
Merge branch 'master' into change-build
emmatown Jun 28, 2018
f2f153f
Add a thing for flow
emmatown Jun 28, 2018
df609e9
Change some stuff
emmatown Jun 28, 2018
f9c975d
Add UMD builds and update build script from next
emmatown Jun 28, 2018
c74a39a
Fix stuff
emmatown Jun 28, 2018
21d2b01
Clean up stuff and update jest
emmatown Jun 28, 2018
95840eb
Change a thing
emmatown Jun 30, 2018
6e1256c
Merge branch 'master' into change-build
emmatown Jun 30, 2018
c5cabe5
Change a thing
emmatown Jun 30, 2018
1b8e73b
Fix site
emmatown Jun 30, 2018
541b1cd
probably fix ci
emmatown Jun 30, 2018
edf6af3
Fix linting
emmatown Jun 30, 2018
eea5e74
Update CONTRIBUTING.md
emmatown Jun 30, 2018
4decc39
Change netlify.toml
emmatown Jun 30, 2018
86c95dc
Fix path
emmatown Jun 30, 2018
b70004d
Fix more paths
emmatown Jun 30, 2018
42f98b8
Remove exclude from rollup-plugin-commonjs usage
emmatown Jun 30, 2018
157a7a0
Move rollup-plugin-commonjs to after rollup-plugin-babel
emmatown Jun 30, 2018
dad28a7
Add comments to macro proxy files
emmatown Jun 30, 2018
54acf9f
Refactor and add comment to react component constructor babel plugin
emmatown Jun 30, 2018
3d4f99a
Disallow commonjs in the src of packages to avoid rollup problems
emmatown Jun 30, 2018
157bbec
Don't build eslint-plugin-emotion
emmatown Jun 30, 2018
ad8d1ad
Fix site
emmatown Jun 30, 2018
22f1907
gahhhhhhhhhhhhhh
emmatown Jun 30, 2018
43eb9e3
Address some feedback and stuff
emmatown Jun 30, 2018
d31ded1
Support PureComponent in basic react constructor babel plugin
emmatown Jun 30, 2018
6f89776
Add flow types to build script
emmatown Jul 1, 2018
44e35e9
Fix a thing
emmatown Jul 1, 2018
29887b9
Update babel (lots of tests are failing)
emmatown Jul 1, 2018
7ae8d49
Fix mock fs in babel plugin tests
emmatown Jul 1, 2018
200495c
Update snapshots (the reason the component selector hashes changed wa…
emmatown Jul 1, 2018
3a0fe42
Add to coverage ignore
emmatown Jul 1, 2018
07aaace
Fix site and switch benchmarks to parcel
emmatown Jul 1, 2018
6d552a4
Revert "Fix site and switch benchmarks to parcel"
emmatown Jul 1, 2018
6d9f93b
Add browserslist to resolutions
emmatown Jul 1, 2018
cb4e562
Change es suffix to esm
emmatown Jul 1, 2018
ec46278
Fix site
emmatown Jul 2, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 5 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ 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']
setupTestFrameworkScriptFile: '<rootDir>/test/testSetup.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"
43 changes: 21 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@
"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": "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"
},
Expand All @@ -39,7 +36,7 @@
"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,9 +68,8 @@
"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-watch-typeahead": "^0.1.0",
"jest-in-case": "^1.0.2",
"jest-serializer-html": "^4.0.1",
"jsdom": "^11.3.0",
Expand All @@ -87,16 +83,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 @@ -141,16 +128,28 @@
"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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the reason behind those 2 "proxy" files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case people have custom instances of emotion and they're using the macros with them since this they were previously imported via babel-plugin-emotion/lib/macro and babel-plugin-emotion/lib/macro-styled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, maybe add a comment that this can be removed with next major?

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
13 changes: 2 additions & 11 deletions packages/babel-plugin-emotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
"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",
"@emotion/babel-utils": "^0.6.4",
Expand All @@ -29,10 +23,7 @@
},
"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
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require('babel-register')
const path = require('path')
require('module-alias').addAliases({
'emotion-utils': path.join(__dirname, '../../../emotion-utils/src'),
'react-emotion/macro': path.join(__dirname, '../../src/macro-styled'),
'emotion/macro': path.join(__dirname, '../../src/macro')
'babel-plugin-emotion': path.join(__dirname, '../../src')
})

module.exports = require('babel-plugin-macros')
13 changes: 3 additions & 10 deletions packages/create-emotion-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
"name": "create-emotion-server",
"version": "9.2.4",
"description": "SSR and style extraction tooling for emotion, The Next Generation of CSS-in-JS.",
"main": "lib/index.js",
"main": "dist/index.js",
"types": "types/index.d.ts",
"files": [
"src",
"lib",
"types"
],
"scripts": {
"build": "npm-run-all clean babel",
"babel": "babel src -d lib",
"clean": "rimraf lib",
"test:typescript": "dtslint types",
"watch": "babel src -d lib --watch"
"test:typescript": "dtslint types"
},
"dependencies": {
"html-tokenize": "^2.0.0",
Expand All @@ -23,12 +19,9 @@
},
"devDependencies": {
"@types/node": "*",
"babel-cli": "^6.24.1",
"dtslint": "^0.3.0",
"emotion": "^9.2.4",
"npm-run-all": "^4.0.2",
"react-emotion": "^9.2.4",
"rimraf": "^2.6.1"
"react-emotion": "^9.2.4"
},
"author": "Kye Hohenberger",
"homepage": "https://emotion.sh",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-emotion-server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import createExtractCritical from './extract-critical'
import createRenderStylesToString from './inline'
import createRenderStylesToStream from './stream'

module.exports = function(emotion: Emotion) {
export default function(emotion: Emotion) {
const nonceString =
emotion.caches.nonce !== undefined ? ` nonce="${emotion.caches.nonce}"` : ''
return {
Expand Down
14 changes: 4 additions & 10 deletions packages/create-emotion-styled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
"types"
],
"scripts": {
"build": "npm-run-all clean rollup",
"clean": "rimraf dist",
"test:typescript": "dtslint types",
"rollup": "rollup -c ../../rollup.config.js",
"watch": "rollup -c ../../rollup.config.js --watch"
"test:typescript": "dtslint types"
},
"dependencies": {
"@emotion/is-prop-valid": "^0.6.1"
Expand All @@ -26,10 +22,7 @@
"devDependencies": {
"@types/react": "16.0.16",
"dtslint": "^0.3.0",
"npm-run-all": "^4.0.2",
"prop-types": "^15.6.1",
"rimraf": "^2.6.1",
"rollup": "^0.60.1"
"prop-types": "^15.6.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems weird to have prop-types in devDeps, are they needed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already there. It's probably not strictly necessary but it was probably added there because it's a peerDependency and it's needed in dev. If you think it should be removed them I'll remove it but IMO, it doesn't really matter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

peer dep thing makes sense 👍

},
"author": "Kye Hohenberger",
"homepage": "https://emotion.sh",
Expand All @@ -44,5 +37,6 @@
],
"bugs": {
"url": "https://github.com/emotion-js/emotion/issues"
}
},
"umd:main": "./dist/emotion.umd.min.js"
}
16 changes: 4 additions & 12 deletions packages/create-emotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
"types"
],
"scripts": {
"build": "npm-run-all clean rollup",
"clean": "rimraf dist",
"test:typescript": "dtslint types",
"rollup": "rollup -c ../../rollup.config.js",
"watch": "rollup -c ../../rollup.config.js --watch"
"test:typescript": "dtslint types"
},
"dependencies": {
"@emotion/hash": "^0.6.2",
Expand All @@ -28,13 +24,8 @@
},
"devDependencies": {
"@types/react": "16.0.16",
"babel-cli": "^6.24.1",
"babel-plugin-transform-define": "^1.3.0",
"cross-env": "^5.0.5",
"dtslint": "^0.3.0",
"npm-run-all": "^4.0.2",
"rimraf": "^2.6.1",
"rollup": "^0.60.1"
"dtslint": "^0.3.0"
},
"author": "Kye Hohenberger",
"homepage": "https://emotion.sh",
Expand All @@ -49,5 +40,6 @@
],
"bugs": {
"url": "https://github.com/emotion-js/emotion/issues"
}
},
"umd:main": "./dist/emotion.umd.min.js"
}
13 changes: 3 additions & 10 deletions packages/emotion-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
"name": "emotion-server",
"version": "9.2.4",
"description": "Extract and inline critical css with emotion for server side rendering.",
"main": "lib/index.js",
"main": "dist/index.js",
"types": "types/index.d.ts",
"files": [
"src",
"lib",
"types"
],
"scripts": {
"build": "npm-run-all clean babel",
"babel": "babel src -d lib",
"clean": "rimraf lib",
"test:typescript": "dtslint types",
"watch": "babel src -d lib --watch"
"test:typescript": "dtslint types"
},
"dependencies": {
"create-emotion-server": "^9.2.4"
Expand All @@ -24,13 +20,10 @@
},
"devDependencies": {
"@types/react-dom": "16.0.5",
"babel-cli": "^6.24.1",
"babel-plugin-emotion": "^9.2.4",
"dtslint": "^0.3.0",
"emotion": "^9.2.4",
"npm-run-all": "^4.0.2",
"react-emotion": "^9.2.4",
"rimraf": "^2.6.1"
"react-emotion": "^9.2.4"
},
"author": "Kye Hohenberger",
"homepage": "https://emotion.sh",
Expand Down
Loading