@@ -43,109 +43,115 @@ const nodeModulesPaths = [
4343
4444const hermesParserPath = require . resolve ( "hermes-parser" ) ;
4545
46- export default withRozenite (
47- Repack . defineRspackConfig ( env => {
48- const { mode, platform } = env ;
46+ const withRozeniteUrlFix = rozeniteConfig => {
47+ return async env => {
48+ const config = await rozeniteConfig ( env ) ;
49+ if ( ! config . devServer ?. setupMiddlewares ) {
50+ return config ;
51+ }
52+
53+ const originalSetupMiddlewares = config . devServer . setupMiddlewares ;
54+
4955 return {
50- mode,
51- context : __dirname ,
52- entry : "./index.js" ,
53- resolve : {
54- ...Repack . getResolveOptions ( platform , {
55- enablePackageExports : true ,
56- preferNativePlatform : true ,
57- } ) ,
58- fullySpecified : false ,
59- modules : nodeModulesPaths ,
60- extensions : [
61- `.${ platform } .tsx` ,
62- `.${ platform } .ts` ,
63- `.${ platform } .jsx` ,
64- `.${ platform } .js` ,
65- ".native.tsx" ,
66- ".native.ts" ,
67- ".native.jsx" ,
68- ".native.js" ,
69- ".tsx" ,
70- ".ts" ,
71- ".jsx" ,
72- ".js" ,
73- ".mjs" ,
74- ".cjs" ,
75- ".json" ,
76- "..." ,
77- ] ,
78- enforceExtension : false ,
79- mainFields : [ "react-native" , "browser" , "main" , "module" ] ,
80- conditionNames : [ "require" , "react-native" , "browser" ] ,
81- alias : {
82- ...buildTsAlias ( tsconfig . compilerOptions . paths ) ,
83- // Packages with malformed exports field (missing "." subpath) - resolve to browser entry
84- "@aptos-labs/aptos-client" : resolveFromPnpmSubmodule (
85- "node_modules" ,
86- "@aptos-labs" ,
87- "aptos-client" ,
88- "dist" ,
89- "browser" ,
90- "index.browser.mjs" ,
91- ) ,
92- "rpc-websockets" : resolveFromPnpmSubmodule (
93- "node_modules" ,
94- "rpc-websockets" ,
95- "dist" ,
96- "index.browser.mjs" ,
97- ) ,
98- } ,
99- fallback : {
100- ...require ( "node-libs-react-native" ) ,
101- fs : require . resolve ( "react-native-level-fs" ) ,
102- net : require . resolve ( "react-native-tcp-socket" ) ,
103- tls : false ,
104- child_process : false ,
105- cluster : false ,
106- dgram : false ,
107- dns : false ,
108- readline : false ,
109- module : false ,
110- repl : false ,
111- vm : false ,
56+ ...config ,
57+ devServer : {
58+ ...config . devServer ,
59+ setupMiddlewares : middlewares => {
60+ const result = originalSetupMiddlewares ( middlewares ) ;
61+ result . unshift ( ( req , res , next ) => {
62+ if ( req . url ?. startsWith ( "/debugger-frontend/" ) ) {
63+ const newUrl = req . url . replace ( "/debugger-frontend/" , "/rozenite/" ) ;
64+ res . writeHead ( 302 , { Location : newUrl } ) ;
65+ res . end ( ) ;
66+ return ;
67+ }
68+ next ( ) ;
69+ } ) ;
70+
71+ return result ;
11272 } ,
11373 } ,
114- module : {
115- rules : [
116- {
117- test : / \. [ c m ] ? [ j t ] s x ? $ / ,
118- use : {
119- loader : "@callstack/repack/babel-loader" ,
120- parallel : true ,
121- options : {
122- hermesParserPath,
74+ } ;
75+ } ;
76+ } ;
77+
78+ export default withRozeniteUrlFix (
79+ withRozenite (
80+ Repack . defineRspackConfig ( env => {
81+ const { mode, platform } = env ;
82+ return {
83+ mode,
84+ context : __dirname ,
85+ entry : "./index.js" ,
86+ resolve : {
87+ ...Repack . getResolveOptions ( platform , {
88+ enablePackageExports : true ,
89+ preferNativePlatform : true ,
90+ } ) ,
91+ modules : nodeModulesPaths ,
92+ alias : {
93+ ...buildTsAlias ( tsconfig . compilerOptions . paths ) ,
94+ // Packages with malformed exports field (missing "." subpath) - resolve to browser entry
95+ "@aptos-labs/aptos-client" : resolveFromPnpmSubmodule (
96+ "node_modules" ,
97+ "@aptos-labs" ,
98+ "aptos-client" ,
99+ "dist" ,
100+ "browser" ,
101+ "index.browser.mjs" ,
102+ ) ,
103+ "rpc-websockets" : resolveFromPnpmSubmodule (
104+ "node_modules" ,
105+ "rpc-websockets" ,
106+ "dist" ,
107+ "index.browser.mjs" ,
108+ ) ,
109+ } ,
110+ fallback : {
111+ ...require ( "node-libs-react-native" ) ,
112+ fs : require . resolve ( "react-native-level-fs" ) ,
113+ net : require . resolve ( "react-native-tcp-socket" ) ,
114+ tls : false ,
115+ child_process : false ,
116+ cluster : false ,
117+ dgram : false ,
118+ dns : false ,
119+ readline : false ,
120+ module : false ,
121+ repl : false ,
122+ vm : false ,
123+ } ,
124+ } ,
125+ module : {
126+ rules : [
127+ {
128+ test : / \. [ c m ] ? [ j t ] s x ? $ / ,
129+ use : {
130+ loader : "@callstack/repack/babel-loader" ,
131+ parallel : true ,
132+ options : {
133+ hermesParserPath,
134+ } ,
123135 } ,
136+ resolve : {
137+ fullySpecified : false ,
138+ } ,
139+ type : "javascript/auto" ,
124140 } ,
125- resolve : {
126- fullySpecified : false ,
127- } ,
128- type : "javascript/auto" ,
129- } ,
130- ...Repack . getAssetTransformRules ( ) ,
141+ ...Repack . getAssetTransformRules ( ) ,
142+ ] ,
143+ } ,
144+ plugins : [
145+ new Repack . RepackPlugin ( ) ,
146+ new ReanimatedPlugin ( {
147+ unstable_disableTransform : true ,
148+ } ) ,
149+ new ExpoModulesPlugin ( ) ,
131150 ] ,
132- } ,
133- plugins : [
134- new Repack . RepackPlugin ( ) ,
135- new ReanimatedPlugin ( {
136- unstable_disableTransform : true ,
137- } ) ,
138- new ExpoModulesPlugin ( ) ,
139- ] ,
140- } ;
141- } ) ,
142- {
143- enabled : process . env . WITH_ROZENITE === "true" ,
144- include : [
145- "@rozenite/network-activity-plugin" ,
146- "@rozenite/react-navigation-plugin" ,
147- "@rozenite/redux-devtools-plugin" ,
148- "@rozenite/mmkv-plugin" ,
149- ] ,
150- } ,
151+ } ;
152+ } ) ,
153+ {
154+ enabled : process . env . WITH_ROZENITE === "true" ,
155+ } ,
156+ ) ,
151157) ;
0 commit comments