Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private rewriteNamespaceObject(
fullyQualifiedName: string, body: estree.ObjectExpression,
nodePath: NodePath) {
const namespaceExports =
getNamespaceExports(body, this.mutableNames, fullyQualifiedName);
// Replace nodePath with some number of namespace exports. Easiest way
// is to insert the exports after nodePath, then remove nodePath.
const nodePathComments = getComments(nodePath);
if (nodePathComments.length > 0) {
const message =
`TODO(modulizer): A namespace named ${fullyQualifiedName} was\n` +
`declared here. The surrounding comments should be reviewed,\n` +
`and this string can then be deleted`;
const tombstone = jsc.expressionStatement(jsc.templateLiteral(
[jsc.templateElement({raw: message, cooked: message}, true)], []));
(tombstone as NodeWithComments).comments = nodePathComments;
nodePath.insertBefore(tombstone);
}
for (const {node} of namespaceExports) {
nodePath.insertBefore(node);
}
nodePath.prune();
for (const e of namespaceExports) {
this.exportMigrationRecords.push({
oldNamespacedName: `${fullyQualifiedName}.${e.name}`,
es6ExportName: e.name
});
}
this.exportMigrationRecords.push(
{oldNamespacedName: fullyQualifiedName, es6ExportName: '*'});
private rewriteNamespaceObject(
fullyQualifiedName: string, body: estree.ObjectExpression,
nodePath: NodePath) {
const namespaceExports =
getNamespaceExports(body, this.mutableNames, fullyQualifiedName);
// Replace nodePath with some number of namespace exports. Easiest way
// is to insert the exports after nodePath, then remove nodePath.
const nodePathComments = getComments(nodePath);
if (nodePathComments.length > 0) {
const message =
`TODO(modulizer): A namespace named ${fullyQualifiedName} was\n` +
`declared here. The surrounding comments should be reviewed,\n` +
`and this string can then be deleted`;
const tombstone = jsc.expressionStatement(jsc.templateLiteral(
[jsc.templateElement({raw: message, cooked: message}, true)], []));
(tombstone as NodeWithComments).comments = nodePathComments;
nodePath.insertBefore(tombstone);
}
for (const {node} of namespaceExports) {
nodePath.insertBefore(node);
}
nodePath.prune();
for (const e of namespaceExports) {
this.exportMigrationRecords.push({
oldNamespacedName: `${fullyQualifiedName}.${e.name}`,
es6ExportName: e.name
});
}
this.exportMigrationRecords.push(
{oldNamespacedName: fullyQualifiedName, es6ExportName: '*'});