react / react/metro

Server Bundles? (requiring native NodeJS modules)

Open
#479 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.6k
Forks
696
Avg merge
8m
Merged PRs (30d)
7

Description

I'm hoping to use Metro to bundle a server-rendered React Native Web app. (Of course I already use Metro for RN.. I'm just trying to leave webpack 😝)

curl http://localhost:8081/web/Server.js.bundle | node

It works great until I actually include anything from node:

const http = require("http");

This require statement should NOT be transpiled, but the rest of the requires should get rolled up into the bundle. Is there any way to configure Metro for this?

PS: Meanwhile I'll be using Razzle, which quite sadly runs two webpack instances for the client and server.
PPS: Alternatively I was considering tsc to handle the JSX(tsx) compilation on the server, and tsc-node-dev during development. But there are drawbacks.. X.web.js files are ignored, and things will break when requiring local image assets.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the server bundle with curl http://localhost:8081/web/Server.js.bundle | node, including const http = require("http"). Start by investigating Metro's server-bundle configuration and module resolution behavior; done means native Node.js requires remain external while application requires are bundled.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, react-native
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.