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 new Gatsby plugin for Inferno support #9138

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"rimraf": "^2.6.1",
"yargs": "^10.0.3"
},
"peerDependencies": {
"inferno": "6.x",
"inferno-compat": "6.x"
},
"engines": {
"yarn": "^1.2.1",
"node": ">=6.11.5"
Expand Down
5 changes: 5 additions & 0 deletions packages/gatsby-plugin-inferno/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
["../../.babel-preset.js", { "browser": true }]
]
}
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-inferno/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*.js
!index.js
yarn.lock
34 changes: 34 additions & 0 deletions packages/gatsby-plugin-inferno/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
*.un~
yarn.lock
src
flow-typed
coverage
decls
examples
19 changes: 19 additions & 0 deletions packages/gatsby-plugin-inferno/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# gatsby-plugin-inferno

Provides drop-in support for replacing React with [Inferno](https://infernojs.org/).

While Inferno doesn't provide full support for the React ecosystem, it is an
intriguing option for Gatsby sites as it both offers bundle size and performance benefits over React

## Install

`npm install --save gatsby-plugin-preact inferno inferno-compat`

More information can be found on [inferno-compat's README](https://github.com/infernojs/inferno/tree/master/packages/inferno-compat). They allow you to customize what React features you support via additional packages

## How to use

```javascript
// In your gatsby-config.js
plugins: [`gatsby-plugin-inferno`]
```
1 change: 1 addition & 0 deletions packages/gatsby-plugin-inferno/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// noop
34 changes: 34 additions & 0 deletions packages/gatsby-plugin-inferno/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "gatsby-plugin-inferno",
"description": "A Gatsby plugin which replaces React with Inferno",
"version": "1.0.0",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"@babel/runtime": "^7.0.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"cross-env": "^5.1.4"
},
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-inferno#readme",
"keywords": [
"gatsby",
"gatsby-plugin",
"inferno"
],
"license": "MIT",
"main": "index.js",
"peerDependencies": {
"gatsby": ">2.0.0-alpha"
},
"repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-inferno",
"scripts": {
"build": "babel src --out-dir . --ignore **/__tests__",
"prepare": "cross-env NODE_ENV=production npm run build",
"watch": "babel -w src --out-dir . --ignore **/__tests__"
}
}
16 changes: 16 additions & 0 deletions packages/gatsby-plugin-inferno/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
exports.onCreateWebpackConfig = ({ stage, actions }) => {
/*
* Inferno doesn't currently support Hot Module Reloading
* in development mode, so we'll exclude it from the process then
*/
if (stage !== `develop-html` && stage !== `develop`) {
actions.setWebpackConfig({
resolve: {
alias: {
react: `inferno-compat`,
"react-dom": `inferno-compat`,
},
},
})
}
}