Skip to content

Commit

Permalink
Merge pull request #1 from mozilla-services/packaging
Browse files Browse the repository at this point in the history
Prepare for packaging.
  • Loading branch information
n1k0 committed Dec 17, 2015
2 parents 52439d5 + 70894e4 commit ccb8c05
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 19 deletions.
7 changes: 1 addition & 6 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"stage": 0,
"env": {
"development": {
"plugins": ["react-transform"]
}
}
"stage": 0
}

1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ node_js:
env:
- ACTION=test
- ACTION="run lint"
- ACTION="run dist"
script:
- npm $ACTION
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@ Requires React 0.14+.

## Installation

As a npm-based project dependency:

```
$ npm install react-jsonschema-form --save
```

As an standalone CDN url:

```html
<script src="https://npmcdn.com/[email protected]/dist/react-jsonschema-form-0.1.0.js"></script>
```

Source maps are available at [this url](https://npmcdn.com/[email protected]/dist/react-jsonschema-form-0.1.0.js.map).

Note that the CDN version **does not** embed *react* nor *react-dom*.

## Usage

```js
Expand All @@ -31,16 +43,20 @@ const schema = {
}
};

const log = (type) => console.log.bind(console, type);

const App = ({schema}) => {
return <Form schema={schema}
onChange={log("changed")}
onSubmit={log("submitted")}
onError={log("errors")} />;
const formData =  {
title: "First task",
done: true
};

render(<App schema={schema} />, document.getElementById("app"));
const log = (type) => console.log.bind(console, type);

render((
<Form schema={schema}
formData={formData}
onChange={log("changed")}
onSubmit={log("submitted")}
onError={log("errors")} />
), document.getElementById("app"));
```

## License
Expand Down
3 changes: 3 additions & 0 deletions dist/react-jsonschema-form-0.1.0.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/react-jsonschema-form-0.1.0.js.map

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"version": "0.1.0",
"description": "A simple React component capable of building forms from a JSON schema.",
"scripts": {
"build": "babel-node -d lib/ src/",
"dist": "babel -d lib/ src/ && rimraf dist && webpack --optimize-minimize",
"lint": "eslint src test",
"publish": "npm run dist && npm publish",
"tdd": "npm run test -- -w",
"test": "NODE_ENV=test mocha --compilers js:babel/register --recursive --require ./test/setup-jsdom.js $(find test -name '*_test.js')"
},
"main": "lib/index.js",
"files": [
"dist",
"lib"
],
"peerDependencies": {
Expand All @@ -23,19 +25,16 @@
"babel": "^5.8.20",
"babel-eslint": "^4.1.6",
"babel-loader": "^5.3.2",
"babel-plugin-react-transform": "^1.1.1",
"chai": "^3.3.0",
"css-loader": "^0.15.6",
"eslint": "^1.8.0",
"eslint-plugin-react": "^3.6.3",
"gh-pages": "^0.4.0",
"jsdom": "^7.2.1",
"json-loader": "^0.5.4",
"mocha": "^2.3.0",
"react-addons-test-utils": "^0.14.3",
"rimraf": "^2.4.4",
"sinon": "^1.17.2",
"style-loader": "^0.12.3"
"webpack": "^1.10.5"
},
"directories": {
"test": "test"
Expand Down
File renamed without changes.
31 changes: 31 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var pkg = require("./package");

module.exports = {
cache: true,
context: __dirname + "/src",
entry: "./index.js",
output: {
path: "./dist",
publicPath: "/dist/",
filename: "react-jsonschema-form-" + pkg.version + ".js",
library: "JSONSchemaForm",
libraryTarget: "umd"
},
devtool: "source-map",
externals: {
react: {
root: "React",
commonjs: "react",
commonjs2: "react",
amd: "react"
}
},
module: {
loaders: [
{
test: /\.js$/,
loaders: ["babel"],
}
]
}
};

0 comments on commit ccb8c05

Please sign in to comment.