incuna/grunt-maketextfiles — pull request #1 by grahamgilchrist (2014-01-07 10:02:58+00:00)
Title: Fix lost requirejs config

@incuna/js So, this grunt module unfortunately is broken and has a tricky requireJS bug that's been driving me slightly crazy.

In the previous version of makeTextFiles.js (also a node module) we import the requireJS config file generated by jam using the following two lines:

```
var requirejs = require('require');
requirejs(requireConfigPath);
```

This correctly loads the requireJS jam config, and later calls to `requirejs.toUrl(moduleName)` have the correct module path from Jam.

Doing this in the new version, exact same script, except that it is now inside a grunt module, fails to load the require config.
Calls to `requirejs.toUrl(moduleName)` come back with the wrong path, simply returning the module name. I've confirmed that the `require.config.js` is definitely being included and run with console logs, and that the requireJS config file is correctly loaded within the `require.config.js` file, but the loaded require.config in that file is not returned to the calling makeTextFiles script.

I don't understand why using the same version of requireJS (updated in this PR) and this single line doesn't do the same thing in the grunt module as the original node module. Both are essentially node modules. The only change I can see is that we load the new one by an absolute file path, but I can't see how this would change whether the config value is returned from the required file?

Attached is a PR which fixes the problem, but only by ditching requireJS for including the config and instead using the built-in node `require` (commonJS) version. This works, as Jam outputs the `require.config.js` in several ways to be included by different AMD systems. However, it seems wrong, as we are using requireJS throughout the chain and we ought to be relying on that...

Is this a crazy ix, or have I missed something else?
Suggestions/solutions welcome!