-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Library
React Components / v9 (@fluentui/react-components)
Describe the issue
We introduced exports maps to our packages some time ago to improve bundling and tree-shakeability.
While doing that we forgot to update types fields within export maps, which currently point to non existing declaration files. This might be potentially dangerous to users that wanna use native ESM and use Typescript >=4.7 with "moduleResolution": "Node16", or "moduleResolution": "NodeNext" configuration.
Have you discussed this feature with our team
v-build
Additional context
Exports map with types field paths are consumed by TS if and only if:
- compilerOptions.moduleResolution is set to Node16 or NodeNext
- note that if package has "type":"module" in its package.json typescript doesn't care (but it should based on docs - TS bug ? )
What does this mean to us:
- our source of truth is
typingsortypesroot property in package.json that points to our rolluped file (dist/index.d.tsordist/unstable.d.tsfor unstable) - we need to fix all
"exports[glob]types"in package json to point to./dist/index.d.tsand./dist/unstable.d.tsrespectively.- Why do we need to fix it ? typescript is "SMART" about type declaration resolution and if user is in native ESM mode, and types are not provided in exports map, TS will "try" to check for module name with alias of js module ( so
foo/hello.jswill try to resolvefoo/hello.d.tswhich will throw type error.
- Why do we need to fix it ? typescript is "SMART" about type declaration resolution and if user is in native ESM mode, and types are not provided in exports map, TS will "try" to check for module name with alias of js module ( so
🚨 Word of caution:
if consumers are using native ESM modules they are out of luck because v9 doesn't support native ESM modules -> Thus they should not use `compilerOptions.moduleResolution is set to Node16 or NodeNextat all !
Validations
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Tasks
- update migration generator to process export maps with unstable API if present | feat(tools): add exports map support to migrate-converged-pkg generator #25033
- run migration on
@fluentui/react-components| will be closed by fix: create valid export maps #25558, Defined standard for v9 package file organization #24129