Skip to content

Commit

Permalink
Try to add the support for yarn2 pnp #26
Browse files Browse the repository at this point in the history
  • Loading branch information
saltyshiomix committed Jun 19, 2020
1 parent 7a5fafd commit a7670c6
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/support-yarn2-pnp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
.pnp/*
!.pnp/releases
!.pnp/plugins
!.pnp/sdks
!.pnp/versions
.pnp.*
.ssr
18 changes: 18 additions & 0 deletions examples/support-yarn2-pnp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"private": true,
"name": "support-yarn2-pnp",
"scripts": {
"dev": "node server.js"
},
"dependencies": {
"@react-ssr/core": "latest",
"@react-ssr/express": "latest",
"express": "^4.17.1",
"pnp-webpack-plugin": "^1.6.4",
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"installConfig": {
"pnp": true
}
}
17 changes: 17 additions & 0 deletions examples/support-yarn2-pnp/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const express = require('express');
const register = require('@react-ssr/express/register');

const app = express();

(async () => {
await register(app);

app.get('/', (req, res) => {
const user = { name: 'World' };
res.render('index', { user });
});

app.listen(3000, () => {
console.log('> Ready on http://localhost:3000');
});
})();
17 changes: 17 additions & 0 deletions examples/support-yarn2-pnp/ssr.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const PnpWebpackPlugin = require('pnp-webpack-plugin');

module.exports = {
webpack: (config) => {
config.resolve.plugins = [
...(config.resolve.plugins || []),
PnpWebpackPlugin,
];

config.resolveLoader.plugins = [
...(config.resolveLoader.plugins || []),
PnpWebpackPlugin.moduleLoader(module),
];

return config;
},
};
23 changes: 23 additions & 0 deletions examples/support-yarn2-pnp/views/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { Head } from '@react-ssr/express';

const Index = ({ user }) => {
const [message, setMessage] = React.useState('waiting...');

const onClick = () => setMessage('This is a react-ssr!');

return (
<React.Fragment>
<Head>
<title>
basic-jsx - @react-ssr/express
</title>
</Head>
<p>Hello {user.name}!</p>
<button onClick={onClick}>Click Me</button>
<p>Message from state: {message}</p>
</React.Fragment>
);
};

export default Index;

0 comments on commit a7670c6

Please sign in to comment.