import { ListModel } from “./list-model”;
var model = new ListModel();
model.doSomething();
My WebPack-Entry-Points are"list.html" and “list.ts”.
When I start the application, I get the error “Unable to find module with ID: app/list”. As soon as I write the following about the import-part it works: PLATFORM.moduleName("app/list-model");
But, with simple imports of TS files, shouldn’t it be possible for Webpack to resolve the relationship itself?
The requirement of PLATFORM.moduleName in Webpack is a common pain point.
That’s why I switched to the new built-in loader from the CLI when it was introduced.
It’s basically revamped require.js and “just works”.
right, that’s the problem. As soon as I add the PLATFORM.moduleName for list-model, app/list is found.
This confuses me a bit, because all referenced TS files (via import) are resolved automatically.
My understanding was that PLATFORM.moduleName must only be used for views.
Unfortunately it is not possible to post the complete application.
That’s not true. I it when configuring routes in configureRouter. In the JS examples it wasn’t required to do this, but nothing worked in my TS project unless I used it. My routes all start with this form:
but look at my example, it’s not a route. It’s a simple TS class that’s being referenced. And because of this reference, the list class cannot be loaded.
Any Idea why?
PLATFORM.moduleName is used not just only for views. It’s a way to tell webpack that find the module being pointed to, and also try to find if there’s any view associated with it, via convention.