Skip to content

Commit

Permalink
Move metro-minify-terser dependency to metro-transform-worker, fi…
Browse files Browse the repository at this point in the history
…x pnpm (etc) resolution (#1199)

Summary:
Pull Request resolved: #1199

Related: #1172

This is the minimally invasive change to fix resolution of the default `minifierPath: 'metro-minify-terser'`, especially under isolated node_modules layouts.

`minifierPath` is required/resolved only from `metro-transform-worker`:
 - https://github.com/facebook/metro/blob/v0.80.4/packages/metro-transform-worker/src/utils/getMinifier.js#L22
 - https://github.com/facebook/metro/blob/v0.80.4/packages/metro-transform-worker/src/index.js#L656

Per the [current docs for `minifierPath`](https://metrobundler.dev/docs/configuration/#minifierpath), a module specifier relative to `metro-transform-worker` is explicitly acceptable:

> Type: string (default: 'metro-minify-terser')
> Path, or package name resolvable from metro-transform-worker, to the minifier that minifies the code after transformation.

Unlike #1172 (thanks tido64 for flagging), this doesn't modify the defaults and can be released in a patch release. The approach in that PR (using fully resolved paths in config) may be the better long-term fix though, so this patch shouldn't be regarded as superseding it.

Changelog:
```
 - **[Fix]:** Move `metro-minify-terser` dependency to fix resolution under isolated node_modules (pnpm, etc).
```

Reviewed By: huntie

Differential Revision: D53000650

fbshipit-source-id: 251f52c17af58c88ebedb387ac92ecbe788772ea
  • Loading branch information
robhogan authored and facebook-github-bot committed Jan 24, 2024
1 parent c892bf7 commit 8e26460
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion packages/metro-transform-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
"metro-babel-transformer": "0.80.4",
"metro-cache": "0.80.4",
"metro-cache-key": "0.80.4",
"metro-minify-terser": "0.80.4",
"metro-source-map": "0.80.4",
"metro-transform-plugins": "0.80.4",
"nullthrows": "^1.1.1"
},
"devDependencies": {
"metro-memory-fs": "0.80.4",
"metro-minify-terser": "0.80.4",
"@react-native/metro-babel-transformer": "0.73.11"
},
"engines": {
Expand Down
1 change: 0 additions & 1 deletion packages/metro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"metro-config": "0.80.4",
"metro-core": "0.80.4",
"metro-file-map": "0.80.4",
"metro-minify-terser": "0.80.4",
"metro-resolver": "0.80.4",
"metro-runtime": "0.80.4",
"metro-source-map": "0.80.4",
Expand Down

0 comments on commit 8e26460

Please sign in to comment.