You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ecs-persistence: [persist] on an app's components fails to compile (trait key from a package's types is 'unique symbol') #239
An app can't mark its components with [persist] as the @adobe/ecs-persistence README shows. With Compiler.plugin() the build fails:
a trait's key persist is a top-level `Symbol()` constant, of this module or one it imports
[baseColorFactor]: { type: Vec4.F32; default: [1, 1, 1, 1]; [persist]: 'baseColorFactor' };
Built with @adobe/ecs 0.2.3, @adobe/ecs-persistence 0.0.1, Vite 8 and Compiler.plugin(), in the dev server, a build and vitest alike.
Cause
The compiler reads a trait key's declaration to check that it is a Symbol() constant (requireTraitKey, augmentations.ts). For an import from a package it reads the types file beside the JavaScript (typesFileOf), and in dist/types/persist.d.ts the key is export declare const persist: unique symbol;, which is not a Symbol() call. The special case that finds a package's source applies to copies of @adobe/ecs itself, not to other packages.
Workaround
Alias @adobe/ecs-persistence to the src/index.ts the package already ships (resolve.alias), and keep it out of the dev server's pre-bundling (optimizeDeps.exclude); under vitest it also needs to be transformed by the plugin. That works but every app has to know to do it.
Requested (any of)
The compiler accepts a trait key whose declaration is declare const x: unique symbol in an imported package's types, since the key's identity is registered at runtime by the package's own JavaScript (declare$(persist, "trait")).
The compiler finds the source a package ships, as it does for @adobe/ecs, for any package that declares traits.
@adobe/ecs-persistence documents what an app must configure, and ships it as a Vite helper.
@adobe/ecs-persistence 0.1.0 declares no trait of its own (#241, in #240): an app declares its own, snapshot({ world, by }), so no package's unique symbol trait key is named in an app's declarations.
Activity
krisnye commentedon Nov 1, 2026
@adobe/ecs-persistence 0.1.0 declares no trait of its own (#241, in #240): an app declares its own,
snapshot({ world, by }), so no package'sunique symboltrait key is named in an app's declarations.