Skip to content

(chore) Add support for preact x #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ Wraps [react-redux] up for [Preact] (8.x and prior), without using [preact-compa

**See [preact-redux-example](https://github.com/developit/preact-redux-example):** _a full working example of `redux` + `preact` using `preact-redux`!_

> 💁‍ **Compatibility Note:**
>
> If you're using Preact X (preact@10+), please use the official [react-redux] library.

---


Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function(config) {
},

webpack: {
mode: "production",
mode: "development",
module: {
rules: [{
test: /\.jsx?$/,
Expand Down
5,335 changes: 1,890 additions & 3,445 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@
},
"homepage": "https://github.com/developit/preact-redux",
"peerDependencies": {
"preact": "<10",
"redux": ">=2",
"preact-context": ">=1.1.0"
"preact": ">10",
"redux": ">=2"
},
"devDependencies": {
"@babel/cli": "^7.4.3",
Expand Down Expand Up @@ -72,12 +71,10 @@
"mkdirp": "^0.5.1",
"mocha": "^6.1.2",
"npm-run-all": "^4.0.2",
"phantomjs-prebuilt": "^2.1.14",
"preact": "^8.1.0",
"preact-context": "^1.1.3",
"preact": "^10.0.0",
"pretty-bytes-cli": "^2.0.0",
"react-redux": "^6.0.1",
"redux": "^4.0.0",
"react-redux": "^7.1.1",
"redux": "^4.0.4",
"rimraf": "^2.6.1",
"rollup": "^1.9.2",
"rollup-plugin-alias": "^1.2.1",
Expand Down
4 changes: 3 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const babelRc = JSON.parse(fs.readFileSync(".babelrc"));
let pkg = JSON.parse(fs.readFileSync("./package.json"));

let external = Object.keys(pkg.peerDependencies || {}).concat(
Object.keys(pkg.dependencies || {})
Object.keys(pkg.dependencies || {}), 'preact/compat'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including preact/compat completely defeats the purpose of this project, doesn't it? 😿

);

let format = process.env.FORMAT === "es" ? "es" : "umd";
Expand All @@ -35,12 +35,14 @@ export default {
alias({
"react-redux": "node_modules/react-redux/src/index.js",
react: __dirname + "/src/compat.js",
"react-dom": __dirname + "/src/compat.js",
invariant: __dirname + "/src/empty.js",
"prop-types": __dirname + "/src/prop-types.js"
}),
replace({
"process.env.NODE_ENV": JSON.stringify("production"),
"typeof Symbol": JSON.stringify("string"),
"Symbol.for": "false",
"(forwardRef)": "(false)"
}),
babel({
Expand Down
12 changes: 3 additions & 9 deletions src/compat.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
export { Component, Component as PureComponent } from "preact";
import { createContext } from "preact-context";
import { h } from "preact";
import empty from "./empty";
import * as React from 'preact/compat';

export default {
createContext,
forwardRef: empty,
createElement: h
};
export * from 'preact/compat';
export default React;
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Provider, connect, connectAdvanced, ReactReduxContext } from 'react-redux';
export { Provider, connect, connectAdvanced, ReactReduxContext };
export default { Provider, connect, connectAdvanced, ReactReduxContext };
import * as ReactRedux from 'react-redux';
export * from 'react-redux';

export default ReactRedux;
5 changes: 2 additions & 3 deletions test/provider.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { createStore } from 'redux';
import { Provider, connect, connectAdvanced } from '../';
import { Provider, connect, connectAdvanced } from '../dist/preact-redux.esm';
import { render, options } from 'preact';
import React from 'preact';

import * as React from 'preact';
import * as Redux from '../dist/preact-redux.esm.js';

// disable async rendering entirely to make tests simpler
Expand Down