-
Notifications
You must be signed in to change notification settings - Fork 27
Workers and Node
azproduction edited this page Jan 28, 2013
·
1 revision
- Flags:
node
,worker
You can use LMD in-package modules (require()
) in worker and run it as node script without any config changes.
But if you are going to use require.async()
or require.js()
you should add worker: true
or/and node: true
config
flags. require.css()
in node or worker environment acts like require()
-
require.async()
in Worker environment works exactly the same as in browser environment -
require.async()
in Node usesfs.readFile()
to read file and evals/returns file content depend on file extension -
require.js()
in Worker acts likeimportScripts()
and call back an empty object{}
-
require.js()
in Node acts like Node.jsGLOBALS.require()
and returnsmodule.exports
object from node module -
require.css()
in both environments acts like LMDrequire()
Run tests or see examples/demos/basic/modules/main.js#L60 and examples/demos/basic/modules/workerDepA.js for details