Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alloy-compiler

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alloy-compiler

Compiler for Alloy components

  • 0.2.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

alloy-compiler

Compiler for Alloy components

This packages contains the standalone Alloy compiler. In most cases you should be using it in Webpack powered Alloy projects, you will only need it separately if you are writing build tools with very specific needs.

Installation

npm i alloy-compiler

Usage

const { createCompiler, createCompileConfig } = require('alloy-compiler');

API

createCompiler(options)

Creates a new Alloy compiler instance.

Example

const { createCompiler } = require('alloy-compiler');
const compiler = createCompiler({
  compileConfig: {
    projectDir: '/path/to/my/project',
    alloyConfig: {
      platform: 'ios',
      deploytype: 'development'
    }
  },
  webpack: true
});
Options

Expects an options object with the following properties:

  • compileConfig

    • Type: object

    Configuration that will be passed to the Alloy compiler.

    You can either pass an object returned by createCompileConfig or directly pass the same options accepted by that function. The config object will then be created from the passed options.

  • webpack

    • Type: boolean
    • Default: false

    Whether or not to create a special compiler instance that creates optimized output Webpack.

createCompileConfig(options)

Creates a new Alloy compile configuration based on the passed options.

Example
const { createCompileConfig } = require('alloy-compiler');
const compileConfig = createCompileConfig({
  projectDir: '/path/to/my/project',
  alloyConfig: {
    platform: 'ios',
    deploytype: 'development'
  }
});
Parameters

Expects an options object with the following properties:

  • projectDir

    • Type: string

    Path to the root directory of the Alloy project.

  • alloyConfig

    • Type: object

    Alloy configuration. Expects an object with the following structure:

    {
      platform: string // 'ios' or 'android'
      deploytype: string // 'development', 'test' or 'production'
    }
    
  • logLevel

    Log level for the internal logger.

  • buildLog

    • Type: BuildLog
    • Default: BuildLog for the specified projectDir

compiler.compileComponent(options)

Compiles the controller and view of an Alloy component.

Returns a result object with the following structure:

{
  code: string,
  map: object, // Source map
  dependencies: array // List of dependencies used during compilation like view and style file
}
Example
const { createCompiler } = require('alloy-compiler');
const compiler = createCompiler({
  compileConfig: {
    projectDir: '/path/to/my/project',
    alloyConfig: {
      platform: 'ios',
      deploytype: 'development'
    }
  }
});
const result = compiler.compileComponent({
  file: '/path/to/my/project/app/controllers/index.js'
});
Parameters

Expects an options object with the following properties:

  • file

    • Type: string

    Full path to the controller or view file that should be compiled. The compiler will automatically look for all possible associated files of the component (controller/view/style) and process them.

  • content

    • Type: string

    Content of file, if already known. The compiler will automatically read the file's content if this is omitted.

  • inputSourceMap

    • Type: object

    Input source map. The compiler will create a new source map if this is omitted.

Keywords

FAQs

Package last updated on 02 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc