-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Implement preact/inferno SSR #1346
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const dev = process.env.NODE_ENV !== 'production' | ||
const moduleAlias = require('module-alias') | ||
|
||
// For the development version, we'll use React. | ||
// Because, it support react hot loading and so on. | ||
if (!dev) { | ||
moduleAlias.addAlias('react', 'inferno-compat') | ||
moduleAlias.addAlias('react-dom/server', 'inferno-server') | ||
moduleAlias.addAlias('react-dom', 'inferno-compat') | ||
} | ||
|
||
const { createServer } = require('http') | ||
const { parse } = require('url') | ||
const next = require('next') | ||
|
||
const app = next({ dev }) | ||
const handle = app.getRequestHandler() | ||
|
||
app.prepare() | ||
.then(() => { | ||
createServer((req, res) => { | ||
const parsedUrl = parse(req.url, true) | ||
handle(req, res, parsedUrl) | ||
}) | ||
.listen(3000, (err) => { | ||
if (err) throw err | ||
console.log('> Ready on http://localhost:3000') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
module.exports = { | ||
webpack: function (config) { | ||
webpack: function (config, { dev }) { | ||
// For the development version, we'll use React. | ||
// Because, it support react hot loading and so on. | ||
if (dev) { | ||
return config | ||
} | ||
|
||
config.resolve.alias = { | ||
'react': 'preact-compat/dist/preact-compat', | ||
'react-dom': 'preact-compat/dist/preact-compat' | ||
} | ||
|
||
// Disable uglify. This has been fixed in https://github.com/developit/preact-compat/issues/155. | ||
// Can be removed once there is a new preact-compat release. | ||
config.plugins = config.plugins.filter((plugin) => { | ||
if (plugin.constructor.name === 'UglifyJsPlugin') { | ||
return false | ||
} else { | ||
return true | ||
} | ||
}) | ||
|
||
return config | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const dev = process.env.NODE_ENV !== 'production' | ||
const moduleAlias = require('module-alias') | ||
|
||
// For the development version, we'll use React. | ||
// Because, it support react hot loading and so on. | ||
if (dev) { | ||
moduleAlias.addAlias('react', 'preact-compat') | ||
moduleAlias.addAlias('react-dom', 'preact-compat') | ||
} | ||
|
||
const { createServer } = require('http') | ||
const { parse } = require('url') | ||
const next = require('next') | ||
|
||
const app = next({ dev }) | ||
const handle = app.getRequestHandler() | ||
|
||
app.prepare() | ||
.then(() => { | ||
createServer((req, res) => { | ||
const parsedUrl = parse(req.url, true) | ||
handle(req, res, parsedUrl) | ||
}) | ||
.listen(3000, (err) => { | ||
if (err) throw err | ||
console.log('> Ready on http://localhost:3000') | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about simplifying this to:
or at least drop the redundant if/return true/false:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I copied this one: #1195 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... "Good catch. I don't care." Was it the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, didn't get to changing it before rauchg merged it 😅 Will send a PR 👍🏻👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1351