Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commonjs support #59

Open
konsumer opened this issue Jan 4, 2015 · 2 comments
Open

commonjs support #59

konsumer opened this issue Jan 4, 2015 · 2 comments

Comments

@konsumer
Copy link

konsumer commented Jan 4, 2015

I would like CommonJS support for using in browserify (and others,) which might help simplify the build process & better track dependencies, too.

Here is an example package.json file:

{
  "name": "audiolet",
  "version": "1.0.0",
  "description": "Real-time audio synthesis and composition from within the browser",
  "main": "src/audiolet/commonjs.js",
  "repository": {
    "type": "git",
    "url": "http://github.com/oampo/Audiolet.git"
  },
  "bugs": {
    "url": "http://github.com/oampo/Audiolet/issues"
  },
  "scripts": {
    "build": "browserify src/audiolet/commonjs.js --standalone Audiolet -o src/audiolet/Audiolet.js && uglifyjs src/audiolet/Audiolet.js -o src/audiolet/Audiolet.min.js"
  },
  "devDependencies": {
    "browserify": "^8.0.3",
    "uglify-js": "^2.4.16"
  },
  "dependencies": {
    "sink.js": "^0.0.1"
  }
}

In this example src/audiolet/commonjs.js should be an entry point that exposes the API with module.exports, and you can build standalone versions (for plain browser-globals & requirejs) with npm run build.

If you don't want to go full-on into browserify, etc, support for CommonJS would still enable others who use it to use audiolet easier (and without adding script tags to html.)

if this is published to npm, users can do npm install audiolet to install in their project & use it like this:

var Audiolet = require('audiolet');

Since browserify will build versions for others (requirejs, browser-global) you don't have to manage concatenating the files & if the user uses a module system that avoids browser-globals, they won't be exposed.

Also, as a sidenote, this will add server-side node to your available deployment targets. sink,js already targets node server-side sound, so it should work pretty well, natively.

The real work is going through all the files and setting up the CommonJs dependencies in every file. I am happy to do this work, if all this sounds like a good idea.

@oampo
Copy link
Owner

oampo commented Jan 6, 2015

Hey David,

I've really not had much time to put into Audiolet for quite a while now, and it would be really nice to see it become a bit more modern looking. CommonJS and Node support would be pretty high on the list of priorities, so yeah, if you are up for doing the work I'll be happy to merge it. Hopefully it'll kick-start me to clean up some more rough edges and start doing a bit of work on this again!

Cheers,
Joe

@konsumer
Copy link
Author

konsumer commented Jan 6, 2015

I am working on a project that I hope to use it in, so I am happy to lend a hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants