This will PR generates the relative paths relationship for the JS bundles.
For instance, for the 2 exports which one is relying on the other one, and ./foo is dependent on ./, project name is "my-lib":
- src/
|- index.ts
|- foo.ts
Bunchee will output the below structure and use "<project name>/<export path>" as dependency for each bundle to import the other export bundles. e.g. foo.js will import from "my-lib" as it's the ./ export.
- dist/
|- index.js
|- foo.js
This output is not ideal cause it might resolve the 2nd module resolving. And some bundler might error (e.g. vite).
After this PR, the output the relative path for all imports and there's no extra module resolving. And we did some smart resolution which also based on the output format, to make sure CJS is only requiring other CJS bundles and ESM can resolve other ESM bundles.
Types will also be smartly resolved like above, but since we could have import.types or require.types conditions, or simply types conditions, so we'll resolve twice to make sure it's able to be resolved properly matching with the format.
This will PR generates the relative paths relationship for the JS bundles.
For instance, for the 2 exports which one is relying on the other one, and
./foo
is dependent on./
, project name is "my-lib":Bunchee will output the below structure and use
"<project name>/<export path>"
as dependency for each bundle to import the other export bundles. e.g. foo.js will import from"my-lib"
as it's the./
export.This output is not ideal cause it might resolve the 2nd module resolving. And some bundler might error (e.g. vite).
After this PR, the output the relative path for all imports and there's no extra module resolving. And we did some smart resolution which also based on the output format, to make sure CJS is only requiring other CJS bundles and ESM can resolve other ESM bundles.
e.g.
Types will also be smartly resolved like above, but since we could have
import.types
orrequire.types
conditions, or simplytypes
conditions, so we'll resolve twice to make sure it's able to be resolved properly matching with the format.Resolves #511