fix(build): Enable compatibility with moduleResolution = nodenext #106
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Customers using TypeScript configured to
moduleResolution="nodenext"
ormoduleResolution="node2016"
will run into the problems described at:With our current build system (and most others today) type definitions in the
build/
outputs contain one.d.ts
file per source file, and these files must refer to one another by.js
extensions when consumed by any TypeScript project usingmoduleResolution="nodenext"
. This could be avoided if we had a build system that bundled all type definitions into a single.d.ts
file — in which case there are no imports in the generated types — but I'm not confident recommending a build system with this feature.TypeScript does not rename extensions from
./foo
or./foo.ts
to./foo.js
by itself (microsoft/TypeScript#49462).deck.gl has a special build step configured to do this renaming.
I'd rather not complicate the build process, so I think the simplest and safest solution is to ensure that all relative imports are
.js
in the source files, so they'll already be correct when type definitions are built. By adoptingmoduleResolution="nodenext"
for this library we can be sure that the extensions will be consistent, becauseyarn lint
enforces it. For examples and tests it doesn't particularly matter either way.