Skip to content

Commit

Permalink
Merge pull request #6 from TechniqueSoftware/fix/bad-dependency-for-r…
Browse files Browse the repository at this point in the history
…eact-dom

Remove tightly coupled node modules dependency.
  • Loading branch information
Matthew R. Elliott committed Jan 13, 2016
2 parents f8910ff + 7441371 commit d7a93a1
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 42 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spec/spec.js
*.md
webpack.config.spec.js
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

`npm install react-json-schema`

This library builds React elements from JSON by mapping JSON definitions to React components that you expose. The interest behind making this library is to allow non-programmers to construct a view using JSON, which can be stored and retrieved in a database. Use it as you'd like.
This library constructs React elements from JSON by mapping JSON definitions to React components that you expose.

JSX is not a dependency for react-json-schema.

For a quick reference, you can jump to [full example](#putting-it-all-together).
For a quick reference, you can jump to the [full example](#putting-it-all-together).

For 0.3.0+, you must use React 0.14.0+. You may use 0.2.0 for older versions.

Expand Down
27 changes: 13 additions & 14 deletions dist/react-json-schema.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
'use strict';

Object.defineProperty(exports, '__esModule', {
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

Object.defineProperty(exports, "__esModule", {
value: true
});

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var _react = require('react');

var _node_modulesReactLibReactDOMFactories = require('../node_modules/react/lib/ReactDOMFactories');
var _ReactDOMFactories = require('react/lib/ReactDOMFactories');

var _node_modulesReactLibReactDOMFactories2 = _interopRequireDefault(_node_modulesReactLibReactDOMFactories);
var _ReactDOMFactories2 = _interopRequireDefault(_ReactDOMFactories);

var _lodash = require('lodash');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var _componentMap = null;

var ReactJsonSchema = (function () {
var ReactJsonSchema = function () {
function ReactJsonSchema() {
_classCallCheck(this, ReactJsonSchema);
}
Expand Down Expand Up @@ -67,7 +67,7 @@ var ReactJsonSchema = (function () {
Component = schema.component;
} else if (_componentMap && _componentMap[schema.component]) {
Component = _componentMap[schema.component];
} else if ((0, _lodash.has)(_node_modulesReactLibReactDOMFactories2['default'], schema.component)) {
} else if ((0, _lodash.has)(_ReactDOMFactories2.default, schema.component)) {
Component = schema.component;
}
} else {
Expand All @@ -93,7 +93,6 @@ var ReactJsonSchema = (function () {
}]);

return ReactJsonSchema;
})();
}();

exports['default'] = ReactJsonSchema;
module.exports = exports['default'];
exports.default = ReactJsonSchema;
2 changes: 1 addition & 1 deletion dist/react-json-schema.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/ReactJsonSchema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createElement } from 'react';
import ReactDOMFactories from '../node_modules/react/lib/ReactDOMFactories';
import { isFunction, isArray, forEach, omit, clone, has, isObject, isString } from 'lodash';
import ReactDOMFactories from 'react/lib/ReactDOMFactories';
import { isArray, forEach, omit, clone, has, isObject } from 'lodash';

let _componentMap = null;

Expand Down Expand Up @@ -44,7 +44,7 @@ export default class ReactJsonSchema {
} else if (has(ReactDOMFactories, schema.component)) {
Component = schema.component;
}
} else {
} else {
throw new Error('ReactJsonSchema could not resolve a component due to a missing component attribute in the schema.');
}
return Component;
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@
"react": "^0.14.2"
},
"devDependencies": {
"babel-core": "^5.8.25",
"babel-cli": "^6.4.0",
"babel-core": "^6.4.0",
"babel-eslint": "^4.1.3",
"babel-loader": "^5.3.2",
"babel-loader": "6.1.0",
"babel-preset-es2015": "6.1.18",
"babel-preset-react": "6.1.18",
"bootstrap": "^3.3.5",
"eslint": "^1.5.1",
"eslint-config-airbnb": "^0.1.0",
Expand Down
13 changes: 4 additions & 9 deletions webpack.config.demo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/* eslint "esnext": false */

'use strict';

module.exports = {
entry: {
javascript: './demo/index.jsx',
Expand All @@ -13,14 +9,13 @@ module.exports = {
},
module: {
loaders: [
{
test: /\.jsx$/,
loader: 'jsx-loader'
},
{
test: /\.js|jsx$/,
exclude: /node_modules/,
loader: 'babel-loader'
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
}
},
{
test: /\.html$/,
Expand Down
17 changes: 6 additions & 11 deletions webpack.config.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
/* eslint "esnext": false */

'use strict';

var path = require('path');
var srcPath = path.join(__dirname, './spec');

module.exports = {
entry: {
javascript: path.join(srcPath, 'spec.entry'),
html: path.join(srcPath, 'index.html')
javascript: path.join(srcPath, 'spec.entry'),
html: path.join(srcPath, 'index.html')
},
output: {
path: srcPath,
Expand All @@ -17,14 +13,13 @@ module.exports = {
},
module: {
loaders: [
{
test: /\.js|jsx$/,
loader: 'jsx-loader'
},
{
test: /\.js|jsx$/,
exclude: /node_modules/,
loader: 'babel-loader'
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
}
},
{
test: /\.html$/,
Expand Down

0 comments on commit d7a93a1

Please sign in to comment.