Skip to content

Commit ccb8c05

Browse files
committed
Merge pull request #1 from mozilla-services/packaging
Prepare for packaging.
2 parents 52439d5 + 70894e4 commit ccb8c05

File tree

9 files changed

+66
-19
lines changed

9 files changed

+66
-19
lines changed

.babelrc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"stage": 0,
3-
"env": {
4-
"development": {
5-
"plugins": ["react-transform"]
6-
}
7-
}
2+
"stage": 0
83
}
94

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ node_js:
66
env:
77
- ACTION=test
88
- ACTION="run lint"
9+
- ACTION="run dist"
910
script:
1011
- npm $ACTION

README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,22 @@ Requires React 0.14+.
99

1010
## Installation
1111

12+
As a npm-based project dependency:
13+
1214
```
1315
$ npm install react-jsonschema-form --save
1416
```
1517

18+
As an standalone CDN url:
19+
20+
```html
21+
<script src="https://npmcdn.com/[email protected]/dist/react-jsonschema-form-0.1.0.js"></script>
22+
```
23+
24+
Source maps are available at [this url](https://npmcdn.com/[email protected]/dist/react-jsonschema-form-0.1.0.js.map).
25+
26+
Note that the CDN version **does not** embed *react* nor *react-dom*.
27+
1628
## Usage
1729

1830
```js
@@ -31,16 +43,20 @@ const schema = {
3143
}
3244
};
3345

34-
const log = (type) => console.log.bind(console, type);
35-
36-
const App = ({schema}) => {
37-
return <Form schema={schema}
38-
onChange={log("changed")}
39-
onSubmit={log("submitted")}
40-
onError={log("errors")} />;
46+
const formData =  {
47+
title: "First task",
48+
done: true
4149
};
4250

43-
render(<App schema={schema} />, document.getElementById("app"));
51+
const log = (type) => console.log.bind(console, type);
52+
53+
render((
54+
<Form schema={schema}
55+
formData={formData}
56+
onChange={log("changed")}
57+
onSubmit={log("submitted")}
58+
onError={log("errors")} />
59+
), document.getElementById("app"));
4460
```
4561

4662
## License

dist/react-jsonschema-form-0.1.0.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-jsonschema-form-0.1.0.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"version": "0.1.0",
44
"description": "A simple React component capable of building forms from a JSON schema.",
55
"scripts": {
6-
"build": "babel-node -d lib/ src/",
6+
"dist": "babel -d lib/ src/ && rimraf dist && webpack --optimize-minimize",
77
"lint": "eslint src test",
8+
"publish": "npm run dist && npm publish",
89
"tdd": "npm run test -- -w",
910
"test": "NODE_ENV=test mocha --compilers js:babel/register --recursive --require ./test/setup-jsdom.js $(find test -name '*_test.js')"
1011
},
1112
"main": "lib/index.js",
1213
"files": [
14+
"dist",
1315
"lib"
1416
],
1517
"peerDependencies": {
@@ -23,19 +25,16 @@
2325
"babel": "^5.8.20",
2426
"babel-eslint": "^4.1.6",
2527
"babel-loader": "^5.3.2",
26-
"babel-plugin-react-transform": "^1.1.1",
2728
"chai": "^3.3.0",
28-
"css-loader": "^0.15.6",
2929
"eslint": "^1.8.0",
3030
"eslint-plugin-react": "^3.6.3",
3131
"gh-pages": "^0.4.0",
3232
"jsdom": "^7.2.1",
33-
"json-loader": "^0.5.4",
3433
"mocha": "^2.3.0",
3534
"react-addons-test-utils": "^0.14.3",
3635
"rimraf": "^2.4.4",
3736
"sinon": "^1.17.2",
38-
"style-loader": "^0.12.3"
37+
"webpack": "^1.10.5"
3938
},
4039
"directories": {
4140
"test": "test"
File renamed without changes.

webpack.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var pkg = require("./package");
2+
3+
module.exports = {
4+
cache: true,
5+
context: __dirname + "/src",
6+
entry: "./index.js",
7+
output: {
8+
path: "./dist",
9+
publicPath: "/dist/",
10+
filename: "react-jsonschema-form-" + pkg.version + ".js",
11+
library: "JSONSchemaForm",
12+
libraryTarget: "umd"
13+
},
14+
devtool: "source-map",
15+
externals: {
16+
react: {
17+
root: "React",
18+
commonjs: "react",
19+
commonjs2: "react",
20+
amd: "react"
21+
}
22+
},
23+
module: {
24+
loaders: [
25+
{
26+
test: /\.js$/,
27+
loaders: ["babel"],
28+
}
29+
]
30+
}
31+
};

0 commit comments

Comments
 (0)