Last active
September 9, 2022 11:33
-
-
Save michaelnero/ffa1104721943effa44dc1802caa7427 to your computer and use it in GitHub Desktop.
Aurelia node resolve error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Dumber Gist</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> | |
<base href="/"> | |
</head> | |
<!-- | |
Dumber Gist uses dumber bundler, the default bundle file | |
is /dist/entry-bundle.js. | |
The starting module is pointed to "main" (data-main attribute on script) | |
which is your src/main.ts. | |
--> | |
<body> | |
<my-app></my-app> | |
<script src="/dist/entry-bundle.js" data-main="main"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"aurelia": "latest" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Aurelia, { RouterConfiguration} from 'aurelia'; | |
import { MyApp } from './my-app'; | |
Aurelia.register(RouterConfiguration).app(MyApp).start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<import from="./my-component"></import> | |
<div class="message">${message}</div> | |
<au-viewport default="my-component"></au-viewport> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class MyApp { | |
public message: string = 'Hello Aurelia 2!'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<import from="./sub-component"></import> | |
<div>This is my component</div> | |
<sub-component></sub-component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { inject } from "aurelia"; | |
import { INode } from "@aurelia/runtime-html"; | |
import { IMyService } from "./my-service"; | |
export class MyComponent { | |
constructor( | |
@INode private readonly node: INode<Element>, // Remove this, and you won't get an error | |
@IMyService private readonly service: IMyService) { // This always works | |
this.node.id = "some-id"; | |
} | |
} | |
<!-- Note that this method also fails | |
@inject(Element) | |
export class MyComponent { | |
constructor(private readonly node: Element) { | |
this.node.id = "some-id"; | |
} | |
} | |
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DI } from "aurelia"; | |
export const IMyService = DI.createInterface<IMyService>(x => x.singleton(MyService)); | |
export interface IMyService extends MyService { } | |
export class MyService { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div>Sub component</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { INode } from "aurelia"; | |
export class SubComponent { | |
// The following works correctly | |
constructor(@INode private readonly node: INode<Element>) { | |
this.node.id = "sub-id"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment