Skip to content
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

Add support for creating a preact-compat build #124

Closed
2 tasks done
insin opened this issue Jun 25, 2016 · 6 comments
Closed
2 tasks done

Add support for creating a preact-compat build #124

insin opened this issue Jun 25, 2016 · 6 comments

Comments

@insin
Copy link
Owner

insin commented Jun 25, 2016

@developit's preact-compat is a drop-in way to try preact with a React app - if it's compatible with your app, having support for it in react-specific build commands would be an easy way to shave size off your production build.

The actual change here should be making the following tweaks to build-react-app.js and build-react.js:

  • If a --preact flag is present, add this resolve.alias config to the base Webpack config
  • If a --preact flag is present, don't configure React inline and constant element transforms for production builds
@developit
Copy link

You are a gentleman and a scholar.

insin added a commit that referenced this issue Jul 7, 2016
- react and react-dom are aliased to preact-compat in Webpack config
- Incompatible Babel transforms for React production optimisations are excluded from Babel config

Closes #124
@insin
Copy link
Owner Author

insin commented Jul 7, 2016

@developit is there anything in the code in the Gist below which would specifically be incompatible with preact-compat?

https://gist.github.com/insin/45b7f66e01628601c0cc6b79767b0e4f#file-app-js

Trying the --preact flag in the next branch with it and am getting this:

firefox_2016-07-08_03-00-18

@developit
Copy link

@insin Sorry for the delay - use preact@beta (currently 5.x), this is fixed there.

@insin
Copy link
Owner Author

insin commented Jul 8, 2016

👍 got it working, but I had to fiddle with preact-compat's package.json in node_modules/ and delete its own installed version of preact to make it use my app's preact@beta, and for that not to be peer invalid (with npm2):

  "peerDependencies": {
    "preact": "* || ^5.1.0-beta.20",
    "proptypes": "*"
  },
  "dependencies": {
    "preact-render-to-string": "^2.6.1",
    "preact-svg": "^1.6.0"
  },

A dependency should usually be in either peerDependencies or dependencies/optionalDependencies, but not both as the latter will make it install its own version and the * version not matching prerelease versions makes it a pain when you need to be on the bleeding edge 😸

@developit
Copy link

Ah totally yeah, I need to remove it from optionalDependencies. Will try to tonight. Though I'm likely release preact 5 as the new mainline this week so the problem should go away.

@insin insin mentioned this issue Jul 8, 2016
10 tasks
developit added a commit to preactjs/preact-compat that referenced this issue Jul 8, 2016
@developit
Copy link

@insin Removed optionalDependencies from preact-compat and released as 1.10.0.

@insin insin closed this as completed in eead31a Aug 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants