disabling normalize breaks static build #417
Description
continuing from the thread at: jspm/jspm#1314
In the project im working on, im doing dynamic requires, as in, the name of the module I require is constructed at runtime based on configuration that is provided at build time. I had trouble getting this to work but found an almost adequate solution by setting the compile option "encodeNames" to false. However this left a couple of problems, 1) the ".js" extension was left in the dependency names (annoying be workable) and 2) the aliases from my config.js were ignored.
My config.js looks something like this:
System.config({
//...
meta: {
"jtvw.integrations/integrationsProvider":{
"format": "cjs",
"deps": ["jtvw.integrations/facebook/fbIntegrator",
"jtvw.integrations/twitter/twitterIntegrator"]
},
},
map: {
//...
"jtvw.integrations": "src/integrations",
//...
}
});
So in my code (integrations provider) I would like to do something like this:
require("jtvw.integrations/" + name + "/" + config.intName); //ex: name = facebook, config.intName = fbIntegrator
With just encodeNames set to false, I get in the bundled code:
$__System.registerDynamic("src/integrations/integrationsProvider.js", ["web-commons", "promise",
"utils", "Logger", "src/integrations/facebook/fbIntegrator.js", "src/integrations/twitter/twitterIntegrator.js"],
true, function($__require, exports, module) {
//...
The dependency names dont match my config or my code... 😞
So I realized that passing "normalize = false" will make the dependency names stay as I want them:
$__System.registerDynamic("src/integrations/integrationsProvider.js", ["web-commons", "promise",
"utils", "Logger", "jtvw.integrations/facebook/fbIntegrator", "jtvw.integrations/twitter/twitterIntegrator"],
true, function($__require, exports, module) {
//...
but... now I have a bigger problem, the require calls inside the module arent renamed correctly, even for the normal (not dynamic) dependencies and the resulting code is:
$__System.registerDynamic("src/integrations/integrationsProvider.js", ["web-commons", "promise",
"utils", "Logger", "jtvw.integrations/facebook/fbIntegrator", "jtvw.integrations/twitter/twitterIntegrator"],
true, function($__require, exports, module) {
;
var global = this,
__define = global.define;
global.define = undefined;
module.exports = (function() {
"use strict";
var _ = require("web-commons").common,
Promise = require("promise").Promise,
utils = require("utils"),
logger = require("Logger").getLogger();
//...
notice that the module function receives "$__require" while inside the calls are left as "require" which of course fails with "require is not defined" Error.
Am I missing something here? does disabling normalize also means the require method isnt renamed on purpose or is it a bug?
thanks.