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

one

Package Overview
Dependencies
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

one

Transform NodeJS packages into single stand-alone script files.

  • 1.1.5
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
decreased by-32.66%
Maintainers
1
Weekly downloads
 
Created
Source

OneJS is a command-line utility for converting CommonJS packages to single, stand-alone JavaScript files that can be run on other JavaScript platforms such as web browsers, unity, silkjs etc.

Motivation

  • Reusability OneJS aims to let developers run NodeJS modules and packages on all environments able to execute JavaScript.
  • Elegant Modularization OneJS lets web projects benefit from CommonJS, an excellent proposal that gives us a very well designed way to structure JavaScript source codes.
  • NPM It eventually makes it possible for web projects to use NPM. Which is a great tool that makes controlling dependencies even fun!
  • No Spaghetti Code No awkward headers, no framework-specific definitions which become deprecated in a few years.
  • Reliable code generation OneJS doesn't change your source code. It only generates a container environment that simply emulates NodeJS environment.
  • Unobtrusive Code OneJS generates puts all content into an isolated JS object.

Examples

  • See the example project included in this repository
  • See MultiplayerChess.com's source code.

Install

$ npm install one
  • Tip: Pass -g parameter to install it globally. *

First Steps

Testing Example Project

It's an easy way to give OneJS a test-drive. Example project is located at this repository;

$ git clone git@github.com:azer/onejs.git
$ cd onejs
$ npm install
$ cd example-project

It's a non-functional NodeJS project with some dummy dependencies under node_modules directory. The built file will contain all the packages under node_modules directory;

$ ../bin/onejs build package.json bundle.js

Now we're willing to test the code OneJS generated for us. Quickest way might be requiring it from NodeJS;

> var exampleProject = require('./bundle');
> exampleProject.main() // calls main module of the package, returns its exports
> exampleProject.require('./b') // each package object has a require method available for external calls

To test it on web browsers, OneJS has a "server" command that builds the source code and start serving it at localhost:1338.

$ ../bin/onejs server example-project/package.json

You can simply go to that URL and inspect the content of "exampleProject" object, using Firebug Lite. The whole source code with dependencies (if exists) is wrapped by it. It also provides an external API for the possible clients, containing some methods such as require, main, stdin, stdout, stderror.

> exampleProject.require('dependency'), exampleProject.require('./b');
> exampleProject.lib.process.stdout.write("Hello World");
> exampleProject.stdout();
"Hello World"

Projects Using OneJS

  • MultiplayerChess.com
  • HighKick

Beginner's Guide

FIXME

API Reference

FIXME

Keywords

FAQs

Package last updated on 29 Feb 2012

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