@vercel/nft
Advanced tools
Comparing version 0.9.3 to 0.9.4
@@ -350,96 +350,89 @@ "use strict"; | ||
} | ||
for (const [, m] of modules) { | ||
if (m.params.length === 3 && m.params[2].type === 'Identifier') { | ||
const assignedVars = new Map(); | ||
estree_walker_1.walk(m.body, { | ||
enter(node, maybeParent) { | ||
if (node.type === 'FunctionExpression' || | ||
node.type === 'FunctionDeclaration' || | ||
node.type === 'ArrowFunctionExpression' || | ||
node.type === 'BlockStatement' || | ||
node.type === 'TryStatement') { | ||
if (maybeParent) | ||
return this.skip(); | ||
} | ||
if (node.type === 'CallExpression' && | ||
node.callee.type === 'Identifier' && | ||
node.callee.name === m.params[2].name && | ||
node.arguments.length === 1 && | ||
node.arguments[0].type === 'Literal') { | ||
const externalId = externalMap.get(node.arguments[0].value); | ||
if (externalId) { | ||
const replacement = { | ||
type: 'CallExpression', | ||
callee: { | ||
type: 'Identifier', | ||
name: 'require' | ||
}, | ||
arguments: [{ | ||
type: 'Literal', | ||
value: externalId | ||
}] | ||
}; | ||
const parent = maybeParent; | ||
if (parent.right === node) { | ||
parent.right = replacement; | ||
if (externalMap.size) | ||
for (const [, m] of modules) { | ||
if (m.params.length === 3 && m.params[2].type === 'Identifier') { | ||
const assignedVars = new Map(); | ||
estree_walker_1.walk(m.body, { | ||
enter(node, maybeParent) { | ||
if (node.type === 'CallExpression' && | ||
node.callee.type === 'Identifier' && | ||
node.callee.name === m.params[2].name && | ||
node.arguments.length === 1 && | ||
node.arguments[0].type === 'Literal') { | ||
const externalId = externalMap.get(node.arguments[0].value); | ||
if (externalId) { | ||
const replacement = { | ||
type: 'CallExpression', | ||
callee: { | ||
type: 'Identifier', | ||
name: 'require' | ||
}, | ||
arguments: [{ | ||
type: 'Literal', | ||
value: externalId | ||
}] | ||
}; | ||
const parent = maybeParent; | ||
if (parent.right === node) { | ||
parent.right = replacement; | ||
} | ||
else if (parent.left === node) { | ||
parent.left = replacement; | ||
} | ||
else if (parent.object === node) { | ||
parent.object = replacement; | ||
} | ||
else if (parent.callee === node) { | ||
parent.callee = replacement; | ||
} | ||
else if (parent.arguments && parent.arguments.some((arg) => arg === node)) { | ||
parent.arguments = parent.arguments.map((arg) => arg === node ? replacement : arg); | ||
} | ||
else if (parent.init === node) { | ||
if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') | ||
assignedVars.set(parent.id.name, externalId); | ||
parent.init = replacement; | ||
} | ||
} | ||
else if (parent.left === node) { | ||
parent.left = replacement; | ||
} | ||
else if (parent.object === node) { | ||
parent.object = replacement; | ||
} | ||
else if (parent.callee === node) { | ||
parent.callee = replacement; | ||
} | ||
else if (parent.arguments && parent.arguments.some((arg) => arg === node)) { | ||
parent.arguments = parent.arguments.map((arg) => arg === node ? replacement : arg); | ||
} | ||
else if (parent.init === node) { | ||
if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') | ||
assignedVars.set(parent.id.name, externalId); | ||
parent.init = replacement; | ||
} | ||
} | ||
} | ||
else if (node.type === 'CallExpression' && | ||
node.callee.type === 'MemberExpression' && | ||
node.callee.object.type === 'Identifier' && | ||
node.callee.object.name === m.params[2].name && | ||
node.callee.property.type === 'Identifier' && | ||
node.callee.property.name === 'n' && | ||
node.arguments.length === 1 && | ||
node.arguments[0].type === 'Identifier' && | ||
assignedVars.get(node.arguments[0].name)) { | ||
if (maybeParent && maybeParent.init === node) { | ||
maybeParent.init = { | ||
type: 'ObjectExpression', | ||
properties: [{ | ||
type: 'ObjectProperty', | ||
method: false, | ||
computed: false, | ||
shorthand: false, | ||
key: { | ||
type: 'Identifier', | ||
name: 'a' | ||
}, | ||
value: { | ||
type: 'CallExpression', | ||
callee: { | ||
else if (node.type === 'CallExpression' && | ||
node.callee.type === 'MemberExpression' && | ||
node.callee.object.type === 'Identifier' && | ||
node.callee.object.name === m.params[2].name && | ||
node.callee.property.type === 'Identifier' && | ||
node.callee.property.name === 'n' && | ||
node.arguments.length === 1 && | ||
node.arguments[0].type === 'Identifier' && | ||
assignedVars.get(node.arguments[0].name)) { | ||
if (maybeParent && maybeParent.init === node) { | ||
maybeParent.init = { | ||
type: 'ObjectExpression', | ||
properties: [{ | ||
type: 'ObjectProperty', | ||
method: false, | ||
computed: false, | ||
shorthand: false, | ||
key: { | ||
type: 'Identifier', | ||
name: 'require' | ||
name: 'a' | ||
}, | ||
arguments: [{ | ||
type: 'Literal', | ||
value: assignedVars.get(node.arguments[0].name) | ||
}] | ||
} | ||
}] | ||
}; | ||
value: { | ||
type: 'CallExpression', | ||
callee: { | ||
type: 'Identifier', | ||
name: 'require' | ||
}, | ||
arguments: [{ | ||
type: 'Literal', | ||
value: assignedVars.get(node.arguments[0].name) | ||
}] | ||
} | ||
}] | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
@@ -446,0 +439,0 @@ } |
{ | ||
"name": "@vercel/nft", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"repository": "vercel/nft", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144863
2905