SlexAxton/require-handlebars-plugin — pull request #218 by Dremora (2014-12-10 19:39:35+00:00)
Title: Fixed: removeCombined breaks the build with multiple modules

I'm trying to build multiple applications and a shared library into a set of files, with one file per app and one file for shared code. `removeCombined` option is enabled. The example below for simplicity has two modules.

```
root/
src/
foo.js
bar.js
template.hbs
config.js
```

**src/foo.js**:
```javascript
define(function (require) {
require('bar');
});
```

**src/bar.js**:
```javascript
define(function (require) {
require('hbs!./template');
});
```

**src/template.hbs**
```handlebars

```

**config.js**:
```javascript
({
paths: {
hbs: '../bower_components/require-handlebars-plugin/hbs'
},
appDir: 'src',
baseUrl: './',
dir: 'build/src',
removeCombined: true,
modules: [
{
name: 'foo',
exclude: [ 'bar' ]
},
{
name: 'bar'
}
]
})
```

However, combined templates are removed too early. I'm getting the following error:
```
$ r.js -o config.js

Tracing dependencies for: foo

Tracing dependencies for: bar
Error: ENOENT, no such file or directory '/Users/dremora/Code/playground/require-handlebars-plugin-bug/build/src/template.hbs'
In module tree:
bar
hbs

Error: Error: ENOENT, no such file or directory '/Users/dremora/Code/playground/require-handlebars-plugin-bug/build/src/template.hbs'
In module tree:
bar
hbs

at Object.fs.openSync (fs.js:438:18)
```

See also [this gist](https://gist.github.com/Dremora/3c4b0bcd3126803780c1) (checkout, run `bower install && r.js -o config.js`).

This pull request fixes the issue.