busterjs/buster — Issue #45: buster static doesn't work with requirejs
Author: johlrogge
Created: 2011-12-28 22:23:58+00:00
State: open

When I run buster static for a requirejs application it fails with this exception:

Uncaught Error: Module name 'fs' has not been loaded yet for context: _
http://requirejs.org/docs/errors.html#notloaded
req.onErrorrequire-jquery.js:1524
context.requirerequire-jquery.js:1241
requirejsrequire-jquery.js:1470
addCSSbuster-static-html-reporter.js:184
htmlReporter.setRootbuster-static-html-reporter.js:39
htmlReporter.createbuster-static-html-reporter.js:14
(anonymous function)buster-static-browser-run.js:3
(anonymous function)buster-static-browser-run.js:7

I believe (without doing too much analysis) that in order to know wether or not the code runs in a node-environment a tests is made wether the require function is defined. Requirejs defines a require-function so the test passes and the browser code believes that it executes in a node environment.

If this is correct, perhaps it would be good to have a way to test for a node environment on the buster-object. That way the test can be rather involved and changed when problems like this is discovered.