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.
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
Move node-cli to be pure ESM, use Conf for persistent storage #203
base: main
Are you sure you want to change the base?
Move node-cli to be pure ESM, use Conf for persistent storage #203
Changes from 34 commits
67e1402
3a739b4
c3577ce
d3f9ea9
f29e56b
81edc40
3690ccb
4d3339a
13d7cde
1f1f120
a98f439
b3114a9
2e462ee
f9f9f6d
7dce78b
17f9e6c
da4ba81
77aba02
35dd5ff
8a7aae6
2519feb
fdefb4d
3d2c41e
0cba13f
45a1ac1
04640d5
aff3dae
5289bb3
e531e3e
e6e1c4f
f6b9dc4
aadfada
5bcda63
c33fc77
0d2c008
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need to modify imports of our deps to point to the js file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately, yes...
Relative imports need to explicitly have the file extensions
.js
attached to them when we set module and moduleresolution toNode16
orNodeNext
. That was a rule seemingly defined by the TS team - what the TS compiler does is try to resolve the import to a specific file. If it can't find a specific file, it adds a .js extension (this is what thenode
resolver does). Apparently, this is a side-effect, rather than the compiler's intention.Specifying
--experimental-specifier-resolution=node
would have worked, bypassing the TS linter rules, but it's experimental, and starting from Node 19 this flag was dropped :(See the comments on this post on an explanation on what goes on underneath the compiler, and see this github discussion on the TS devs being tired of explaining their reasoning 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like you can replicate the effects from this flag --experimental-specifier-resolution=node by creating a custom loader for node but yeah that sounds much more troublesome than just adding .js extension 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading all the comments about this, it's starting to make sense... including the explicit file extension improves module resolution performance (the loader doesn't need to go through every permutation of
.js
or.d.js
or.ejs
), and it reduces ambiguity. The thing is, not having the file extension was how the majority of devs have done it in the past, so while including it is the recommended, it's doesn't help with uniformity