Skip to content

Authoring Notes and Warnings

anodynos edited this page Jun 27, 2013 · 4 revisions
  • .coffee files are valid source modules. All modules are compiled and parsed only as javascript; Module generation is again just javascript. If you want to have .iced, .coco, .ts etc as modules, its VERY easy: you dont need a a plugin, just declare it on bundle.resources.
  • Your requires should use a string, eg require('myModule'). Requires that evaluate at runtime, eg require(myVar + 'module') can't be possibly be evaluated at parse time, and thus are unsafe.

  • Your module define(..) must be a top level in your .js (not nested inside some other code).

  • Everything outside define is simply ignored.

  • Only one module per file is expected - i.e only the first define per file is parsed.

  • Each module build with uRequire has 3 convenience variables that detect the runtime environment: __isAMD, __isNode & __isWeb. They might be optionally removed in the future.

  • You can use the .js extension (but why?) on your dependencies (eg require('../mylib.js'), as it is allowed by nodejs. Because of the different semantics in RequireJS, its fixed(i.e stripped) by uRequire ONLY if not really needed (i.e it exists on your bundle dir). Otherwise its NOT stripped.

  • There are some limitations due to the parser/code generator used (uglifyjs) : a) Comments are ignored and b) some unsafe transformations. This will change sometime, when the parser changes to UglifyJS2 or esprima.

Clone this wiki locally