Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[metro-config] pass in custom serializer to expo default config #25810

Closed
wants to merge 4 commits into from

Conversation

quinlanj
Copy link
Member

@quinlanj quinlanj commented Dec 8, 2023

Why

I want my metro.configs.js to use the sentry custom serializer. It will look something like this:

const {
  getDefaultConfig,
} = require("/Users/quin/Documents/expo/packages/@expo/metro-config/build/ExpoMetroConfig");
const {
  createChunkSerializer,
} = require("/Users/quin/Documents/expo/packages/@expo/metro-config/build/serializer/serializeChunks");
const { mergeConfig } = require("metro");
const {
  createSentryMetroSerializer,
} = require("@sentry/react-native/dist/js/tools/sentryMetroSerializer");

const config = getDefaultConfig(__dirname, {
  customSerializer: createSentryMetroSerializer(createChunkSerializer()),
});

module.exports = config;

How you can help

I noticed that the passed in serializer is only called when the output is not static. However, I want this seriaIizer to be called in the static case. I noticed we split the modules up into chunks and then serialize the chunks . When we serialize each chunk to code, I'm thinking we can use the passed in serializer there. Any guidance someone can give me would be much appreciated!

Test Plan

Ran expo-dev export --output-dir dist --dump-sourcemap on my test app to verify that it works

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Dec 8, 2023
@expo-bot
Copy link
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against 5d1153e

@quinlanj quinlanj changed the title [WIP][metro-config] pass in custom serializer to expo default config [metro-config] pass in custom serializer to expo default config Dec 11, 2023
@quinlanj quinlanj marked this pull request as ready for review December 11, 2023 19:35
@krystofwoldrich
Copy link
Contributor

@quinlanj This looks great!

This will work for JSC iOS/Android and I assume also Web.

But for Hermes, the Debug ID gets lost when composing the Hermes source map.

What is the easiest way to try the changes from this branch? I've seen you mentioned expo-dev, but I don't know how it works.

@quinlanj
Copy link
Member Author

@krystofwoldrich

On trying the changes on the branch: When I run expo-dev, i'm running the cli from source that maps to /my/path/expo/packages/@expo/cli/build/bin/cli. But I suspect it will also work if you ran just expo export and have your metro.config.js reference the path of the development source code. For example:

const {
  getDefaultConfig,
} = require("/Users/quin/Documents/expo/packages/@expo/metro-config/build/ExpoMetroConfig");

On Hermes Debug ID - You'll need to add this bit back to write the packager source map to disk, but iirc, if I run your copy-debug-id script it should move the debug id to the composed hermes source map

@quinlanj
Copy link
Member Author

closing in favour of #25859

@quinlanj quinlanj closed this Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants