Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
@vavra7/compiler
Advanced tools
It runs Webpack under the hood to bundle application. Client part and server part allowing React to be server side rendered.
Readme
It runs Webpack under the hood to bundle application. Client part and server part allowing React to be server side rendered.
SSR React app written in Typescript
compiler dev
compiler build
compiler build -a
.
├── dist
│ ├── bundles.json
│ ├── index.js
│ └── static
│ ├── js
│ │ ├── main.js
│ │ ├── main.js.gz
│ │ ├── react.js
│ │ └── react.js.gz
│ └── media
│ └── 6576f3a9a340ac02328d.jpg
├── node_modules
├── public
│ └── favicon.ico
├── src
│ ├── assets
│ │ └── media
│ │ └── logo.jpg
│ ├── index.client.tsx
│ ├── index.server.tsx
│ └── root.tsx
├── package.json
└── tsconfig.json
import type { FC } from 'react';
import React from 'react';
const Root: FC = () => {
return (
<>
<img alt="logo" className="App-logo" src={require('./assets/media/logo.jpg')} />
<div>Root of React application.</div>
</>
);
};
export default Root;
import fs from 'node:fs';
import path from 'node:path';
import express from 'express';
import React from 'react';
import { renderToString } from 'react-dom/server';
import Root from './root';
const app = express();
const bundles = JSON.parse(fs.readFileSync(path.join(__dirname, './bundles.json'), 'utf-8'));
app.use('/', express.static(path.join(__dirname, '../public')));
app.use(
'/static',
(req, res, next) => {
if (req.originalUrl.match(/^\/static\/js\/.*.js$/)) {
req.url = req.url + '.gz';
res.set('Cache-Control', 'max-age=2147483647');
res.set('Content-Encoding', 'gzip');
res.set('Content-Type', 'text/javascript');
}
next();
},
express.static(path.join(__dirname, './static'))
);
app.use('*', (req, res) => {
const app = <Root />;
const markup = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="${bundles['main.js']}" defer></script>
<script src="${bundles['react.js']}" defer></script>
<title>Document</title>
</head>
<body>
<div id="root-container">
${renderToString(app)}
</div>
</body>
</html>
`;
res.setHeader('Content-Type', 'text/html');
res.end(markup);
});
app.listen(3000, () => console.log('Server is listening on http://localhost:3000'));
import React from 'react';
import { createRoot } from 'react-dom/client';
import Root from './root';
if (module?.hot) module.hot.accept();
const container = document.getElementById('root-container');
const root = createRoot(container!);
root.render(<Root />);
https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/725
FAQs
It runs Webpack under the hood to bundle application. Client part and server part allowing React to be server side rendered.
We found that @vavra7/compiler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).