Skip to content

Commit

Permalink
feature: @putout/plugin-merge-destructuring-properties: exclude remov…
Browse files Browse the repository at this point in the history
…e parentPath
  • Loading branch information
coderaiser committed Jun 19, 2024
1 parent 8ce44a8 commit cae5511
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ const addVariable = ({store}) => (path, node) => {
if (path === currentPath || currentPath.removed)
return;

if (currentPath.parentPath.removed)
return;

const is = compare(currentPath.node.init, node);

if (is && sameKind(path, currentPath))
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-merge-destructuring-properties/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
],
"devDependencies": {
"@putout/plugin-convert-mock-require-to-mock-import": "*",
"@putout/plugin-declare": "*",
"@putout/plugin-minify": "*",
"@putout/plugin-nodejs": "*",
"@putout/plugin-putout": "*",
"@putout/plugin-tape": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const {defineProperty: a} = Object;
let c = null;
var d = 1073741823, {keys: b} = Object;

function A(...e) {
if (n)
return new Proxy({
get(n) {},
has(n) {
return !1;
},
keys() {
n.push(...b(resolveSource(e[t])));
},
}, propTraps);

const t = {}, r = Object.create(null);

for (let n = e.length - 1; n >= 0; n--)
const s = Object.getOwnPropertyNames(o), i = Object.getOwnPropertyDescriptor(o, n)
a(o, n, t);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let scheduledCallback = null;const maxSigned31BitInt = 1073741823;

function mergeProps(...e) {
if (n)
return new Proxy({get(n) {
}, has(n) {
return!1;
}, keys() {
n.push(...Object.keys(resolveSource(e[t])));
}}, propTraps);

const t = {}, r = Object.create(null);

for (let n = e.length - 1;n >= 0;n--) {
const s = Object.getOwnPropertyNames(o);
const i = Object.getOwnPropertyDescriptor(o, n);
}

Object.defineProperty(o, n, t);
}

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ test('plugin-merge-destructuring-properties: transform: putout/declare', (t) =>
t.end();
});

test('plugin-merge-destructuring-properties: transform: minify', async (t) => {
const minify = await import('@putout/plugin-minify');
const declare = await import('@putout/plugin-declare');

t.transform('minify', {
declare,
minify,
});
t.end();
});

test('plugin-merge-destructuring-properties: transform: tape', (t) => {
t.transform('tape', {
'putout/tape': tape,
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-minify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
],
"devDependencies": {
"@putout/plugin-conditions": "*",
"@putout/plugin-declare": "^4.0.0",
"@putout/plugin-declare": "*",
"@putout/plugin-merge-destructuring-properties": "*",
"@putout/plugin-remove-unreferenced-variables": "*",
"@putout/test": "^10.0.0",
"c8": "^10.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const {defineProperty: a} = Object;
let c = null;
var d = 1073741823, {keys: b} = Object;

function A(...e) {
if (n)
return new Proxy({
get(n) {},
has(n) {
return !1;
},
keys() {
n.push(...b(resolveSource(e[t])));
},
}, propTraps);

const t = {}, r = Object.create(null);

for (let n = e.length - 1; n >= 0; n--)
const s = Object.getOwnPropertyNames(o), i = Object.getOwnPropertyDescriptor(o, n)
a(o, n, t);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let scheduledCallback = null;const maxSigned31BitInt = 1073741823;

function mergeProps(...e) {
if (n)
return new Proxy({get(n) {
}, has(n) {
return!1;
}, keys() {
n.push(...Object.keys(resolveSource(e[t])));
}}, propTraps);

const t = {}, r = Object.create(null);

for (let n = e.length - 1;n >= 0;n--) {
const s = Object.getOwnPropertyNames(o);
const i = Object.getOwnPropertyDescriptor(o, n);
}

Object.defineProperty(o, n, t);
}

10 changes: 10 additions & 0 deletions packages/plugin-minify/test/minify.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {createTest} from '@putout/test';
import * as mergeDestructuringProperties from '@putout/plugin-merge-destructuring-properties';
import * as declare from '@putout/plugin-declare';
import * as minify from '../lib/index.js';

const test = createTest(import.meta.url, {
Expand Down Expand Up @@ -137,3 +139,11 @@ test('plugin-minify: transform: merge-assignment-expressions', (t) => {
t.transform('merge-assignment-expressions');
t.end();
});

test('plugin-minify: transform: merge-destructuring-properties', (t) => {
t.transform('merge-destructuring-properties', {
declare,
mergeDestructuringProperties,
});
t.end();
});

0 comments on commit cae5511

Please sign in to comment.