How to configure Aurelia to load modules from a folder?

Asked By: Anonymous

Aurelia has this fantastic ViewLocator strategy. I can’t figure out how to make it do the same for modules. Here’s a sample /src setup:

- src/
    - main.js
    - app/
        - app.js
        - app.html
    - foo/
        - foo.js
        - foo.html
    - bar/baz/
        - baz.js
        - baz.html

Following this convention, I’d like to be able to load app with the name app rather than app/app, foo with foo rather than foo/foo, and baz with bar/baz rather than bar/baz/baz.

So in effect, <path>/<module>/<module> should be accessible from <path>/<module>

In Aurelia, what is the best way to set this convention?


Solution

Answered By: Anonymous

There’s a convention for this, and it’s actually a general convention for node packages. First, structure your app module using an index.js entry point.

- src/
    - main.js
    - app/
        - index.js
        - app.js
        - app.html

Next, in your main.js code, use the feature “app”. This tells Aurelia to look for app/index.js and load it as a plugin.

main.js

export configure(aurelia) {
  aurelia.use
    .feature('app');
}

You can read more information about features here: Aurelia Features


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen Windows 10 Lisans Office 2019 Mac Satın Al follower kaufen instagram follower kaufen porno