New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parcel-react-ssr

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parcel-react-ssr - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

app/App.jsx

51

package.json
{
"name": "parcel-react-ssr",
"version": "0.3.2",
"version": "0.4.0",
"description": "Example of SSR with React and ParcelJS",
"main": "index.js",
"keywords": ["parcel", "react", "ssr"],
"author": "Benoit Tremblay <benoit@reactivestack.com>",
"license": "MIT",
"repository": "reactivestack/parcel-react-ssr",
"scripts": {
"start": "parcel src/index.html",
"dev": "parcel app/index.html",
"build": "rimraf dist && npm run build-client && npm run build-server",
"build-client": "parcel build src/index.html -d dist/client --public-url /dist",
"build-server": "cross-env BABEL_ENV=node babel src -d dist/server --ignore __tests__",
"test": "jest"
"build-client":
"parcel build app/index.html -d dist/client --public-url /dist",
"build-server":
"parcel build server/index.js -d dist/server --public-url /dist --target=node6",
"start": "node dist/server"
},
"keywords": [],
"author": "",
"license": "ISC",
"repository": "reactivestack/parcel-react-ssr",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-transform-require-ignore": "^0.1.1",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"cross-env": "^5.1.1",
"enzyme": "^3.2.0",
"enzyme-adapter-react-16": "^1.1.0",
"jest": "^21.2.1",
"parcel-bundler": "^1.2.0",
"rimraf": "^2.6.2"
},
"dependencies": {
"apollo-cache-inmemory": "^1.1.4",
"apollo-client": "^2.0.4",
"apollo-link-http": "^1.3.1",
"cheerio": "^1.0.0-rc.2",
"express": "^4.16.2",
"graphql": "^0.11.7",
"graphql-tag": "^2.6.0",
"node-fetch": "^1.7.3",
"object-assign": "^4.1.1",
"promise": "^8.0.1",
"raf": "^3.4.0",
"react": "^16.2.0",
"react-apollo": "^2.0.4",
"react-dom": "^16.2.0",
"react-helmet": "^5.2.0",
"react-router-dom": "^4.2.2",
"whatwg-fetch": "^2.0.3"
"react-router-dom": "^4.2.2"
},
"devDependencies": {
"node-sass": "^4.7.2",
"parcel-bundler": "^1.6.1",
"rimraf": "^2.6.2"
}
}

@@ -1,25 +0,33 @@

# Example of server-side rendering with React.js and ParcelJS
# parcel-react-ssr
Complete example of a React.js with server-side rendering and bundled with ParcelJS. It includes:
Simple example of how to do server-rendering. You will not believe how easy it is!
- React.js - UI library
- React Helmet - SEO library - Manage your `<head />` and page title
- React Router - URL Router
- Apollo Client - GraphQL client
- Communicate with GitHub GraphQL API as an example
Using:
## Development
In development, you don't have server-side rendering. All you need to do is `npm start`.
* parcel-bundler
* react
* react-router-dom
* react-helmet (SEO)
## Production
To run into production, you need to build first and then you can run the app using the express server.
## How to run
- `npm run build`
- `node server`
* `npm run dev` - Run the development server with hot reload but no server-rendering
* `npm run build` - Build for production, required before running
* `npm start` - Start the production server
## How is this working?
There is two build: one for the browser using Parcel.js and one for Node.js using BabelJS.
## How does it work?
The parcel build is in dist/client and is a regular build just like you would do without server-side rendering.
To do proper server-rendering, the code is bundled in two version: one for the browser and one for Node.js.
The Node.js build is in dist/client and is only transformed through BabelJS. It uses a babel plugin to ignore the file extensions that should not be executed through the server. You can add your own!
The browser version is in the `dist/client` folder and the Node.js version is in `dist/server`. However, they both share the same public path for their files: `/dist` and it points to the browser version. Go read the code, it's pretty straightforward!
## Read the code!
1. [package.json](package.json) - Start by reading the `scripts` section to understand how the build process works. Yes it's that dead simple!
1. [app/index.html](app/index.html) - Your only HTML file acting as a template
1. [app/App.jsx](app/App.jsx) - Your main application component shared between your browser and Node.js version
1. [app/HelloWorld.jsx](app/HelloWorld.jsx) - Dead simple hello world
1. [app/HelloWorld.scss](app/HelloWorld.scss) - Example of SCSS
1. [server/index.js](server/index.js) - Entry point for your Node.js version
1. [server/middleware.js](server/middleware.js) - Middleware taking care of server-rendering
1. [server/generateHtml.js](server/generateHtml.js) - Generate the HTML using `index.html` as the template with cheerio

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc