Giter Site home page Giter Site logo

ti-commonjs-wrap-plugin's Introduction

ti-commonjs-wrap-plugin

The module ti-commonjs allows to use NodeJS style modules in Alloy. This plugin for the Titanium CLI adds support for stock Titanium SDK code.

How to install

Check out the module and place it at

plugins/ti-commonjs-wrap-plugin

inside of your Titanium project.

Install the required npm packages:

$ cd plugins/ti-commonjs-wrap-plugin
$ npm install

Add the plugin to your tiapp.xml:

<plugins>
    <plugin version="1.0">ti-commonjs-wrap-plugin</plugin>
</plugins>

How to control what to wrap

The plugin supports a .gitignore like file named .commonjswrapignore in the project root directory. Files matching the patterns in this file are not wrapped, i.e. the require command in those files is the original Titanium require.

How to control where the ti-commonjs module is found

By default the wrapper code will try to tirequire the module node_modules/ti-commonjs/lib/ti-commonjs. If the ti-commonjs npm module is installed somewhere else than in the project root, the ti_commonjs_dir variable must be set in app.js, i.e. globally.

By default ti_commonjs_dir is set to node_modules. If for example ti-commonjs is installed into node_world/node_modules/ti-commonjs, the following is necessary before any wrapped file is required:

ti_commonjs_dir = "node_world/node_modules";
var my_first_node_module = require("node_world/node_app.js");

Like in the upper example this mechanism can be used together with .commonjswrapignore to restrict the wrapping to a "node world" directory. Outside of that directory no wrapping takes place.

The corresponding .commonjswrapignore file looks like this:

*
!Resources/node_world

How to build the example

$ cd example
$ cd Resources
$ npm install
$ cd ..
$ ti build -p ios
...
[DEBUG] Application booted in 123.372018 ms
  mocha
    + works

  1 passing (6ms)

ti-commonjs-wrap-plugin's People

Contributors

sttts avatar

Stargazers

Justin Lee avatar Brenton House avatar Dan Tamas avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.