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

Add option to override default metro config #207

Merged
merged 3 commits into from
May 10, 2024

Conversation

jakub-gonet
Copy link
Member

@jakub-gonet jakub-gonet commented May 6, 2024

The option is set in the launch.json under metroConfigPath key.

To test it, create another metro config (e.g. metro.config.dev.js), set the key in the configuration and add blocklist: [/App\.tsx/] (you can use any other imported file) in the metro resolver options. After rebundling, you should get bundle error saying that the module wasn't found.

Fixes #180.

@jakub-gonet jakub-gonet requested a review from kmagiera May 6, 2024 09:19
Copy link

vercel bot commented May 6, 2024

@jakub-gonet is attempting to deploy a commit to the software-mansion Team on Vercel.

To accomplish this, @jakub-gonet needs to request access to the Team.

Afterwards, an owner of the Team is required to accept their membership request.

If you're already a member of the respective Vercel Team, make sure that your Personal Vercel Account is connected to your GitHub account.

"**/metro.config.{js,ts}",
"**/node_modules"
);
let metroConfigGlob = "**/metro.config.{js,ts}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't be searching for the file. If it is specified, it needs to give you path relative to the workspace root. We can test if the file indeed exists, but searching for it is just too much as we may accidentally find other, conflicting files this way

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it from the extension code – you can only construct paths relative to the workspace and we check roots from the workspaces before this check. I changed the code in metro.ts to construct paths against workspace folders and removed recursive search from there.

packages/vscode-extension/src/project/metro.ts Outdated Show resolved Hide resolved
packages/vscode-extension/src/project/metro.ts Outdated Show resolved Hide resolved
@jakub-gonet jakub-gonet force-pushed the jgonet/override-metro-config branch from 01ccde0 to d7e5166 Compare May 9, 2024 10:17
Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@jakub-gonet jakub-gonet merged commit a75366a into main May 10, 2024
1 of 2 checks passed
@jakub-gonet jakub-gonet deleted the jgonet/override-metro-config branch May 10, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Extend launch.json to allow specify path to metro config.
2 participants