Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Allow imports with .js extension #370

Closed
cyrilletuzi opened this issue Feb 10, 2017 · 1 comment
Closed

Allow imports with .js extension #370

cyrilletuzi opened this issue Feb 10, 2017 · 1 comment

Comments

@cyrilletuzi
Copy link

Since TS 2.0, it's possible to :
import { Something } from './something.js';

Module identifiers allow for .js extension

Before TypeScript 2.0, a module identifier was always assumed to be extension-less; for instance, given an import as import d from "./moduleA.js", the compiler looked up the definition of "moduleA.js" in ./moduleA.js.ts or ./moduleA.js.d.ts. This made it hard to use bundling/loading tools like SystemJS that expect URI's in their module identifier.

With TypeScript 2.0, the compiler will look up definition of "moduleA.js" in ./moduleA.ts or ./moduleA.d.ts.

But using this possibility with awesome-typescript-loader results in error :
Module not found: Error: Can't resolve './something.js'

It's important to be compatible with ES6 modules, which require the .js extension, as <script type="module"></script> is now in test in all browsers, and as for now TS doesn't provide an option to add the .js extension in transpiled files (see microsoft/TypeScript#13422).

It's possible in rollup/rollup-plugin-typescript so I assume it's possible with awesome-typescript-loader too.

@cyrilletuzi
Copy link
Author

Unresolved, but closing as there has been no answer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant