Can you use with a string pointing to a module with an exported class as view-model, with CLI-bundler + SystemJS AND have systemjs look for the module in the app-bundle?
It seems like SystemJS perfoms a request to the server, trying to load the module, but the module will always be inside the bundle in our case.
I’ve gotten suggestion to import all possible modules with import statements and then feed the class of the component to compose, see example at the bottom. But I’m curious to see if I can avoid this.
Long version:
We have built a screen in our app where the customer can drag n drop components from our “toolbox” onto a dynamic view.
At runtime, we load the uri’s to each component that the user has selected from a database and feeds that uri as a string pointing to a module to <compose>
-elements. This worked fine with jspm+systemjs and old aurelia bundler from 2016, since each .js-module was copied to the dist folder along with the bundles. SystemJS could then find the js-modules.
With the new CLI-bundler (Beta15) and systemjs no js-files are copied to the dist folder, only the bundles. Can I make SystemJS look inside the bundle instead?
— Workaround: this should work as a work around, but I’m curious to see if I can avoid it.
import { MachineChart } from '/components/machine-chart'
import { Scheduler } from '/components/scheduler'
export class CompositionMapper {
getViewModel(componentName: string) {
switch (componentName) {
case 'MachineChart':
return MachineChart;
case 'Scheduler':
return Scheduler;
}
}
}