-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/issue support js index files fix 260 (#261)
* Fix an ESM index.js/.mjs/.cjs import edge case In [1] a removeFileExtensionToAllowForJs() utility function has been added to help with normalizing import paths into extensionless ones in order to handle ESM imports (which have to have extensions, either .js, .mjs or .cjs). One thing was missed though as index files are handled in a special way. In the analyzer.ts: const processImports = (file: File, exportMap: ExportMap): void => { Object.keys(file.imports).forEach((key) => { let ex = exportMap[removeFileExtensionToAllowForJs(key)]?.exports; exportMap had keys with extensions and "index" removed (so that "xxx/index.ts" became "xxx" there) but paths in file.imports came from getFromText() which only handled extensionless index imports so xxx/index.js" stayed "xxx/index.js". The .js extension was then removed by removeFileExtensionToAllowForJs() but the damage was done already and "xxx" != "xxx/index". This change brings the removeFileExtensionToAllowForJs()-like ESM-compatible behavior to getFromText(). [1] 6e506ae ("Add .js extension support with es6 example (#255)") * Fix test cleanup. Up changelog * Bump package.json and changelog Co-authored-by: Jakub Stasiak <[email protected]>
- Loading branch information
1 parent
2d1b88c
commit 0d956e8
Showing
5 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters