Unhandled rejection getViewStrategy

I have built my application and then deployed it to S3. The application works fine until I perform an operation that uses the aurelia dialogs. The error I get is

Unhandled rejection getViewStrategy

Is there a work around to get the dialog to work?

Regards,
Mark.

I guess you are using webpack, and use the dialog open API in the following way:

import { SomeDialogViewModel } from './some-module';

export class SomeCustomElement {
  // ...
  confirm() {
    dialogService.open({
      viewModel: SomeDialogViewModel
    })
  }
}

if so:

Why the error happens at production time, but not during development is because in development build, modules origins (can be understood as module path) are preserved, so aurelia-webpack-loader is able to figure out the origin of dialog view model module, and so is corresponding view. In production build there are some more work related to module mangling in webpack that makes aurelia-webpack-loader no longer able to figure out the view model origin.

You have 2 options:

  1. Instruction Webpack to not concatenate the module, via PLATFORM.moduleName:
import { SomeDialogViewModel } from './some-module';

PLATFORM.moduleName('./some-module');

export class SomeCustomElement {
  // ...
  confirm() {
    dialogService.open({
      viewModel: SomeDialogViewModel
    })
  }
}
  1. Explicitly tell where the view of SomeDialogViewModel is, either via import .html:
import { view } from 'aurelia-framework';
import DIALOG_VIEW from './some-dialog.html';

@view({
  template: DIALOG_VIEW,
  /* dependencies: () => []*/
})
export class SomeDialogViewModel {

}

or using useView decorator, with PLATORM.moduleName

import { useView } from 'aurelia-framework';

@useView(PLATFORM.moduleName('absolute/path/to/some-dialog.html'))
export class SomeDialogViewModel {

}

Can you try the above suggestion?

Option 1 worked fine. I haven’t tried option 2 yet; however, adding the modal view to the global resources also works.

Regards,
Mark.