Skip to content

Commit c2d9fe9

Browse files
ahabhgkSyMind
authored andcommitted
fix: missing some module in server/edge server compile
1 parent 0b97657 commit c2d9fe9

File tree

5 files changed

+58
-42
lines changed

5 files changed

+58
-42
lines changed

crates/node_binding/binding.d.ts

+50-4
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export declare class JsModule {
253253
get resourceResolveData(): JsResourceData | undefined
254254
get matchResource(): string | undefined
255255
emitFile(filename: string, source: JsCompatSource, assetInfo: JsAssetInfo): void
256-
buildInfo(): object
256+
get buildInfo(): Record<string, any>
257257
}
258258

259259
export declare class JsModuleGraph {
@@ -280,7 +280,7 @@ export declare class JsModuleGraphConnection {
280280

281281
export declare class JsResolver {
282282
resolveSync(path: string, request: string): string | false
283-
withOptions(JsResolver): JsResolverWrapper
283+
withOptions(raw?: RawResolveOptionsWithDependencyType | undefined | null): JsResolver
284284
}
285285

286286
export declare class JsResolverFactory {
@@ -380,7 +380,8 @@ export declare enum BuiltinPluginName {
380380
RsdoctorPlugin = 'RsdoctorPlugin',
381381
JsLoaderRspackPlugin = 'JsLoaderRspackPlugin',
382382
LazyCompilationPlugin = 'LazyCompilationPlugin',
383-
SubresourceIntegrityPlugin = 'SubresourceIntegrityPlugin'
383+
SubresourceIntegrityPlugin = 'SubresourceIntegrityPlugin',
384+
FlightClientEntryPlugin = 'FlightClientEntryPlugin'
384385
}
385386

386387
export declare function cleanupGlobalTrace(): void
@@ -392,6 +393,11 @@ export interface ContextInfo {
392393

393394
export declare function formatDiagnostic(diagnostic: JsDiagnostic): ExternalObject<'Diagnostic'>
394395

396+
export interface JsAction {
397+
workers: Record<string, JsModuleInfo>
398+
layer: Record<string, string>
399+
}
400+
395401
export interface JsAddingRuntimeModule {
396402
name: string
397403
generator: () => String
@@ -685,7 +691,7 @@ export interface JsExternalItemFnCtx {
685691
context: string
686692
dependencyType: string
687693
contextInfo: ContextInfo
688-
resolver: JsResolverWrapper
694+
resolver: JsResolver
689695
}
690696

691697
export interface JsFactorizeArgs {
@@ -698,6 +704,18 @@ export interface JsFactoryMeta {
698704
sideEffectFree?: boolean
699705
}
700706

707+
export interface JsFlightClientEntryPluginState {
708+
serverActions: Record<string, JsAction>
709+
edgeServerActions: Record<string, JsAction>
710+
serverActionModules: Record<string, JsModulePair>
711+
edgeServerActionModules: Record<string, JsModulePair>
712+
ssrModules: Record<string, JsModuleInfo>
713+
edgeSsrModules: Record<string, JsModuleInfo>
714+
rscModules: Record<string, JsModuleInfo>
715+
edgeRscModules: Record<string, JsModuleInfo>
716+
injectedClientEntries: Record<string, string>
717+
}
718+
701719
export interface JsHtmlPluginAssets {
702720
publicPath: string
703721
js: Array<string>
@@ -806,6 +824,16 @@ export interface JsModuleDescriptor {
806824
id?: string
807825
}
808826

827+
export interface JsModuleInfo {
828+
moduleId: string
829+
isAsync: boolean
830+
}
831+
832+
export interface JsModulePair {
833+
server?: JsModuleInfo
834+
client?: JsModuleInfo
835+
}
836+
809837
export interface JsNormalModuleFactoryCreateModuleArgs {
810838
dependencyType: string
811839
rawRequest: string
@@ -1054,6 +1082,13 @@ export interface JsRuntimeRequirementInTreeResult {
10541082
runtimeRequirements: JsRuntimeGlobals
10551083
}
10561084

1085+
export interface JsShouldInvalidateCbCtx {
1086+
entryName: string
1087+
absolutePagePath: string
1088+
bundlePath: string
1089+
clientBrowserLoader: string
1090+
}
1091+
10571092
export interface JsStatsAsset {
10581093
type: string
10591094
name: string
@@ -1666,6 +1701,17 @@ export interface RawFlagAllModulesAsUsedPluginOptions {
16661701
explanation: string
16671702
}
16681703

1704+
export interface RawFlightClientEntryPluginOptions {
1705+
dev: boolean
1706+
appDir: string
1707+
isEdgeServer: boolean
1708+
encryptionKey: string
1709+
builtinAppLoader: boolean
1710+
shouldInvalidateCb: (ctx: JsShouldInvalidateCbCtx) => boolean
1711+
invalidateCb: () => void
1712+
stateCb: (state: JsFlightClientEntryPluginState) => void
1713+
}
1714+
16691715
export interface RawFuncUseCtx {
16701716
resource?: string
16711717
realResource?: string

crates/node_binding/package.json

+4-19
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,10 @@
1414
"binding.d.ts"
1515
],
1616
"scripts": {
17-
"build:debug": "node scripts/build.js",
18-
"watch:debug": "node scripts/build.js --watch",
19-
"build:debug:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js",
20-
"build:debug:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js",
21-
"build:release": "node scripts/build.js --release",
22-
"watch:release": "node scripts/build.js --release --watch",
23-
"build:release:arm64": "cross-env RUST_TARGET=aarch64-apple-darwin node scripts/build.js --release",
24-
"build:release:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js --release",
25-
"build:release:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js --release",
26-
"build:release:musl": "cross-env RUST_TARGET=aarch64-unknown-linux-musl node scripts/build.js --release",
27-
"build:release:win": "cross-env RUST_TARGET=x86_64-pc-windows-msvc node scripts/build.js --release",
28-
"build:release-prod": "node scripts/build.js --release-prod",
29-
"watch:release-prod": "node scripts/build.js --release-prod --watch",
30-
"build:release-prod:arm64": "cross-env RUST_TARGET=aarch64-apple-darwin node scripts/build.js --release-prod",
31-
"build:release-prod:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js --release-prod",
32-
"build:release-prod:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js --release-prod",
33-
"build:release-prod:win": "cross-env RUST_TARGET=x86_64-pc-windows-msvc node scripts/build.js --release-prod",
34-
"build:release-debug": "node scripts/build.js --release-debug",
35-
"build:release-dev": "node scripts/build.js --release-dev",
17+
"build:dev": "node scripts/build.js",
18+
"build:ci": "node scripts/build.js --profile ci",
19+
"build:profiling": "node scripts/build.js --profile profiling",
20+
"build:release": "node scripts/build.js --profile release",
3621
"move-binding": "node scripts/move-binding",
3722
"test": "tsc -p tsconfig.type-test.json"
3823
},

crates/rspack_plugin_next_flight_client_entry/src/lib.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use serde_json::json;
4848
use sugar_path::SugarPath;
4949

5050
static NEXT_DIST_ESM_REGEX: Lazy<Regex> =
51-
Lazy::new(|| Regex::new("[\\/]next[\\/]dist[\\/]esm[\\/]").unwrap());
51+
Lazy::new(|| Regex::new(r"[\\/]next[\\/]dist[\\/]esm[\\/]").unwrap());
5252

5353
static NEXT_DIST: Lazy<String> = Lazy::new(|| {
5454
format!(
@@ -1485,10 +1485,7 @@ async fn after_emit(&self, compilation: &mut Compilation) -> Result<()> {
14851485
}
14861486
}
14871487
}
1488-
if mod_resource.contains("app/style.css") {
1489-
dbg!(module.get_layer());
1490-
dbg!(module.identifier());
1491-
}
1488+
14921489
if module.get_layer().map(|layer| layer.as_str())
14931490
!= Some(WEBPACK_LAYERS.server_side_rendering)
14941491
{
@@ -1543,11 +1540,7 @@ async fn after_emit(&self, compilation: &mut Compilation) -> Result<()> {
15431540
&& let Some(module) = module.as_concatenated_module()
15441541
{
15451542
for m in module.get_modules() {
1546-
if let Some(module_id) =
1547-
ChunkGraph::get_module_id(&compilation.module_ids_artifact, m.id)
1548-
{
1549-
record_module(module_id, &m.id);
1550-
}
1543+
record_module(module_id, &m.id);
15511544
}
15521545
}
15531546
}

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
"build:binding:dev": "pnpm --filter @rspack/binding run build:dev",
3232
"build:binding:ci": "pnpm --filter @rspack/binding run build:ci",
3333
"build:binding:release": "pnpm --filter @rspack/binding run build:release",
34-
"build:binding:release-debug": "pnpm --filter @rspack/binding run build:release-debug",
35-
"build:binding:release-prod": "pnpm --filter @rspack/binding run build:release-prod",
36-
"build:binding:release-dev": "pnpm --filter @rspack/binding run build:release-dev",
34+
"build:binding:profiling": "pnpm --filter @rspack/binding run build:profiling",
3735
"prepare": "is-ci || husky",
3836
"test:diff": "pnpm --filter \"@rspack/*\" test:diff",
3937
"test:hot": "pnpm --filter \"@rspack/*\" test:hot",

packages/rspack/src/ModuleGraph.ts

-6
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ export default class ModuleGraph {
8080
.map(binding => ModuleGraphConnection.__from_binding(binding));
8181
}
8282

83-
getIncomingConnections(module: Module): ModuleGraphConnection[] {
84-
return this.#inner
85-
.getIncomingConnections(Module.__to_binding(module))
86-
.map(binding => ModuleGraphConnection.__from_binding(binding));
87-
}
88-
8983
getParentBlockIndex(dependency: Dependency): number {
9084
const depBinding = bindingDependencyFactory.getBinding(dependency);
9185
if (depBinding) {

0 commit comments

Comments
 (0)