-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Domain: ES ModulesThe issue relates to import/export style module behaviorThe issue relates to import/export style module behaviorIn DiscussionNot yet reached consensusNot yet reached consensusNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
I'd like there to be a way to always require the file extension to be specified for relative import statements. At the moment extensionless imports always just work. Even 'Go to Definition' just assumes it should open the JS file.
src/
- index.js
- foo.js
// index.js
import { Foo } from './foo'; // extensionless
I'd like there to be a jsconfig option to disable this behavior and require a file extension to be specified.
import { Foo } from './foo';
^^^^^^^ No definition found for 'foo'
// fix
- import { Foo } from './foo';
+ import { Foo } from './foo.js';
I'm asking because extensionless imports don't really work in the browser if you're not using a module bundler. It can only work if the HTTP server supports extensionless imports, which is a big ask.
fatcerberus, balupton, eser, cedx, xXACCEXx and 23 morectjlewis, mxjp, blt-r and natpbs
Metadata
Metadata
Assignees
Labels
Domain: ES ModulesThe issue relates to import/export style module behaviorThe issue relates to import/export style module behaviorIn DiscussionNot yet reached consensusNot yet reached consensusNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript