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

Fix metro-minify-terser being resolved from the wrong folder #1172

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/metro-config/package.json
Expand Up @@ -19,6 +19,7 @@
"metro": "0.80.4",
"metro-cache": "0.80.4",
"metro-core": "0.80.4",
"metro-minify-terser": "0.80.4",
"metro-runtime": "0.80.4"
},
"devDependencies": {
Expand Down
Expand Up @@ -140,7 +140,7 @@ Object {
},
"toplevel": false,
},
"minifierPath": "metro-minify-terser",
"minifierPath": "/~/packages/metro-minify-terser/src/index.js",
"optimizationSizeLimit": 153600,
"publicPath": "/assets",
"transformVariants": Object {
Expand Down Expand Up @@ -320,7 +320,7 @@ Object {
},
"toplevel": false,
},
"minifierPath": "metro-minify-terser",
"minifierPath": "/~/packages/metro-minify-terser/src/index.js",
"optimizationSizeLimit": 153600,
"publicPath": "/assets",
"transformVariants": Object {
Expand Down Expand Up @@ -500,7 +500,7 @@ Object {
},
"toplevel": false,
},
"minifierPath": "metro-minify-terser",
"minifierPath": "/~/packages/metro-minify-terser/src/index.js",
"optimizationSizeLimit": 153600,
"publicPath": "/assets",
"transformVariants": Object {
Expand Down Expand Up @@ -680,7 +680,7 @@ Object {
},
"toplevel": false,
},
"minifierPath": "metro-minify-terser",
"minifierPath": "/~/packages/metro-minify-terser/src/index.js",
"optimizationSizeLimit": 153600,
"publicPath": "/assets",
"transformVariants": Object {
Expand Down
11 changes: 11 additions & 0 deletions packages/metro-config/src/__tests__/loadConfig-test.js
Expand Up @@ -20,6 +20,13 @@ const path = require('path');
const prettyFormat = require('pretty-format');
const stripAnsi = require('strip-ansi');

function fixupAbsolutePaths(result: any) {
result.transformer.minifierPath = result.transformer.minifierPath.replace(
process.cwd(),
'/~',
);
}

describe('loadConfig', () => {
beforeEach(() => {
cosmiconfig.reset();
Expand All @@ -39,6 +46,7 @@ describe('loadConfig', () => {
cosmiconfig.setResolvedConfig(config);

const result = await loadConfig({});
fixupAbsolutePaths(result);

expect(result).toMatchSnapshot();
expect(result.cacheStores).toEqual([]);
Expand Down Expand Up @@ -92,6 +100,7 @@ describe('loadConfig', () => {
// We don't actually use the specified file in this test but it needs to
// resolve to a real file on the file system.
const result = await loadConfig({config: './__tests__/loadConfig-test.js'});
fixupAbsolutePaths(result);

const relativizedResult = {
...result,
Expand Down Expand Up @@ -131,6 +140,7 @@ describe('loadConfig', () => {
// We don't actually use the specified file in this test but it needs to
// resolve to a real file on the file system.
const result = await loadConfig({config: path.resolve(__dirname, '../')});
fixupAbsolutePaths(result);

const relativizedResult = {
...result,
Expand Down Expand Up @@ -214,6 +224,7 @@ describe('loadConfig', () => {
cosmiconfig.setResolvedConfig(config);

const result = await loadConfig({});
fixupAbsolutePaths(result);

expect(result).toMatchSnapshot();
expect(result.cacheStores).toEqual([]);
Expand Down
4 changes: 3 additions & 1 deletion packages/metro-config/src/defaults/defaults.js
Expand Up @@ -63,7 +63,9 @@ exports.moduleSystem = (require.resolve(

exports.platforms = ['ios', 'android', 'windows', 'web'];

exports.DEFAULT_METRO_MINIFIER_PATH = 'metro-minify-terser';
exports.DEFAULT_METRO_MINIFIER_PATH = (require.resolve(
'metro-minify-terser',
): string);

exports.defaultCreateModuleIdFactory = defaultCreateModuleIdFactory;

Expand Down
5 changes: 2 additions & 3 deletions packages/metro-transform-worker/package.json
Expand Up @@ -26,9 +26,8 @@
"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"
"@react-native/metro-babel-transformer": "0.73.11",
"metro-memory-fs": "0.80.4"
},
"engines": {
"node": ">=18"
Expand Down
1 change: 0 additions & 1 deletion packages/metro/package.json
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