1
- import type {
2
- javascript ,
3
- LoaderContext ,
4
- NormalModule ,
5
- webpack ,
1
+ import {
2
+ ModuleFilenameHelpers ,
3
+ type javascript ,
4
+ type LoaderContext ,
5
+ type NormalModule ,
6
+ type webpack ,
6
7
} from 'next/dist/compiled/webpack/webpack'
7
8
import { RSC_MOD_REF_PROXY_ALIAS } from '../../../../lib/constants'
8
9
import {
@@ -13,7 +14,6 @@ import { warnOnce } from '../../../../shared/lib/utils/warn-once'
13
14
import { getRSCModuleInformation } from '../../../analysis/get-page-static-info'
14
15
import { formatBarrelOptimizedResource } from '../../utils'
15
16
import { getModuleBuildInfo } from '../get-module-build-info'
16
- import { ModuleFilenameHelpers } from 'next/dist/compiled/webpack/webpack'
17
17
18
18
type SourceType = javascript . JavascriptParser [ 'sourceType' ] | 'commonjs'
19
19
@@ -148,19 +148,21 @@ ${JSON.stringify(ref)},
148
148
}
149
149
150
150
const compilation = this . _compilation !
151
- const originalSourceURL = ModuleFilenameHelpers . createFilename (
152
- module ,
153
- {
154
- moduleFilenameTemplate :
155
- 'webpack://[namespace]/[resource-path]/__nextjs-internal-proxy.mjs' ,
156
- namespace : '_N_E' ,
157
- } ,
158
- {
159
- requestShortener : compilation . requestShortener ,
160
- chunkGraph : compilation . chunkGraph ,
161
- hashFunction : compilation . outputOptions . hashFunction ,
162
- }
163
- )
151
+ const originalSourceURL = process . env . NEXT_RSPACK
152
+ ? `webpack://_N_E/${ this . utils . contextify ( this . context || this . rootContext , this . resourcePath ) } /__nextjs-internal-proxy.mjs`
153
+ : ModuleFilenameHelpers . createFilename (
154
+ module ,
155
+ {
156
+ moduleFilenameTemplate :
157
+ 'webpack://[namespace]/[resource-path]/__nextjs-internal-proxy.mjs' ,
158
+ namespace : '_N_E' ,
159
+ } ,
160
+ {
161
+ requestShortener : compilation . requestShortener ,
162
+ chunkGraph : compilation . chunkGraph ,
163
+ hashFunction : compilation . outputOptions . hashFunction ,
164
+ }
165
+ )
164
166
165
167
return this . callback ( null , esmSource , {
166
168
version : 3 ,
@@ -179,19 +181,21 @@ module.exports = createProxy(${stringifiedResourceKey})
179
181
`
180
182
181
183
const compilation = this . _compilation !
182
- const originalSourceURL = ModuleFilenameHelpers . createFilename (
183
- module ,
184
- {
185
- moduleFilenameTemplate :
186
- 'webpack://[namespace]/[resource-path]/__nextjs-internal-proxy.cjs' ,
187
- namespace : '_N_E' ,
188
- } ,
189
- {
190
- requestShortener : compilation . requestShortener ,
191
- chunkGraph : compilation . chunkGraph ,
192
- hashFunction : compilation . outputOptions . hashFunction ,
193
- }
194
- )
184
+ const originalSourceURL = process . env . NEXT_RSPACK
185
+ ? `webpack://_N_E/${ this . utils . contextify ( this . context || this . rootContext , this . resourcePath ) } /__nextjs-internal-proxy.cjs`
186
+ : ModuleFilenameHelpers . createFilename (
187
+ module ,
188
+ {
189
+ moduleFilenameTemplate :
190
+ 'webpack://[namespace]/[resource-path]/__nextjs-internal-proxy.cjs' ,
191
+ namespace : '_N_E' ,
192
+ } ,
193
+ {
194
+ requestShortener : compilation . requestShortener ,
195
+ chunkGraph : compilation . chunkGraph ,
196
+ hashFunction : compilation . outputOptions . hashFunction ,
197
+ }
198
+ )
195
199
196
200
return this . callback ( null , cjsSource , {
197
201
version : 3 ,
0 commit comments