Description
A first implementation of <script type="module"><script>
just landed in Safari Technology Preview 21, so I tried to use it on a TypeScript / Angular project, to finally get rid of system.js.
First issue, resolved but unconvenient : ES6 modules paths must include the '.js'
extension. Fortunately, TS 2.0+ knows how to resolve import { Something } from './test.js'
into import { Something } from './test.ts'
while in dev. But it's a huge change to common practices and a lot of refactoring : official TypeScript docs, Angular, RxJS and so on have all encouraged until know to use the no extension form (import { Something } from './test'
).
Second issue, unresolved : TS provides many options to tell the compiler how to resolve paths like import { Component } from '@angular/core'
. But it never transforms the imported path in the compiled files. '@angular/core'
will stay '@angular/core'
in the transpiled files. After investigation, I've read in many issues it is by design.
It's OK with loaders like system.js and others, which provide similar path mapping options. But with <script type="module"><script>
, as far as I know, there is no configuration, so import { Component } from '@angular/core'
will always fail.
I am missing something, or does that really mean that we won't be able to use the native loader with TypeScript projects ?
If I'm right, is it possible to add an option to force path transformation in compiled files ?