Registry / web-framework / onejs-unity

onejs-unity

JSON →
library0.2.13jsnpmunverified

Unity integration utilities for OneJS (v0.2.13), providing asset loading, esbuild/PostCSS build plugins for USS transformation, and GPU compute APIs. Designed for Unity developers using OneJS to write UI and logic in JavaScript/TypeScript. Key differentiators: automatic path resolution between Editor and Build modes, npm package asset distribution without config, built-in Tailwind-like utility class generation for USS without external tailwindcss dependency, and ES6 import transformation for C# namespaces. Requires react ^18/^19, esbuild >=0.17, postcss >=8, tailwindcss >=3. Ships TypeScript types.

npm install onejs-unity
INSTALL
IMPORT
SIG · ONEJS-UNITY
O
onejs-unity
web-frameworkjavascriptv0.2.13
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

loadImage
import { loadImage } from 'onejs-unity/assets'
import loadImage from 'onejs-unity/assets'
Named export from subpath module, not default.
importTransformPlugin
import { importTransformPlugin } from 'onejs-unity/esbuild'
const importTransformPlugin = require('onejs-unity/esbuild')
ESM-only package; CommonJS require will fail. Also, note the subpath '/esbuild'.
ussModulesPlugin
import { ussModulesPlugin } from 'onejs-unity/esbuild'
import { ussModulesPlugin } from 'onejs-unity'
Must import from 'onejs-unity/esbuild', not the main package.

Demonstrates asset loading and esbuild plugin setup for USS transformation with TypeScript.

import { loadImage } from 'onejs-unity/assets'; import { ussModulesPlugin, tailwindPlugin } from 'onejs-unity/esbuild'; // Load an image asset const logo = loadImage('images/logo.png'); // esbuild config for USS plugins (e.g., in build script) const esbuildConfig = { plugins: [ ussModulesPlugin({ generateTypes: true }), tailwindPlugin({ content: ['./src/**/*.{tsx,ts}'] }), ], };
Debug
Known issues
gotchaThe tailwindPlugin does NOT require an external tailwindcss package; it generates USS classes internally. However, the peer dependency 'tailwindcss' is still listed, which may be confusing.
fix
You can install tailwindcss as a peer dep to satisfy the requirement, but it is not strictly needed for the USS generation.
affects: >=0.0.0
gotchaAsset loading functions (loadImage, etc.) are synchronous and may throw if the asset does not exist. Ensure assetExists() checks before loading or wrap in try/catch.
fix
Use assetExists() to check availability before loading, or wrap calls in try-catch blocks.
affects: >=0.0.0
gotchaImport paths for C# namespaces are case-sensitive and must start with an uppercase letter for importTransformPlugin to work.
fix
Ensure module names start with an uppercase letter (e.g., 'UnityEngine', not 'unityEngine').
affects: >=0.0.0
breakingIf using an older version of OneJS that does not support subpath imports (e.g., Node <16), require /esbuild or /assets subpaths may fail.
fix
Upgrade Node or use a bundler that supports package.json exports.
affects: <0.1.0
Errors
Common errors & fixes
Cannot find module 'onejs-unity/esbuild'
Using a bundler or Node version that doesn't resolve package.json exports correctly.
fix
Ensure your bundler (esbuild, webpack, etc.) supports subpath exports. For Node scripts, use Node >=16. Alternatively, import from the main package if the subpath is not required.
TypeError: loadImage is not a function
Misnamed import: likely imported as default instead of named.
fix
Use: import { loadImage } from 'onejs-unity/assets';
Error: [tailwindPlugin] content option is required
Missing content option when initializing tailwindPlugin.
fix
Provide content glob array: tailwindPlugin({ content: ['./src/**/*.{tsx,ts}'] })
Upgrade
Version history
0.2.13latest on npm
Audit
Dependencies
reactrequiredPeer dependency for React-based UI in OneJS
esbuildrequiredPeer dependency for build plugins
postcssrequiredPeer dependency for PostCSS plugin
tailwindcssrequiredPeer dependency for tailwindPlugin (though built-in USS generator may reduce need)
Agent activity
2 hits · last 30 days
node
2
Resources
onejs-unity — npm install onejs-unity · libregistry