{"id":27196,"library":"onejs-unity","title":"onejs-unity","description":"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.","status":"active","version":"0.2.13","language":"javascript","source_language":"en","source_url":"https://github.com/Singtaa/onejs-unity","tags":["javascript","unity","onejs","esbuild","postcss","tailwindcss","uss","css-modules","gpu","typescript"],"install":[{"cmd":"npm install onejs-unity","lang":"bash","label":"npm"},{"cmd":"yarn add onejs-unity","lang":"bash","label":"yarn"},{"cmd":"pnpm add onejs-unity","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for React-based UI in OneJS","package":"react","optional":false},{"reason":"Peer dependency for build plugins","package":"esbuild","optional":false},{"reason":"Peer dependency for PostCSS plugin","package":"postcss","optional":false},{"reason":"Peer dependency for tailwindPlugin (though built-in USS generator may reduce need)","package":"tailwindcss","optional":false}],"imports":[{"note":"Named export from subpath module, not default.","wrong":"import loadImage from 'onejs-unity/assets'","symbol":"loadImage","correct":"import { loadImage } from 'onejs-unity/assets'"},{"note":"ESM-only package; CommonJS require will fail. Also, note the subpath '/esbuild'.","wrong":"const importTransformPlugin = require('onejs-unity/esbuild')","symbol":"importTransformPlugin","correct":"import { importTransformPlugin } from 'onejs-unity/esbuild'"},{"note":"Must import from 'onejs-unity/esbuild', not the main package.","wrong":"import { ussModulesPlugin } from 'onejs-unity'","symbol":"ussModulesPlugin","correct":"import { ussModulesPlugin } from 'onejs-unity/esbuild'"}],"quickstart":{"code":"import { loadImage } from 'onejs-unity/assets';\nimport { ussModulesPlugin, tailwindPlugin } from 'onejs-unity/esbuild';\n\n// Load an image asset\nconst logo = loadImage('images/logo.png');\n\n// esbuild config for USS plugins (e.g., in build script)\nconst esbuildConfig = {\n  plugins: [\n    ussModulesPlugin({ generateTypes: true }),\n    tailwindPlugin({ content: ['./src/**/*.{tsx,ts}'] }),\n  ],\n};","lang":"typescript","description":"Demonstrates asset loading and esbuild plugin setup for USS transformation with TypeScript."},"warnings":[{"fix":"You can install tailwindcss as a peer dep to satisfy the requirement, but it is not strictly needed for the USS generation.","message":"The 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use assetExists() to check availability before loading, or wrap calls in try-catch blocks.","message":"Asset 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.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure module names start with an uppercase letter (e.g., 'UnityEngine', not 'unityEngine').","message":"Import paths for C# namespaces are case-sensitive and must start with an uppercase letter for importTransformPlugin to work.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Node or use a bundler that supports package.json exports.","message":"If using an older version of OneJS that does not support subpath imports (e.g., Node <16), require /esbuild or /assets subpaths may fail.","severity":"breaking","affected_versions":"<0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"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.","cause":"Using a bundler or Node version that doesn't resolve package.json exports correctly.","error":"Cannot find module 'onejs-unity/esbuild'"},{"fix":"Use: import { loadImage } from 'onejs-unity/assets';","cause":"Misnamed import: likely imported as default instead of named.","error":"TypeError: loadImage is not a function"},{"fix":"Provide content glob array: tailwindPlugin({ content: ['./src/**/*.{tsx,ts}'] })","cause":"Missing content option when initializing tailwindPlugin.","error":"Error: [tailwindPlugin] content option is required"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}