v2.0.0-beta.15
Pre-release
Pre-release
What's Changed
BREAKING CHANGES:
- refactor(runtime): migration to TC39 decorators + metadata simplification by @Sayan751 in #1932
- refactor(exp-parser): move to own package by @bigopon in #1943
- refactor(bindings): move binding infra to runtime html by @bigopon in #1944
Features:
Bug fixes:
- fix(vite-plugin): when using ShadowDOM, need to load css as string by @3cp in #1934
- fix(vite-plugin): missed some default options in "load" preprocess by @3cp in #1936
- chore: default options for internal ts-jest instance by @3cp in #1941
Full Changelog: v2.0.0-beta.14...v2.0.0-beta.15
Decorator migration guide
For the Aurelia 2 codebase, the usage of experimental decorators is turned off in #1932, and all the decorators are migrated to the TC39 decorators. This means when you update your Aurelia2 dependencies to v2.0.0-beta.15 or higher, you need to do the following.
- Ensure that you are using the latest TypeScript version, if you are a TypeScript user.
- Remove the following 2 properties from the effective
tsconfig.json
:"emitDecoratorMetadata": true
and"experimentalDecorators": true
. This activates the native/TC39 decorator. - Ensure that the
target
property is set to something lower thanesnext
. If this is set toesnext
, then TypeScript assumes reasonably that the target runtime supports decorators natively, and hence does not transpile those. - The decorator proposal does not support parameter decorators (yet). Hence, the following code won't work any longer.
Instead, use the
class MyClass { public constructor( @IBar private readonly bar: IBar, @IFoo foo: IFoo, ) {} }
resolve
function.import { resolve } from 'aurelia'; // also can be exported from `@aurelia/kernel`. class MyClass { private readonly bar: IBar = resolve(IBar); public constructor( // alternative#1 foo: IFoo = resolve(IFoo) ) { // alternative#2 const foo: IFoo = resolve(IFoo) } }
- If you are a TypeScript user, and were already using bindable coercers, it might not work after the update. Previously, this feature depended on the emission of design time type metadata. However, TypeScript does not emit this metadata any more with the standardized decorators (yet). Refer microsoft/TypeScript#55788 and microsoft/TypeScript#57533 for more information. For now, you can explicitly specify the type when declaring bindables.
- If you are using only Aurelia decorators in your code, it should be fine if the aforementioned changes are performed. In case you have developed your own decorators, then you need to migrate those by yourself. Here are a couple of resources that can be helpful:
- JavaScript metaprogramming with the 2022-03 decorators API by Dr. Axel Rauschmayer
- TypeScript 5.0 release notes.
- Use the TypeScript playground to check the transpiled code to make you aware of the timings, at which different parts of your decorators are invoked.
- If you are using the Aurelia2 convention plugin, in most case it should work as it supposed to. In case it does not, please inform us.
- If you are not using TypeScript and were already using decorators somehow, consult your transpiler tool docs on how to use the new standard/native decorators.