-
Notifications
You must be signed in to change notification settings - Fork 20
Authoring Notes and Warnings
-
.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
require
s should use a string, egrequire('myModule')
. Requires that evaluate at runtime, egrequire(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 (egrequire('../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.