Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate relative path for types #426

Merged
merged 5 commits into from
Jan 24, 2024
Merged

Generate relative path for types #426

merged 5 commits into from
Jan 24, 2024

Conversation

huozhi
Copy link
Owner

@huozhi huozhi commented Jan 24, 2024

This PR refactors each build to a standalone rollup build job including its own input and own output, instead of having one input and multi output before.

For .d.cts and .d.mts we need to import the proper file, for instance, .d.cts matches .cjs files and .d.mts matches .mjs files, so you would have:

In a .d.mts file, module resolving situation will be like

// index.d.mts
export { Shared } from '../shared/index.mjs'; // ✅
export { Shared } from '../shared/index'; // ❌ cannot resolve
export { Shared } from '../shared/index.cjs'; // ❌ cannot resolve

This means we need a resolving map for each format of build, if we're building import condition output with esm syntax format, we need to alias the code to mjs output. This rule only applies to types. JS can still do <pkg>/<export> import as nodejs is able to resolve that.

So we created alias for each build, and also put relative path there to make sure they can be resolved

Resolves #390

@huozhi huozhi marked this pull request as ready for review January 24, 2024 15:12
@huozhi huozhi merged commit e889747 into main Jan 24, 2024
3 checks passed
@huozhi huozhi deleted the relative-path-ts branch January 24, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate realtive paths for types when they refer to each other
1 participant