-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hi there,
Thanks for creating this library.
I just tried to get this working and encountered a problem - not sure if it's memfiles or if its just how rjs works.
Given the example in the Readme (which works when the file doesn't have any dependencies):
var fs = require( "js" );
var requirejs = require( "requirejs-memfiles" );
var files = {
"main.js": fs.readFileSync( "./main.js" ),
...
}
requirejs.setFiles( files, function( done ) {
requirejs.optimize({
appDir: ".",
baseUrl: ".",
dir: "dist",
modules: [{
name: "output",
include: "main",
create: true
}]
}, function() {
var output = files[ "dist/output.js" ];
...
done();
}, function( error ) {
// handle error
...
done();
});
});
Now, if we set main.js content to look like the following so it has a dependency to another module:
define("Main", ["require", "exports", "ModuleA"], function (require, exports, moduleA) {
"use strict";
});
And then you include this additional file:
var moduleAContents = "define(\"ModuleA\", [\"require\", \"exports\"], function (require, exports) {\r\n \"use strict\";\r\n});";
var files = {
"main.js": fs.readFileSync( "./main.js" ),
"ModuleA.js": moduleAContents,
}
Now, during the optimisation, the rjs optimiser requests a file from the in memory files on the path: dist/ModuleA.js . This file doesn't exist.
Rjs doesn't appear to copy the ModuleA file from its original location, to the build directory, and then it requests it from the build directory location - and it isn't there.
If I change the "modules" config to list each module independently -like this:
modules: [{
name: "Main",
},{
name: "ModuleC",
}]
When I do that, rjs now copies each of the files to the built location, and optimisation succeeds.
In the case that I wish to optimise a single file, that has dependencies, i'm not sure the best way to do this using memfiles at the moment due to this issue.
Any pointers greatly appreciated.