Open antonmoiseev opened 9 years ago
Here is how it could look like: https://github.com/Farata/IMD/commit/7751481d228829fde9cfc1ab544ef17c131bc74d
It could be a configurable option:
define.imd({defaultExtension: 'js'})
// or
imd.config({defaultExtension: 'js'})
I generally use the "as" attribute on script tags to give it a short module name. For implicit names, I'd be more inclined to say that the extension should be stripped from the implicit name when registered, rather than adding one on lookup.
What do you think about automatically adding
.js
extension while resolving relative module IDs? Relative URLs always represent a file so it should be safe to append it.Motivation
We use TypeScript and ES6 modules for writing application code. For importing local modules we use relative paths:
After transpiling it turns into an AMD module:
The module itself is loaded as part of an HTML Import:
And registered within the module registry with following name:
However when IMD attempts to resolve the imported module it cannot be found:
If we specify
.js
extension as part of the import statement it breaks the tooling since original file has.ts
extension.