Permalink
Browse files

start of project, still lots left to do.

  • Loading branch information...
0 parents commit 3c7cb7973cd814fa53fee2181ad03dbb399cc889 @jrburke jrburke committed Jul 14, 2011
@@ -0,0 +1 @@
+demo-build
@@ -0,0 +1,47 @@
+# require-hm
+
+A simulation of some APIs that are proposed for ECMAScript Harmony for
+JavaScript modules, but done as a loader plugin that works with
+[RequireJS](http://requirejs.org), and other AMD loaders that support
+the [loader plugin API](http://requirejs.org/docs/plugins.html) supported by
+RequireJS.
+
+The APIs are taken from here:
+
+* [harmony:modules](http://wiki.ecmascript.org/doku.php?id=harmony:modules)
+* [harmony:module_loaders](http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders)
+* [harmony:modules_examples](http://wiki.ecmascript.org/doku.php?id=harmony:modules_examples)
+
+Not all the APIs are supported, see further below for more details.
+
+## Goals
+
+The goal is to allow using harmony-like modules today, that work in today's
+browsers and in Node. This allows playing with the APIs to make sure
+they get some use and understanding before baking them into a standard.
+
+It is also a way for me to experiment with the API and suggest changes in a way
+that holds together in real code.
+
+## Limitations
+
+The loader plugin just uses some regular expressions, and
+it relies on existing JavaScript engines, which cannot do the fancy compilation
+and linking that native support can do.
+
+This means some things that would be early errors in a native implementation are
+not early errors with this approach, and there are probably some parsing edge
+cases that fail with this approach vs. native support.
+
+It is possible to take this code and go further with some AST tools like
+UglifyJS, and this code may expand for that purpose, but for now, the regexp
+approach allows a quicker proof of concept.
+
+## Supported APIs
+
+TODO
+module math {} NOT supported
+
+string resolution: .js and mod/name
+Mention .hm for the files that are harmony files.
+Inclusion and exclusion lists?
@@ -0,0 +1,15 @@
+({
+ appDir: '.',
+ baseUrl: 'lib',
+ //Uncomment to turn off uglify minification.
+ //optimize: 'none',
+ dir: '../demo-build',
+ paths: {
+ cs: '../../cs'
+ },
+ modules: [
+ {
+ name: "main"
+ }
+ ]
+})
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+rm -rf ../demo-build
+node ../tools/r.js -o build.js
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>CoffeeScript Loader Plugin Demo</title>
+ <script data-main="lib/main" src="lib/require.js"></script>
+</head>
+<body>
+ <h1>CoffeeScript Loader Plugin Demo</h1>
+</body>
+</html>
@@ -0,0 +1,7 @@
+
+define {
+ attach: (view) ->
+ # Just a simple demonstration of some modules cooperating.
+ require.ready () ->
+ view.render document.getElementsByTagName('body')[0]
+}
@@ -0,0 +1,3 @@
+
+define ['cs!controller', 'cs!view'], (controller, view) ->
+ controller.attach(view)
@@ -0,0 +1,5 @@
+require({
+ paths: {
+ cs: '../../cs'
+ }
+}, ['cs!csmain']);
Oops, something went wrong. Retry.

0 comments on commit 3c7cb79

Please sign in to comment.