typescript-transform-paths
Advanced tools
Comparing version 1.1.13 to 1.1.14
@@ -5,2 +5,11 @@ # Changelog | ||
### [1.1.14](https://github.com/LeDDGroup/typescript-transform-paths/compare/v1.1.13...v1.1.14) (2019-12-27) | ||
### Bug Fixes | ||
* add support for dynamic imports ([#46](https://github.com/LeDDGroup/typescript-transform-paths/issues/46)) ([88b6001](https://github.com/LeDDGroup/typescript-transform-paths/commit/88b6001)) | ||
### [1.1.13](https://github.com/LeDDGroup/typescript-transform-paths/compare/v1.1.12...v1.1.13) (2019-11-11) | ||
@@ -7,0 +16,0 @@ |
@@ -80,2 +80,15 @@ "use strict"; | ||
} | ||
var isRequire = function (node) { | ||
return typescript_1.default.isCallExpression(node) && | ||
typescript_1.default.isIdentifier(node.expression) && | ||
node.expression.text === "require" && | ||
typescript_1.default.isStringLiteral(node.arguments[0]) && | ||
node.arguments.length === 1; | ||
}; | ||
var isAsyncImport = function (node) { | ||
return typescript_1.default.isCallExpression(node) && | ||
node.expression.kind === typescript_1.default.SyntaxKind.ImportKeyword && | ||
typescript_1.default.isStringLiteral(node.arguments[0]) && | ||
node.arguments.length === 1; | ||
}; | ||
function visit(node) { | ||
@@ -90,16 +103,4 @@ if (!isDeclarationFile && | ||
} | ||
if (typescript_1.default.isCallExpression(node) && | ||
typescript_1.default.isIdentifier(node.expression) && | ||
node.expression.text === "require" && | ||
typescript_1.default.isStringLiteral(node.arguments[0]) && | ||
node.arguments.length === 1) { | ||
var firstArg = node.arguments[0]; | ||
var file = bindModuleToFile(firstArg.text); | ||
if (!file) { | ||
return node; | ||
} | ||
var fileLiteral = typescript_1.default.createLiteral(file); | ||
return typescript_1.default.updateCall(node, node.expression, node.typeArguments, [ | ||
fileLiteral | ||
]); | ||
if (isRequire(node) || isAsyncImport(node)) { | ||
return unpathRequireAndAsyncImport(node); | ||
} | ||
@@ -115,4 +116,32 @@ if (typescript_1.default.isExternalModuleReference(node)) { | ||
} | ||
if (typescript_1.default.isImportTypeNode(node)) { | ||
return unpathImportTypeNode(node); | ||
} | ||
return typescript_1.default.visitEachChild(node, visit, context); | ||
} | ||
function unpathRequireAndAsyncImport(node) { | ||
var firstArg = node.arguments[0]; | ||
var file = bindModuleToFile(firstArg.text); | ||
if (!file) { | ||
return node; | ||
} | ||
var fileLiteral = typescript_1.default.createLiteral(file); | ||
return typescript_1.default.updateCall(node, node.expression, node.typeArguments, [ | ||
fileLiteral | ||
]); | ||
} | ||
function unpathImportTypeNode(node) { | ||
var argument = node.argument; | ||
var literal = argument.literal; | ||
if (!typescript_1.default.isStringLiteral(literal)) { | ||
return node; | ||
} | ||
var file = bindModuleToFile(literal.text); | ||
if (!file) { | ||
return node; | ||
} | ||
var fileLiteral = typescript_1.default.createLiteral(file); | ||
var fileArgument = typescript_1.default.updateLiteralTypeNode(argument, fileLiteral); | ||
return typescript_1.default.updateImportTypeNode(node, fileArgument, node.qualifier, node.typeArguments, node.isTypeOf); | ||
} | ||
function unpathImportEqualsDeclaration(node) { | ||
@@ -119,0 +148,0 @@ if (!typescript_1.default.isStringLiteral(node.expression)) { |
{ | ||
"name": "typescript-transform-paths", | ||
"version": "1.1.13", | ||
"version": "1.1.14", | ||
"description": "Transforms absolute imports to relative", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -74,22 +74,26 @@ # typescript-transform-paths | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
<!-- prettier-ignore --> | ||
<!-- prettier-ignore-start --> | ||
<!-- markdownlint-disable --> | ||
<table> | ||
<tr> | ||
<td align="center"><a href="https://github.com/danielpza"><img src="https://avatars2.githubusercontent.com/u/17787042?v=4" width="100px;" alt="Daniel Perez Alvarez"/><br /><sub><b>Daniel Perez Alvarez</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=danielpza" title="Code">💻</a> <a href="#maintenance-danielpza" title="Maintenance">🚧</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=danielpza" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://github.com/anion155"><img src="https://avatars1.githubusercontent.com/u/4786672?v=4" width="100px;" alt="Михайлов Антон"/><br /><sub><b>Михайлов Антон</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=anion155" title="Code">💻</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Aanion155" title="Bug reports">🐛</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=anion155" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://joshuaavalon.io"><img src="https://avatars0.githubusercontent.com/u/7152420?v=4" width="100px;" alt="Joshua Avalon"/><br /><sub><b>Joshua Avalon</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Ajoshuaavalon" title="Bug reports">🐛</a> <a href="#platform-joshuaavalon" title="Packaging/porting to new platform">📦</a></td> | ||
<td align="center"><a href="https://roblav96.github.io/resume"><img src="https://avatars1.githubusercontent.com/u/1457327?v=4" width="100px;" alt="Robert Laverty"/><br /><sub><b>Robert Laverty</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Aroblav96" title="Bug reports">🐛</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=roblav96" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://github.com/oleersoy"><img src="https://avatars3.githubusercontent.com/u/1163873?v=4" width="100px;" alt="Ole Ersoy"/><br /><sub><b>Ole Ersoy</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Aoleersoy" title="Bug reports">🐛</a> <a href="#blog-oleersoy" title="Blogposts">📝</a></td> | ||
<td align="center"><a href="https://github.com/sbmw"><img src="https://avatars0.githubusercontent.com/u/30099628?v=4" width="100px;" alt="sbmw"/><br /><sub><b>sbmw</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Asbmw" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/richardspence"><img src="https://avatars2.githubusercontent.com/u/9914123?v=4" width="100px;" alt="richardspence"/><br /><sub><b>richardspence</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Arichardspence" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/danielpza"><img src="https://avatars2.githubusercontent.com/u/17787042?v=4" width="100px;" alt=""/><br /><sub><b>Daniel Perez Alvarez</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=danielpza" title="Code">💻</a> <a href="#maintenance-danielpza" title="Maintenance">🚧</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=danielpza" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://github.com/anion155"><img src="https://avatars1.githubusercontent.com/u/4786672?v=4" width="100px;" alt=""/><br /><sub><b>Михайлов Антон</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=anion155" title="Code">💻</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Aanion155" title="Bug reports">🐛</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=anion155" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://joshuaavalon.io"><img src="https://avatars0.githubusercontent.com/u/7152420?v=4" width="100px;" alt=""/><br /><sub><b>Joshua Avalon</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Ajoshuaavalon" title="Bug reports">🐛</a> <a href="#platform-joshuaavalon" title="Packaging/porting to new platform">📦</a></td> | ||
<td align="center"><a href="https://roblav96.github.io/resume"><img src="https://avatars1.githubusercontent.com/u/1457327?v=4" width="100px;" alt=""/><br /><sub><b>Robert Laverty</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Aroblav96" title="Bug reports">🐛</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=roblav96" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://github.com/oleersoy"><img src="https://avatars3.githubusercontent.com/u/1163873?v=4" width="100px;" alt=""/><br /><sub><b>Ole Ersoy</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Aoleersoy" title="Bug reports">🐛</a> <a href="#blog-oleersoy" title="Blogposts">📝</a></td> | ||
<td align="center"><a href="https://github.com/sbmw"><img src="https://avatars0.githubusercontent.com/u/30099628?v=4" width="100px;" alt=""/><br /><sub><b>sbmw</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Asbmw" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/richardspence"><img src="https://avatars2.githubusercontent.com/u/9914123?v=4" width="100px;" alt=""/><br /><sub><b>richardspence</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Arichardspence" title="Bug reports">🐛</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="http://codepen.io/viT-1/"><img src="https://avatars1.githubusercontent.com/u/19496430?v=4" width="100px;" alt="Vitaly Pinchuk"/><br /><sub><b>Vitaly Pinchuk</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3AviT-1" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/laij84"><img src="https://avatars0.githubusercontent.com/u/18145822?v=4" width="100px;" alt="laij84"/><br /><sub><b>laij84</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Alaij84" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/dko-slapdash"><img src="https://avatars0.githubusercontent.com/u/46383452?v=4" width="100px;" alt="dko-slapdash"/><br /><sub><b>dko-slapdash</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Adko-slapdash" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="http://codepen.io/viT-1/"><img src="https://avatars1.githubusercontent.com/u/19496430?v=4" width="100px;" alt=""/><br /><sub><b>Vitaly Pinchuk</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3AviT-1" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/laij84"><img src="https://avatars0.githubusercontent.com/u/18145822?v=4" width="100px;" alt=""/><br /><sub><b>laij84</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Alaij84" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/dko-slapdash"><img src="https://avatars0.githubusercontent.com/u/46383452?v=4" width="100px;" alt=""/><br /><sub><b>dko-slapdash</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Adko-slapdash" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/hedwiggggg"><img src="https://avatars1.githubusercontent.com/u/42947316?v=4" width="100px;" alt=""/><br /><sub><b>hedwiggggg</b></sub></a><br /><a href="https://github.com/LeDDGroup/typescript-transform-paths/issues?q=author%3Ahedwiggggg" title="Bug reports">🐛</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=hedwiggggg" title="Tests">⚠️</a> <a href="https://github.com/LeDDGroup/typescript-transform-paths/commits?author=hedwiggggg" title="Code">💻</a></td> | ||
</tr> | ||
</table> | ||
<!-- markdownlint-enable --> | ||
<!-- prettier-ignore-end --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! |
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
26833
230
99