I have library my-lib which is consumed by my-application.
I have updated my-application and my-lib from Angular15 to Angular16.
After that I recognize that There is issue with modules imports for example
Module not found: Error: Can't resolve (name of module) (with relative path)
Example import is
import {MyModuleOne} from 'my-Lib/my-module-one';
If I will change import to below all works fine.
import {MyModuleOne} from 'my-lib'
After some more investigation I also saw that problem is resolved when I will change some configuration in my-lib package.json file from this
{
"exports": {
"./*": {
"types": "./index.d.ts",
"esm2020": "./esm2020/my-lib.mjs",
"es2020": "./fesm2020/my-lib.mjs",
"es2015": "./fesm2015/my-lib.mjs",
"node": "./fesm2015/my-lib.mjs",
"default": "./fesm2020/my-lib.mjs"
}
}
}
To that one
{
"exports": {
"./*": {
"types": "./index.d.ts",
"esm2022": "./esm2022/my-lib.mjs",
"es2022": "./fesm2022/my-lib.mjs",
"node": "./fesm2022/my-lib.mjs",
"default": "./fesm2022/my-lib.mjs"
}
}
}
My question is why after this change imports like below start working correctly?
import {MyModuleone} from 'my-lib/my-module-one';
I also add that in my dist > my-lib > there were esm2022 and fesm2022 files, so not esm2020, es2020 or es2015 or fesm2015... despite of that changed import was working correctly, how it's possible?
import {MyModuleone} from 'my-lib';