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 committed Jan 29, 2024
1 parent fce4c52 commit 2526739
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 @@ -22,13 +22,13 @@
"metro-babel-transformer": "0.76.8",
"metro-cache": "0.76.8",
"metro-cache-key": "0.76.8",
"metro-minify-terser": "0.76.8",
"metro-source-map": "0.76.8",
"metro-transform-plugins": "0.76.8",
"nullthrows": "^1.1.1"
},
"devDependencies": {
"metro-memory-fs": "0.76.8",
"metro-minify-terser": "0.76.8",
"metro-react-native-babel-transformer": "0.76.8"
},
"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 @@ -42,7 +42,6 @@
"metro-core": "0.76.8",
"metro-file-map": "0.76.8",
"metro-inspector-proxy": "0.76.8",
"metro-minify-terser": "0.76.8",
"metro-minify-uglify": "0.76.8",
"metro-react-native-babel-preset": "0.76.8",
"metro-resolver": "0.76.8",
Expand Down

0 comments on commit 2526739

Please # to comment.