Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/metro-source-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"cleanup-release": "test ! -e build && mv src build && mv src.real src"
},
"dependencies": {
"@babel/traverse": "^7.29.0",
"@babel/traverse": "^7.29.10",
"@babel/types": "^7.29.8",
"flow-enums-runtime": "^0.0.6",
"invariant": "^2.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/metro-transform-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@babel/core": "^7.25.2",
"@babel/generator": "^7.29.1",
"@babel/template": "^7.28.6",
"@babel/traverse": "^7.29.0",
"@babel/traverse": "^7.29.10",
"flow-enums-runtime": "^0.0.6",
"nullthrows": "^1.1.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,52 @@ describe('constant expressions', () => {

compare([constantFoldingPlugin], code, expected);
});

test('does not fold arithmetic on destructured object bindings', () => {
const code = `
const O = {e: 80};
export function f() {
const {e} = O;
return e + 1;
}
`;

compare([constantFoldingPlugin], code, code);
});

test('does not fold to non-finite numbers from destructured bindings', () => {
const code = `
const SHAPE = {lo: 80, hi: 85, scale: 2.8};
export function f() {
const {lo, hi, scale} = SHAPE;
return (hi - lo) * scale;
}
`;

compare([constantFoldingPlugin], code, code);
});

test('does not fold conditionals on destructured object bindings', () => {
const code = `
const O = {flag: false};
export function f() {
const {flag} = O;
return flag ? 1 : 2;
}
`;

compare([constantFoldingPlugin], code, code);
});

test('does not fold logical expressions on destructured object bindings', () => {
const code = `
const O = {flag: false};
export function f() {
const {flag} = O;
return flag || 3;
}
`;

compare([constantFoldingPlugin], code, code);
});
});
2 changes: 1 addition & 1 deletion packages/metro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@babel/generator": "^7.29.1",
"@babel/parser": "^7.29.9",
"@babel/template": "^7.28.6",
"@babel/traverse": "^7.29.0",
"@babel/traverse": "^7.29.10",
"@babel/types": "^7.29.8",
"accepts": "^2.0.0",
"connect": "^3.6.5",
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
json5 "^2.2.3"
semver "^6.3.1"

"@babel/generator@^7.29.1", "@babel/generator@^7.29.7", "@babel/generator@^7.7.2":
version "7.29.7"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.29.7.tgz#cca0b8827e6bcf3ba176788e7f3b180ad6db2fa3"
integrity sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==
"@babel/generator@^7.29.1", "@babel/generator@^7.29.7", "@babel/generator@^7.29.8", "@babel/generator@^7.7.2":
version "7.29.8"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.29.8.tgz#4b0b887885422643339e09022148a4c4ebaa4979"
integrity sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==
dependencies:
"@babel/parser" "^7.29.7"
"@babel/types" "^7.29.7"
"@babel/parser" "^7.29.8"
"@babel/types" "^7.29.8"
"@jridgewell/gen-mapping" "^0.3.12"
"@jridgewell/trace-mapping" "^0.3.28"
jsesc "^3.0.2"
Expand Down Expand Up @@ -204,7 +204,7 @@
"@babel/template" "^7.29.7"
"@babel/types" "^7.29.7"

"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.23.9", "@babel/parser@^7.24.7", "@babel/parser@^7.25.3", "@babel/parser@^7.29.7", "@babel/parser@^7.29.9":
"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.23.9", "@babel/parser@^7.24.7", "@babel/parser@^7.25.3", "@babel/parser@^7.29.7", "@babel/parser@^7.29.8", "@babel/parser@^7.29.9":
version "7.29.9"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.29.9.tgz#e7ee0a24f752c5296c6455855ccb72662e67ea96"
integrity sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==
Expand Down Expand Up @@ -683,17 +683,17 @@
"@babel/parser" "^7.29.7"
"@babel/types" "^7.29.7"

"@babel/traverse@^7.25.3", "@babel/traverse@^7.29.0", "@babel/traverse@^7.29.7":
version "7.29.7"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.29.7.tgz#c47b07a41b95da0907d026b5dd894d98de7d2f2d"
integrity sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw==
"@babel/traverse@^7.25.3", "@babel/traverse@^7.29.10", "@babel/traverse@^7.29.7":
version "7.29.10"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.29.10.tgz#08ab387639b4a67304511259c7da6cf23a82e91c"
integrity sha512-B3lYAs2nkKskbgQ1nfy8Ma9ao9Q1rntTAQHrzzyDuj+TSO+X3le6PfWwqDvodsb+OumE10eMFfuMCTQSQ5iuIQ==
dependencies:
"@babel/code-frame" "^7.29.7"
"@babel/generator" "^7.29.7"
"@babel/generator" "^7.29.8"
"@babel/helper-globals" "^7.29.7"
"@babel/parser" "^7.29.7"
"@babel/parser" "^7.29.9"
"@babel/template" "^7.29.7"
"@babel/types" "^7.29.7"
"@babel/types" "^7.29.8"
debug "^4.3.1"

"@babel/types@^7.0.0", "@babel/types@^7.29.7", "@babel/types@^7.29.8", "@babel/types@^7.3.0", "@babel/types@^7.3.3":
Expand Down
Loading