Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure core files for easier layer matching #61

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/aws-app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ export default function createConfigs(_env, argv) {
module: {
rules: [
{
resource: [/rsc\.ts$/, /\/app\.tsx$/],
resource: [/\/server\/rsc\//, /\/app\.tsx$/],
layer: webpackRscLayerName,
},
{
// AsyncLocalStorage module instances must be in a shared layer.
resource: /\/server\/shared\//,
layer: `shared`,
test: /(router-location-async-local-storage|use-router-location)/,
},
{
issuerLayer: webpackRscLayerName,
Expand Down
5 changes: 2 additions & 3 deletions apps/cloudflare-app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,12 @@ export default function createConfigs(_env, argv) {
module: {
rules: [
{
resource: [/rsc\.ts$/, /\/app\.tsx$/],
resource: [/\/server\/rsc\//, /\/app\.tsx$/],
layer: webpackRscLayerName,
},
{
// AsyncLocalStorage module instances must be in a shared layer.
resource: /\/server\/shared\//,
layer: `shared`,
test: /(router-location-async-local-storage|use-router-location)/,
},
{
issuerLayer: webpackRscLayerName,
Expand Down
5 changes: 2 additions & 3 deletions apps/vercel-app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,12 @@ export default function createConfigs(_env, argv) {
module: {
rules: [
{
resource: [/rsc\.ts$/, /\/app\.tsx$/],
resource: [/\/server\/rsc\//, /\/app\.tsx$/],
layer: webpackRscLayerName,
},
{
// AsyncLocalStorage module instances must be in a shared layer.
resource: /\/server\/shared\//,
layer: `shared`,
test: /(router-location-async-local-storage|use-router-location)/,
},
{
issuerLayer: webpackRscLayerName,
Expand Down
16 changes: 8 additions & 8 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
"default": "./lib/client/browser.js"
},
"./server/rsc": {
"@mfng:internal": "./src/server/rsc.ts",
"default": "./lib/server/rsc.js"
"@mfng:internal": "./src/server/rsc/index.ts",
"default": "./lib/server/rsc/index.js"
},
"./server/ssr": {
"@mfng:internal": "./src/server/ssr.ts",
"default": "./lib/server/ssr.js"
"@mfng:internal": "./src/server/ssr/index.ts",
"default": "./lib/server/ssr/index.js"
},
"./use-router-location": {
"@mfng:internal:node": "./src/server/use-router-location.ts",
"@mfng:internal:node": "./src/server/shared/use-router-location.ts",
"@mfng:internal": "./src/client/use-router-location.ts",
"types": "./lib/use-router-location.d.ts",
"node": "./lib/server/use-router-location.js",
"node": "./lib/server/shared/use-router-location.js",
"default": "./lib/client/use-router-location.js"
},
"./router-location-async-local-storage": {
"@mfng:internal": "./src/server/router-location-async-local-storage.ts",
"default": "./lib/server/router-location-async-local-storage.js"
"@mfng:internal": "./src/server/shared/router-location-async-local-storage.ts",
"default": "./lib/server/shared/router-location-async-local-storage.js"
}
},
"files": [
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AsyncLocalStorage} from 'node:async_hooks';
import type {RouterLocation} from '../use-router-location.js';
import type {RouterLocation} from '../../use-router-location.js';

export const routerLocationAsyncLocalStorage =
new AsyncLocalStorage<RouterLocation>();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {RouterLocation} from '../use-router-location.js';
import type {RouterLocation} from '../../use-router-location.js';
import {routerLocationAsyncLocalStorage} from './router-location-async-local-storage.js';

export function useRouterLocation(): RouterLocation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type {ReactFormState} from 'react-dom/server';
import ReactDOMServer from 'react-dom/server.edge';
import type {SSRManifest} from 'react-server-dom-webpack';
import ReactServerDOMClient from 'react-server-dom-webpack/client.edge';
import type {RscAppResult} from '../rsc/create-rsc-app-stream.js';
import {createBufferedTransformStream} from './create-buffered-transform-stream.js';
import {createInitialRscResponseTransformStream} from './create-initial-rsc-response-transform-stream.js';
import type {RscAppResult} from './create-rsc-app-stream.js';

export interface CreateHtmlStreamOptions {
readonly reactSsrManifest: SSRManifest;
Expand Down
File renamed without changes.
9 changes: 7 additions & 2 deletions packages/webpack-rsc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@ const serverConfig = {
module: {
rules: [
{
// Match the resource path of the modules that create RSC streams, e.g.:
resource: (value) => /create-rsc-\w+-stream\.tsx?$/.test(value),
// Match the entry modules that should end up in the RSC layer:
resource: [/\/server\/rsc\//, /\/app\.tsx$/],
layer: webpackRscLayerName,
},
{
// Match the modules that should end up in a shared layer (RSC & SSR):
resource: /\/server\/shared\//,
layer: 'shared',
},
{
issuerLayer: webpackRscLayerName,
resolve: {conditionNames: ['react-server', '...']},
Expand Down