Hey all, I’m really new to Aurelia and am running into a problem. A finally got a basic project setup and running using webpack. I am now trying to create my first component. At least I think it’s a component. I want to display some information about a logged in user. I can get it to load the .html file with no problem. But I can’t get it to include the backing typescript. I am able to get it to load the html by putting <require from="../debug/userinformation.html" />
and then a <UserInformation></UserInformation>
element in the page I want it displayed on. I have turned on the analysis of the packed js file and found that the javascript isn’t even being included in it.
I feel like I’ve tried everything, but there’s something I’m missing.
Things I have tried (that I can remember):
-
<require from="../debug/UserInformation.html" />
<- only displays the html -
<require from="../debug/UserInformation" />
<- breaks with an ugly error on the page saying its not found -
<require from="../debug/UserInformation.ts" />
<- breaks with an ugly error on the page saying its not found -
<require from="../debug/UserInformation.js" />
<- breaks with an ugly error on the page saying its not found - In boot.ts, adding to the Aurelia.use,
.globalResources("app/components/debug/UserInformation")
. With this I just get an error sayingError: Unable to find module with ID: app/components/debug/UserInformation
. I have tried with .html, .js and .ts extensions. Same error (with the extension). - Adding
import UserInformation from "./app/components/debug/UserInformation";
to boot.ts. This didn’t include it either.
Here’s my UserInformation.html
<template>
Hello!
<button click.trigger="speak()">Say hello to the world</button>
</template>
Here’s UserInformation.ts
import { autoinject, customElement } from 'aurelia-framework';
@autoinject
export default class {
constructor() {
console.log("<<FOUND IT!>>"); //never logged
}
public async attached() {
console.log("hello"); //never logged
}
public speak() {
alert("Spoken"); //never called
}
}
If anybody can offer any guidance on creating a component while using webpack that may help. The little example offered in the docs yielded the same results, backing javascript was not found or executed.