Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
remix-express-dev-server
Advanced tools
This package includes a Vite plugin to use in your Remix app. It imports the Express app you create in entry.server.tsx.
This package is a Vite plugin that loads your Express app in development. It
expects the app to have been created in your entry.server.tsx file via the
createExpressApp
help.
Install the following npm package:
npm install -D remix-express-dev-server
Add the Vite plugin to your vite.config.ts file. Also, configure
build.target='esnext'
to support top-level await.
import { expressDevServer } from 'remix-express-dev-server'
import { vitePlugin as remix } from '@remix-run/dev'
import { defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
export default defineConfig({
build: {
target: 'esnext',
},
plugins: [
expressDevServer(), // add expressDevServer plugin
remix(),
tsconfigPaths(),
],
})
The expressDevServer
plugin also accepts options:
export type DevServerOptions = {
entry?: string // Express app entry: default = 'virtual:remix/server-build'
entryName?: string // name of express app export: default = app
appDirectory?: string // path to remix app directory: default = ./app
configureServer?: (server: http.Server) => void // allow additional configuration
// of Vite dev server (like setting up socket.io)
}
The scripts
for dev
and build
have been simplified.
Update scripts
in your package.json file. For development, Vite will handle
starting express and calling Remix to build your app, so simply call vite
.
For building, Remix will build your app and create the server and client bundles.
The server bundle is in ./build/server/index.js
To run your production build, call node ./build/server/index.js
Make sure to set NODE_ENV=production
, otherwise it will not create your server.
{
"scripts": {
"dev": "vite",
"build": "remix vite:build",
"start": "NODE_ENV=production node ./build/server/index.js"
}
}
You can wrap the Vite dev server with the socket.io server.
NOTE:
configureServer
is only called for development. In production, use thecreateExpressApp({ createServer })
function to initialize socket.io. You can import same init function in both places.
// vite.config.ts
export default defineConfig({
plugins: [
expressDevServer({
configureServer(server) {
const io = new Server(server)
io.on('upgrade', async (req, socket, head) => {
console.log(
`Attemping to upgrade connection at url ${
req.url
} with headers: ${JSON.stringify(req.headers)}`,
)
socket.on('error', err => {
console.error('Connection upgrade error:', err)
})
console.log(`Client connected, upgrading their connection...`)
})
io.on('connection', socket => {
console.log('Client connected')
socket.emit('server', 'hello from server')
socket.on('client', data => {
console.log('Client sent:', data)
socket.emit('server', data)
})
socket.on('disconnect', () => {
console.log('Client disconnected')
})
})
},
}),
// ...
],
})
FAQs
This package includes a Vite plugin to use in your Remix app. It imports the Express app you create in entry.server.tsx.
The npm package remix-express-dev-server receives a total of 6,698 weekly downloads. As such, remix-express-dev-server popularity was classified as popular.
We found that remix-express-dev-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.