File tree Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " react-server-renderer " : patch
3+ ---
4+
5+ fix: better compatible with webpack v4/v5
Original file line number Diff line number Diff line change 1+ lts/*
Original file line number Diff line number Diff line change @@ -38,14 +38,14 @@ export class ReactSSRServerPlugin implements WebpackPluginInstance {
3838
3939 const entry = entryAssets [ 0 ]
4040 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
41- if ( ! entry || typeof entry !== 'string' ) {
41+ if ( ! entry ) {
4242 throw new Error (
4343 `Entry "${ entryName } " not found. Did you specify the correct entry option?` ,
4444 )
4545 }
4646
4747 const bundle = {
48- entry,
48+ entry : typeof entry === 'string' ? entry : entry . name ,
4949 files : { } as Record < string , Buffer | string > ,
5050 maps : { } as Record < string , unknown > ,
5151 }
Original file line number Diff line number Diff line change @@ -9,18 +9,21 @@ export const warn = (msg: string) => console.error(red(`${prefix} ${msg}\n`))
99export const tip = ( msg : string ) => console . log ( yellow ( `${ prefix } ${ msg } \n` ) )
1010
1111export const validate = ( compiler : Compiler ) => {
12- if ( compiler . options . target !== 'node' ) {
12+ const { externals, output, target } = compiler . options
13+
14+ if ( target !== 'node' ) {
1315 warn ( 'webpack config `target` should be "node".' )
1416 }
1517
1618 if (
19+ output . library ?. type !== 'commonjs2' &&
1720 // @ts -expect-error -- compatibility
18- compiler . options . output . libraryTarget !== 'commonjs2'
21+ output . libraryTarget !== 'commonjs2'
1922 ) {
2023 warn ( 'webpack config `output.libraryTarget` should be "commonjs2".' )
2124 }
2225
23- if ( ! compiler . options . externals ) {
26+ if ( ! externals ) {
2427 tip (
2528 'It is recommended to externalize dependencies in the server build for ' +
2629 'better build performance.' ,
You can’t perform that action at this time.
0 commit comments