Skip to content

Commit

Permalink
Restructure core files for easier layer matching
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Mar 15, 2024
1 parent 5321f4e commit b41073b
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 22 deletions.
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 @@ -8,7 +8,7 @@ import type {SSRManifest} from 'react-server-dom-webpack';
import ReactServerDOMClient from 'react-server-dom-webpack/client.edge';
import {createBufferedTransformStream} from './create-buffered-transform-stream.js';

Check failure on line 9 in packages/core/src/server/ssr/create-html-stream.tsx

View workflow job for this annotation

GitHub Actions / lint

`./create-buffered-transform-stream.js` import should occur after type import of `../rsc/create-rsc-app-stream.js`
import {createInitialRscResponseTransformStream} from './create-initial-rsc-response-transform-stream.js';

Check failure on line 10 in packages/core/src/server/ssr/create-html-stream.tsx

View workflow job for this annotation

GitHub Actions / lint

`./create-initial-rsc-response-transform-stream.js` import should occur after type import of `../rsc/create-rsc-app-stream.js`
import type {RscAppResult} from './create-rsc-app-stream.js';
import type {RscAppResult} from '../rsc/create-rsc-app-stream.js';

export interface CreateHtmlStreamOptions {
readonly reactSsrManifest: SSRManifest;
Expand Down
File renamed without changes.
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

0 comments on commit b41073b

Please sign in to comment.