esnode/visitor.js
/**
 * Update nodes with ES6 declaration syntax (import/export).
 *
 * @param node Node to be updated.
 * @param options Options to resolve path.
 * @return Updated node.
 */
Update nodes with ES6 declaration syntax (import/export).
@param node Node to be updated.
@param options Options to resolve path.
@return Updated node.
Update nodes with ES6 declaration syntax ( import / export ) . @param node Node to be updated . @param options Options to resolve path . @return Updated node .
function updateDeclaration(node, options) {
    if (node.moduleSpecifier) {
        const path = clearPath(node.moduleSpecifier.getFullText());
        const moduleSpecifier = createPathLiteral(Object.assign({}, options, { path }));
        if (path !== moduleSpecifier.text) {
            const flags = node.flags;
            if (ts.isImportDeclaration(node)) {
                node = ts.updateImportDeclaration(node, node.decorators, node.modifiers, node.importClause, moduleSpecifier);
            }
            else if (ts.isExportDeclaration(node)) {
                Object.assign(moduleSpecifier, {
                    parent: node.moduleSpecifier.parent
                });
                node = ts.updateExportDeclaration(node, node.decorators, node.modifiers, node.exportClause, moduleSpecifier);
            }
            node.flags = flags;
        }
    }
    return node;
}
function updateDeclaration ( node , options ) { if ( node . moduleSpecifier ) { const path = clearPath ( node . moduleSpecifier . getFullText ( ) ) ; const moduleSpecifier = createPathLiteral ( Object . assign ( { } , options , { path } ) ) ; if ( path !== moduleSpecifier . text ) { const flags = node . flags ; if ( ts . isImportDeclaration ( node ) ) { node = ts . updateImportDeclaration ( node , node . decorators , node . modifiers , node . importClause , moduleSpecifier ) ; } else if ( ts . isExportDeclaration ( node ) ) { Object . assign ( moduleSpecifier , { parent : node . moduleSpecifier . parent } ) ; node = ts . updateExportDeclaration ( node , node . decorators , node . modifiers , node . exportClause , moduleSpecifier ) ; } node . flags = flags ; } } return node ; }
Update nodes with ES6 declaration syntax (import/export).
Update nodes with ES6 declaration syntax ( import / export ) .
// ModuleSpecifier must exist and include path. // Clean path from redundant characters. // Module specifier with new resolved path. // Change only when path is changed. // Resolve export reference error. // Flags need to be copied.