[cli] fix js inspector is broken when using web SSG #23197
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
when web SSG is enabled, pressing
j
to open js inspector is broken:How
originally we have #21068 fix for the HistoryFallbackMiddleware. the new middleware for SSG unfortunately does not have the fix.
i feel like the root cause is coming from middleware disorder. digging the code in deep, i found we've chained the
connect
app. themiddleware
returned fromMetro.createConnectMiddleware
is actually a connect app, because rn-cli will set theenhanceMiddleware
and it creates theconnect
app under the hood.this pr tries to reuse the connect app. without the connect app chaining, those web middlewares will be placed after the inspector proxy middleware.
also removed the #21068 hack for HistoryFallbackMiddleware in this pr.
Code References
expo/packages/@expo/cli/src/start/server/metro/runServer-fork.ts
Lines 63 to 67 in c1f7b41
Test Plan
after the fix, i've checked:
j
http://localhost:8081/json/list
returns an arrayhttp://localhost:8081/helloweb
returns a html content"output": "static"
in app.json), checkhttp://localhost:8081/helloweb
returns a html contentChecklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).