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] 6e506ae05ef3 ("Add .js extension support with es6 example (#255)")
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:
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] 6e506ae05ef3 ("Add .js extension support with es6 example (#255)")