Skip to content

Support loading TypeScript metro.config.ts in Node.js v24#1560

Closed
robhogan wants to merge 1 commit into
mainfrom
export-D80275288
Closed

Support loading TypeScript metro.config.ts in Node.js v24#1560
robhogan wants to merge 1 commit into
mainfrom
export-D80275288

Conversation

@robhogan

@robhogan robhogan commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

Summary:
Take advantage of Node.js's unflagged TypeScript stripping/.ts module loading and allow Metro to find and load TypeScript config with no additional dependencies, via the .cts, .ts and .mts extensions.

We'll be able to make .ts the suggested format once Node v24.3 (where using TS is on by default and no longer emits a warning) is the minimum supported version.

 - **[Feature]** Support loading TypeScript `metro.config.ts` files when using Node.js/Bun versions that natively support it

Reviewed By: GijsWeterings

Differential Revision: D80275288

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 18, 2025
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D80275288

robhogan added a commit that referenced this pull request Aug 18, 2025
Summary:

Take advantage of Node.js's unflagged TypeScript stripping/.ts module loading and allow Metro to find TypeScript config and load files with no additional dependencies, via the `.cts`, `.ts` and `.mts` extensions.

We'll be able to make `.ts` the suggested format once Node v24.3 (where using TS is on by default and no longer emits a warning) is the minimum supported version.

```
 - **[Feature]** Support loading TypeScript `metro.config.ts` files when using Node.js/Bun versions that natively support it
```

Reviewed By: GijsWeterings

Differential Revision: D80275288
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D80275288

robhogan added a commit that referenced this pull request Aug 18, 2025
Summary:
Pull Request resolved: #1560

Take advantage of Node.js's unflagged TypeScript stripping/.ts module loading and allow Metro to find TypeScript config and load files with no additional dependencies, via the `.cts`, `.ts` and `.mts` extensions.

We'll be able to make `.ts` the suggested format once Node v24.3 (where using TS is on by default and no longer emits a warning) is the minimum supported version.

```
 - **[Feature]** Support loading TypeScript `metro.config.ts` files when using Node.js/Bun versions that natively support it
```

Reviewed By: GijsWeterings

Differential Revision: D80275288
robhogan added a commit that referenced this pull request Aug 20, 2025
Summary:

Take advantage of Node.js's unflagged TypeScript stripping/.ts module loading and allow Metro to find TypeScript config and load files with no additional dependencies, via the `.cts`, `.ts` and `.mts` extensions.

We'll be able to make `.ts` the suggested format once Node v24.3 (where using TS is on by default and no longer emits a warning) is the minimum supported version.

```
 - **[Feature]** Support loading TypeScript `metro.config.ts` files when using Node.js/Bun versions that natively support it
```

Reviewed By: GijsWeterings

Differential Revision: D80275288
Summary:
Pull Request resolved: #1560

Take advantage of Node.js's unflagged TypeScript stripping/.ts module loading and allow Metro to find TypeScript config and load files with no additional dependencies, via the `.cts`, `.ts` and `.mts` extensions.

We'll be able to make `.ts` the suggested format once Node v24.3 (where using TS is on by default and no longer emits a warning) is the minimum supported version.

```
 - **[Feature]** Support loading TypeScript `metro.config.ts` files when using Node.js/Bun versions that natively support it
```

Reviewed By: GijsWeterings

Differential Revision: D80275288
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D80275288

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been merged in 8ba565c.

facebook-github-bot pushed a commit that referenced this pull request Sep 30, 2025
Summary:
In #1560, I added some logic to catch errors and throw more helpful ones (given the config path in a new message, and a specific note for the case that a user was trying to use TypeScript config on an older Node.js version).

I preserved the original error in `error.cause`. However, the integration with `react-native-community/cli` discards the cause. This meant other run-of-the-mill errors in `metro.config.js` that prevented the module being evaluated, like a typo in a variable name, or a syntax error, were obscured.

Instead, preserve the original error and stack, and just add a bit to the message before re-throwing it.

Changelog:
```
 - **[Fix]** Don't obscure errors parsing/evaluating metro.config.js
```

Reviewed By: motiz88

Differential Revision: D83559678

fbshipit-source-id: 82c9425463ad1c7833a14efce513d6ed2a657283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants