Reputation: 239
Our environment has setup a private git repository and configured jspm to install packages from this repository. The repo has a .js, .html, and .css file. Jspm brings all the files down into a folder with @master appended to the name to reflect the branch and stores it all in the pre-configured jspm_packages location on my machine. It also adds a second @master.js file next to the folder with export statements inside (I didn't create this file myself).
These files represent custom elements I want to use in my aurelia application. There is a .js for the viewmodel and a .html for the view (and a .css file). When I go to use the custom element I get a 404, file not found, because system.js is looking for a @master.html file, which doesn't exist.
Jspm seems to be referencing the @master.js file in config.js and somehow that's assuming a @master.html file in Aurelia? Only a @master.js file was created when I installed the package using jspm. The original .html file does exist and lives inside the folder I mention above, but that @master.html file does not and I'm not sure 1) what that file would be for and 2) why it's being referenced. There no reference to @master.html in my code.
I'm not really even sure if this is a JSPM issue, Aurelia issue, System.js issue, or some combination of them?
Anyone else have a similar experience with these technologies?
Thanks, Chris
Upvotes: 0
Views: 164
Reputation: 616
Essentially, Aurelia believes you are importing your repo as a custom element, so when you are importing the @master.js it is looking for the matching "view" of what it assumes is a viewmodel.
It sounds like you need to structure your repository as a plugin. Add an index.js
file at the top level and make that responsible for running the configure function, which should make the components you want global resources. Ensure your package.json points to your index.js
as the 'main'. After that, you would need to add a .plugin('your-package-name') in the main.js
file, just like any other plugin.
An example index.js
is like so:
import {Options, GLOBAL_OPTIONS, DIRECTION} from './options';
import {Dragula} from './dragula';
import {moveBefore} from './move-before';
export {Dragula, Options, DIRECTION, moveBefore};
export function configure(config, callback) {
let defaults = new Options();
config.container.registerInstance(GLOBAL_OPTIONS, defaults);
if (callback !== undefined && typeof callback === 'function') {
callback(defaults);
}
config.globalResources(['./dragula-and-drop']);
}
(taken from here)
Upvotes: 0