{"name":"preact-compat","amdName":"preactCompat","version":"2.2.0","description":"A React compatibility layer for Preact","main":"dist/preact-compat.js","minified:main":"dist/preact-compat.min.js","jsnext:main":"src/index.js","scripts":{"build":"npm-run-all transpile minify size","transpile":"rollup -c rollup.config.js","minify":"uglifyjs $npm_package_main -c dead_code,evaluate -m -o $npm_package_minified_main -p relative --in-source-map ${npm_package_main}.map --source-map ${npm_package_minified_main}.map","size":"echo \"gzip size: $(gzip-size $npm_package_minified_main | pretty-bytes)\"","test":"npm-run-all lint build test:karma","lint":"eslint {src,test}","test:karma":"karma start --single-run","prepublish":"npm-run-all build test","release":"npm run -s build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish","start":"node server.js"},"keywords":["preact","react","compatibility"],"repository":{"type":"git","url":"git+https://github.com/developit/preact-compat.git"},"author":{"name":"Jason Miller","email":"jason@developit.ca"},"license":"MIT","bugs":{"url":"https://github.com/developit/preact-compat/issues"},"homepage":"https://github.com/developit/preact-compat","devDependencies":{"babel-core":"^6.10.4","babel-eslint":"^6.1.1","babel-loader":"^6.2.4","babel-plugin-transform-class-properties":"^6.10.2","babel-plugin-transform-es2015-classes":"^6.9.0","babel-plugin-transform-object-rest-spread":"^6.8.0","babel-plugin-transform-react-jsx":"^6.8.0","babel-preset-es2015":"^6.9.0","babel-preset-es2015-minimal-rollup":"^2.0.0","babel-preset-react":"^6.11.1","babel-preset-stage-0":"^6.5.0","chai":"^3.5.0","diff":"^2.2.3","es5-shim":"^4.5.9","eslint":"^3.0.1","gzip-size-cli":"^1.0.0","karma":"^1.1.1","karma-chai":"^0.1.0","karma-chai-sinon":"^0.1.5","karma-mocha":"^1.1.1","karma-mocha-reporter":"^2.0.4","karma-phantomjs-launcher":"^1.0.1","karma-sourcemap-loader":"^0.3.7","karma-webpack":"^1.7.0","mkdirp":"^0.5.1","mocha":"^2.5.3","npm-run-all":"^2.3.0","phantomjs-prebuilt":"^2.1.7","preact":"^5.3.0","preact-jsx-chai":"^1.6.0","pretty-bytes-cli":"^1.0.0","rollup":"^0.33.1","rollup-plugin-babel":"^2.6.1","rollup-plugin-commonjs":"^3.1.0","rollup-plugin-memory":"^1.0.0","rollup-plugin-node-resolve":"^1.7.1","sinon":"^1.17.4","sinon-chai":"^2.8.0","uglify-js":"^2.7.0","webpack":"^1.13.1"},"peerDependencies":{"preact":">=5"},"dependencies":{"preact-render-to-string":"^2.6.1","proptypes":"^0.14.3"},"gitHead":"b21c1da53a65719f6a8585b0ef6c718c5d8b968d","_id":"preact-compat@2.2.0","_shasum":"820bf93678dfead92870b44e7664040703c4ebb7","_from":".","_npmVersion":"3.8.8","_nodeVersion":"5.7.1","_npmUser":{"name":"developit","email":"jason@developit.ca"},"maintainers":[{"name":"developit","email":"jason@developit.ca"}],"dist":{"shasum":"820bf93678dfead92870b44e7664040703c4ebb7","tarball":"http://registry-npm.ywwl.com/preact-compat/download/preact-compat-2.2.0.tgz","integrity":"sha512-bbx609L02VfX2AEiX4DQoF9ZIh0m7V1IvfASk8w/Knaxz5Oa/U2CtlLFxF0Hk9xBwybfZyb96iP/ye1PE2FE6A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDvwCjeMSaHkgVeYFGROWk/qUF0OA4TIXHeZT+TDH3whAIgeA2glWaVEmwBfaCdvKxPKVmS0Lb9XFVE/+0yWmiE1Ik="}],"size":31161,"noattachment":false,"key":"/preact-compat/-/preact-compat-2.2.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/preact-compat-2.2.0.tgz_1469327924596_0.362321684602648"},"directories":{},"readme":"# preact-compat\n\n[![NPM](https://img.shields.io/npm/v/preact-compat.svg?style=flat)](https://www.npmjs.org/package/preact-compat)\n[![travis-ci](https://travis-ci.org/developit/preact-compat.svg?branch=master)](https://travis-ci.org/developit/preact-compat)\n[![CDNJS](https://img.shields.io/cdnjs/v/preact-compat.svg)](https://cdnjs.com/libraries/preact-compat)\n\n> 🚨 **Note:** This module is for Preact 8.x and prior - Preact X includes compat by default.\n> For Preact X, please uninstall `preact-compat` and replace your aliases with `preact/compat`.\n\n\nThis module is a compatibility layer that makes React-based modules work with [Preact], without any code changes.\n\nIt provides the same exports as `react` and `react-dom`, meaning you can use your build tool of choice to drop it in where React is being depended on.\n\n\n> Interested? Here's an example project that uses `preact-compat` to work with an existing React library unmodified,\n> achieving more than 95% reduction in size:\n>\n> **[preact-compat-example](https://github.com/developit/preact-compat-example)**\n\n---\n\n\n## Why?\n\n> _... or really, \"why [preact]\"?_\n\nReact is a great library and a great concept, and has a large community of module authors creating high-quality components.\nHowever, these components are tightly coupled to React through the use of generic package imports _([example][1])_.\n\n[Preact] is a tiny _(3kb)_ implementation of the core value of React, and maintains a nearly identical API.\nWith a shim like this in place, it is possible to use other React-like libraries like Preact, without forking modules just to change their imports.\n\nThere are better long-term ways to solve the coupling issue, like using factory functions that accept **named** generic methods _(not just React DI)_,\nas [suggested by Eric Elliot][2]. However, since the React community has already authored so many modules in a more explicitly coupled manner, it's worth\nhaving a simple short-term solution for those who would like to liberate themselves from library lock-in.\n\n\n---\n\n## Installation\nYou need to install `preact-compat` first through npm:\n\n```bash\nnpm i --save preact-compat\n```\n\nNOTE: You need to have `preact` already installed, if you don't, install it like so:\n\n```bash\nnpm i --save preact\n```\n\n## Usage with Webpack\n\nUsing `preact-compat` with Webpack is easy.\n\nAll you have to do is add an alias for `react` and `react-dom`:\n\n```js\n{\n    // ...\n    resolve: {\n        alias: {\n            'react': 'preact-compat',\n            'react-dom': 'preact-compat',\n            // Not necessary unless you consume a module using `createClass`\n            'create-react-class': 'preact-compat/lib/create-react-class',\n            // Not necessary unless you consume a module requiring `react-dom-factories`\n            'react-dom-factories': 'preact-compat/lib/react-dom-factories'\n        }\n    }\n    // ...\n}\n```\n\n\n## Usage with Browserify\n\nUsing `preact-compat` with Browserify is as simple as installing and configuring [aliasify](http://npm.im/aliasify).\n\nFirst, install it: `npm install --save-dev aliasify`\n\n... then in your `package.json`, configure aliasify to alias `react` and `react-dom`:\n\n```js\n{\n    // ...\n    \"aliasify\": {\n        \"aliases\": {\n            \"react\": \"preact-compat\",\n            \"react-dom\": \"preact-compat\",\n            // Not necessary unless you consume a module using `createClass`\n            \"create-react-class\": \"preact-compat/lib/create-react-class\",\n            // Not necessary unless you consume a module requiring `react-dom-factories`\n            \"react-dom-factories\": \"preact-compat/lib/react-dom-factories\"\n        }\n    }\n    // ...\n}\n```\n\nIf you want to use a package that has a peer dependency of React and want it to point to preact-compat you’ll need to set Aliasify to be a global transform. [This is not achievable by editing package.json](https://github.com/browserify/browserify#btransformtr-opts), you’ll need to use the Browserify api and include the global option there:\n\n```\nb.transform(aliasify, {\n  global: true,\n  aliases: {\n    'react': 'preact-compat',\n    'react-dom': 'preact-compat'\n  }\n});\n```\n\n## Usage with Babel\n\nUsing `preact-compat` with Babel is easy.\n\nInstall the babel plugin for aliasing: `npm install --save-dev babel-plugin-module-resolver`\n\nAll you have to do is tell babel to process jsx with 'h' and add an alias for `react` and `react-dom` in your .babelrc:\n\n```js\n{\n    // ...\n    \"plugins\": [\n        [\"module-resolver\", {\n        \"root\": [\".\"],\n        \"alias\": {\n            \"react\": \"preact-compat\",\n            \"react-dom\": \"preact-compat\",\n            // Not necessary unless you consume a module using `createClass`\n            \"create-react-class\": \"preact-compat/lib/create-react-class\",\n            // Not necessary unless you consume a module requiring `react-dom-factories`\n            \"react-dom-factories\": \"preact-compat/lib/react-dom-factories\"\n        }\n        }]\n    ],\n    \"presets\": [\n        \"react\"\n    ]\n    // ...\n}\n```\n\n## Usage with Brunch\n\nUsing `preact-compat` with Brunch requires no extra plugins.\n\nIn your `brunch-config.js` you can export an [`npm` object](http://brunch.io/docs/config#-npm-) to configure aliases:\n\n```js\n// ...\nexports.npm = {\n  enabled: true,\n  aliases: {\n    'react': 'preact-compat',\n    'react-dom': 'preact-compat'\n  }\n}\n// ...\n```\n\n\n## Once Aliased\n\nWith the above Webpack or Browserify aliases in place, existing React modules should work nicely:\n\n```js\nimport React, { Component } from 'react';\nimport { render } from 'react-dom';\n\nclass Foo extends Component {\n    propTypes = {\n        a: React.PropTypes.string.isRequired\n    };\n    render() {\n        let { a, b, children } = this.props;\n        return <div {...{a,b}}>{ children }</div>;\n    }\n}\n\nrender((\n    <Foo a=\"a\">test</Foo>\n), document.body);\n```\n\n\n---\n\n\n## Use Without Webpack/Browserify\n\n`preact-compat` and its single dependency [`prop-types`](https://github.com/reactjs/prop-types) are both published as UMD modules as of `preact-compat` version `0.6`. This means you can use them via a `<script>` tag without issue:\n\n```html\n<script src=\"//unpkg.com/preact\"></script>\n<script src=\"//unpkg.com/prop-types/prop-types.min.js\"></script>\n<script src=\"//unpkg.com/preact-compat\"></script>\n<script>\n    var React = preactCompat,\n        ReactDOM = preactCompat;\n    ReactDOM.render(<h1>Hello!</h1>, document.body);\n</script>\n```\n\nYou can see the above in action with this [JSFiddle Example](https://jsfiddle.net/developit/61cqu193/).\n\n\n---\n\n\n### PropTypes\n\n`preact-compat` adds support for validating PropTypes out of the box. This can be disabled the same way it is when using React, by defining a global `process.env.NODE_ENV='production'`.  PropType errors should work the same as in React - the [`prop-types`](https://github.com/reactjs/prop-types) module used here is published by the React team to replace PropTypes in React.\n\n<img src=\"http://i.imgur.com/tGT7Dvw.png\" width=\"650\" alt=\"PropType validation example output\" />\n\n\n\n## License\n\n[MIT]\n\n\n[preact]: https://github.com/developit/preact\n[MIT]: http://choosealicense.com/licenses/mit\n[1]: https://github.com/developit/preact-toolbox/blob/master/components/app/index.jsx#L1\n[2]: https://gist.github.com/ericelliott/7e05747b891673eb704b\n","publish_time":1469327926838,"_cnpm_publish_time":1469327926838,"dist-tags":{"beta":"3.8.2","latest":"3.19.0"}}