{"id":24900,"library":"alloy-compiler","title":"alloy-compiler","description":"Compiler for Appcelerator Titanium Alloy components, enabling standalone compilation of controllers and views. Current version 0.2.7, updated periodically. Unlike the full Alloy CLI, this package can be integrated into custom build toolchains, including Webpack-based setups. It provides createCompiler and createCompileConfig functions for programmatic use, with support for platform-specific output and source maps. Requires Node >=10.","status":"active","version":"0.2.7","language":"javascript","source_language":"en","source_url":"https://github.com/appcelerator/alloy-devkit","tags":["javascript","alloy","compiler"],"install":[{"cmd":"npm install alloy-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add alloy-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add alloy-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package uses CommonJS; ESM import may not work without transpilation.","wrong":"import { createCompiler } from 'alloy-compiler';","symbol":"createCompiler","correct":"const { createCompiler } = require('alloy-compiler');"},{"note":"Both are valid but destructuring is preferred.","wrong":"const createCompileConfig = require('alloy-compiler').createCompileConfig;","symbol":"createCompileConfig","correct":"const { createCompileConfig } = require('alloy-compiler');"},{"note":"compileComponent is an instance method, not a static export.","wrong":"const { compileComponent } = require('alloy-compiler');","symbol":"compiler.compileComponent","correct":"const compiler = createCompiler(options); const result = compiler.compileComponent(options);"}],"quickstart":{"code":"const { createCompiler, createCompileConfig } = require('alloy-compiler');\n\nconst compileConfig = createCompileConfig({\n  projectDir: '/path/to/project',\n  alloyConfig: {\n    platform: 'ios',\n    deploytype: 'development'\n  }\n});\n\nconst compiler = createCompiler({\n  compileConfig,\n  webpack: false\n});\n\nconst result = compiler.compileComponent({\n  file: '/path/to/project/app/controllers/index.js'\n});\n\nconsole.log(result.code);","lang":"javascript","description":"Shows basic usage to compile an Alloy controller using createCompileConfig and createCompiler."},"warnings":[{"fix":"Use require() or transpile with a bundler like Webpack.","message":"The package uses CommonJS; direct ESM imports may fail in Node.js versions that support ES modules.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always provide compileConfig object with projectDir and alloyConfig.","message":"createCompiler requires compileConfig option even if you pass webpack: true.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure the file exists or provide content option.","message":"compileComponent expects file path; if the file does not exist and content is not provided, it will throw.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use const { createCompiler } = require('alloy-compiler');","cause":"Wrong import pattern (e.g., import instead of require for CommonJS module).","error":"TypeError: createCompiler is not a function"},{"fix":"First create compiler with createCompiler, then call compiler.compileComponent().","cause":"Attempted to import compileComponent directly from package instead of calling it on a compiler instance.","error":"TypeError: compiler.compileComponent is not a function"},{"fix":"Add projectDir to the options object: { compileConfig: { projectDir: '/path' } }","cause":"createCompileConfig or createCompiler called without projectDir in options.compileConfig.","error":"Error: \"projectDir\" is required"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}