Description
Versions.
@ngtools/webpack
1.2.9
Repro steps.
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 @ngtools/webpack
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 when using ngc
directly, and also in rollup/rollup-plugin-typescript so I assume it's possible with @ngtools/webpack
too.