-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Allow Setting Extension Priority (and Then Not Requiring Extensions in Imports) #56660
Comments
You example is not correct: import foo from 'foo' Will look for a package foo in the node_modules. import foo from './foo' is not allowed. I'm -1 on having extension guessing. |
Sorry, the perils of pseudocode ... but you seemed to grok my intent :)
You seem to be making assumptions for every Node developer. Personally, and I suspect a lot of people would share this preference, I would happily trade 0.5s startup time for never having to write an extension in my imports ever again. |
I mean if it stays behind a flag, I'd not be totally opposed. I would not like to be the default behavior. I'm afraid it will create a flavor that only works for some and not for others. |
Legitimate concern, but my counterarguments would be:
|
What is the problem this feature will solve?
In recent years Node has been trading developer convenience for functionality, as several recent changes (eg. https://satanacchio.hashnode.dev/everything-you-need-to-know-about-nodejs-type-stripping#heading-a-predictable-experience) strongly encourage:
over:
However, for most devs that's a false trade! We can have convenient (extension-less) imports and have the benefits of the new features.
How?
What is the feature you are proposing to solve the problem?
Now, when Node sees:
it will treat it as
... unless that fails, in which case it will treat is as:
... and so on.
What alternatives have you considered?
Not requiring an argument ... but the dev needs some way to specify "if you see
foo.js
andfoo.ts
, but I saidfrom foo
, use the.js
one".Look, I know three or four extra characters of typing (
.jsx
) may not seem like a lot, but it adds up across dozens of imports in hundreds (or thousands) of files. Please, consider letting us have our extension-less imports back.The text was updated successfully, but these errors were encountered: