and decorator errors until tsconfigRaw is set. (<<Add to title)
Hi all, Iâm new to Needle and used the âNeedle Face Filter Examplesâ sample from Unity for a uni project. I hit a chain of problems that ended in a working setup. Iâm posting the details in case they help others, and in case the sample or templates could be updated.
Setup
- Windows, Unity 6000.0.82f1, Node v22.20.0, BASIC (non-commercial) license
- Web project in Library/Needle/Sample
- Face filter: Unity side uses the local tarball com.needle.face-filter-1.0.0-beta.12.tgz (the registry returns an authentication error for com.needle.face-filter). Web side: @needle-tools/facefilter 1.0.4 from npm.
Symptoms and causes
-
Infinite white screen on engine 5.1.14 / 6.0.0-alpha.3 with Vite 8
The dev server stopped at âbundling dependenciesâŠâ and the page never loaded. The default sandbox worked. I didnât find the exact cause. It went away after I moved to the combination below. -
Build error on engine 5.1.14: âhasProLicense is not exportedâ
This appeared when building with the facefilter package, so it looks like a version mismatch between the facefilter package and the engine. It disappeared on engine 4.10.2. -
Unity kept resolving the engine to 5.1.2
com.needle.engine-samples 1.5.1 depends on com.needle.engine-exporter 5.1.2, which overrode my manifest.json entry of 4.10.2. I had to remove com.needle.engine-samples from Packages/manifest.json, delete Packages/packages-lock.json and reopen Unity. -
Build error on engine 4.10.2 with Vite 8: âFailed to convert builtin plugin âViteAliasââ
Fixed with: npm i -D vite@7 (7.3.6). The FAQ currently says recent engine versions need Vite 8+, which seems to be true for 5.x but not for 4.10.2. -
Runtime errors on engine 4.10.2 / Vite 7
-
ReferenceError: Cannot access â_ShaderToyFaceFilterâ before initialization
-
TypeError: Cannot read properties of undefined (reading â__internalAwakeâ)
-
warnings about â@serializable without a targetâ and âUnknown components in sceneâ
My tsconfig.json already had experimentalDecorators: true, but the facefilter package ships TypeScript source (main: index.ts) under node_modules, and my guess is the project tsconfig isnât applied to those files, so the decorators were compiled incorrectly. Setting tsconfigRaw directly in vite.config.js fixed it:
esbuild: {
tsconfigRaw: { compilerOptions: { experimentalDecorators: true, useDefineForClassFields: false } },
},
optimizeDeps: {
esbuildOptions: {
tsconfigRaw: { compilerOptions: { experimentalDecorators: true, useDefineForClassFields: false } },
},
},
Working combination
- @needle-tools/engine 4.10.2 (Unity package and npm)
- Vite 7.3.6, @vitejs/plugin-basic-ssl 2.3.0
- @needle-tools/facefilter 1.0.4 (npm), Unity face-filter package from the local beta.12 tarball
- Needle Engine Samples package removed
- tsconfigRaw added to vite.config.js as above
With this the camera permission prompt appears and the face filter runs.
Questions
- Is there a recommended engine/facefilter/Vite combination for the face filter sample on engine 5.x? Is a newer facefilter build planned?
- Should the Vite config in the face filter template set tsconfigRaw (or should the package ship compiled JS)?
- Is there a supported way to stop the Unity integration from overwriting vite.config.js and package.json in Library/Needle/Sample? I know the npm: prefix protects the engine version, but I couldnât find anything about the other files.
- Is the authentication error for com.needle.face-filter on packages.needle.tools expected?
I havenât tested the production build (vite build / preview) after the fix, and I canât be sure the root causes are exactly as I described.
Thanks!