I have a module where the package.json contains:
"type": "module",
"exports": {
".": "./build/index.js",
"./*": "./build/*.js",
"./sub-dir": "./build/sub-dir/index.js",
"./sub-dir/*": "./build/sub-dir/*.js"
},
From outside of this package, this now resolves just fine:
const { whatever } = import('module/sub-dir/foo');
however, from within the module, this breaks:
const { whatever } = import('./sub-dir/foo');
This is a TS project, so ./src/sub-dir/foo.ts compiles to ./build/sub-dir/foo.js
So if I change my import to './sub-dir/foo.js', then the built project works, but that path isn't valid in src, so TS breaks.
Any idea on a "proper" configuration here? Or the proper way to import this file, or anything else?