Skip to content

Commit

Permalink
Framework: Add lerna to publish @automattic/simple-components
Browse files Browse the repository at this point in the history
Add `lerna` (a monorepo tool) to Calypso, and use it to publish [`@automattic/simple-components`](https://www.npmjs.com/package/@automattic/simple-components) as a separate npm.

This involves adding a `package.json`, `.gitignore`, and `.npmignore` to `client/components`, and an `alias` field to Calypso's webpack configs.

Since we want Calypso (and possibly other consumers) to continue to use untranspiled code (to benefit from features such as tree-shaking), the npms we produce should contain both transpiled and untranspiled versions of the code. See http://2ality.com/2017/07/npm-packages-via-babel.html, and for more information, http://2ality.com/2017/04/transpiling-dependencies-babel.html and http://2ality.com/2017/06/pkg-esnext.html.
  • Loading branch information
ockham committed Jul 19, 2018
1 parent d71d316 commit 6599b3c
Show file tree
Hide file tree
Showing 9 changed files with 4,900 additions and 2,125 deletions.
2 changes: 2 additions & 0 deletions client/components/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cjs
node_modules
1 change: 1 addition & 0 deletions client/components/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
9 changes: 9 additions & 0 deletions client/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @format */

// Keep in sync with the `files` field in package.json!
// TODO: Can we auto-generate at build time?

export { Badge } from './badge';
export { Button } from './button';
export { Main } from './main';
export { Notice } from './notice';
45 changes: 45 additions & 0 deletions client/components/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@automattic/simple-components",
"version": "0.1.0-alpha.7",
"description": "React components, as used on WordPress.com",
"scripts": {
"build": "npx babel --only ./index.js,./badge/,./button/,./main/,./notice/ --out-dir cjs .",
"prepublishOnly": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/automattic/wp-calypso.git"
},
"keywords": [
"wordpress",
"react",
"components"
],
"author": "Automattic",
"license": "GPL-2.0+",
"bugs": {
"url": "https://github.com/automattic/wp-calypso/issues"
},
"homepage": "https://github.com/Automattic/wp-calypso/blob/master/docs/components.md",
"main": "./cjs/index.js",
"esnext": "./index.js",
"files": [
"index.js",
"cjs/",
"badge/",
"button/",
"main/",
"notice"
],
"dependencies": {
"classnames": "^2.2.6",
"gridicons": "^3.0.1",
"i18n-calypso": "^1.9.1",
"lodash": "^4.17.10",
"prop-types": "^15.6.2",
"react": "^16.4.1"
},
"publishConfig": {
"access": "public"
}
}
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"packages": [
"client/components"
],
"version": "independent"
}
Loading

0 comments on commit 6599b3c

Please sign in to comment.