Looking for guidance on setting up and utilizing a feature plugin with Aurelia docs? Find detailed instructions at
I encountered an issue where paths to resources were being transformed by jspm or Aurelia. Upon specifying the current path as
.aurelia.use.feature('./plugins/auth');
, I faced difficulty locating calvert-auth/index.js
during boot up. The browser threw a 404 error despite the seemingly correct request. Removing the "./" from .aurelia.use.feature('plugins/auth');
resolved this issue.
Subsequently, when I added a call in index.s's configure() to frameworkConfig.globalResources('auth'), a new 404 error emerged. This time, the request was for calvert-auth/auth.html instead of the expected calvert-auth/auth.js.
The root cause of these problems may lie within the jspm config or corejs, but further investigation is needed to pinpoint the exact source of the issue.
If you're interested in creating and implementing internal feature plugins for Aurelia, refer to the following class examples:
config.js
...
paths: {
"*": "dist/*",
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
...
main.js
import 'bootstrap';
import authConfig from './auth-config';
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.feature('plugins/calvert-auth', (baseConfig) => {
baseConfig.configure(authConfig);
});
aurelia.start().then(a => a.setRoot());
}
plugins/calvert-auth/auth.js
export class Auth {
constructor() {
console.log('Auth: constructor()');
}
}
plugins/calvert-auth/index.js
import {BaseConfig} from './baseConfig';
export function configure(frameworkConfig, configCallback) {
frameworkConfig.globalResources('./auth');
let baseConfig = frameworkConfig.container.get(BaseConfig);
if (configCallback !== undefined && typeof(configCallback) === 'function') {
configCallback(baseConfig);
}
}