Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use System.import in an Aurelia app? #151

Closed
djensen47 opened this issue May 19, 2017 · 2 comments
Closed

How do I use System.import in an Aurelia app? #151

djensen47 opened this issue May 19, 2017 · 2 comments

Comments

@djensen47
Copy link

I was looking at the answer to #73 and one suggestion was to use System.import so I tried it in my main.js and it failed with System is not defined.

Next, I attempted to tweak babel settings, install a babel plugin, install systemjs but nothing seemed to work.

@Thanood
Copy link

Thanood commented May 19, 2017

It depends on the loader you're acually using.
Aurelia has an abstracted loader. I think it should be safe to use that.
Docs: http://aurelia.io/hub.html#/doc/api/aurelia/loader/1.0.0/class/Loader

Example:

import {inject, Loader} from 'aurelia-framework';

@inject(Loader)
export class MyClass {
  constructor(loader) {
    this.loader = loader;
  }

  myMethod() {
    this.loader.loadModule('module-id').then((module) => { doSomethingWith(module); });
  }
}

(disclaimer: "hand-written", may contain errors 😏 )

@djensen47
Copy link
Author

This worked great for me. Thanks @Thanood!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants