npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

alloy-compiler

v0.2.7

Published

Compiler for Alloy components

Downloads

30

Readme

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.