systemjs-builder
Advanced tools
Comparing version 0.14.11 to 0.14.12
@@ -9,2 +9,3 @@ var System = require('systemjs'); | ||
var CJSRequireTransformer = require('./cjs').CJSRequireTransformer; | ||
var Promise = require('bluebird'); | ||
@@ -191,2 +192,6 @@ // First of two-pass transform | ||
} | ||
else if (args.length == 1) { | ||
// allow a define(some && expression || statement) for an object | ||
factoryTree = args[0]; | ||
} | ||
else { | ||
@@ -193,0 +198,0 @@ // not valid define |
@@ -15,2 +15,3 @@ var path = require('path'); | ||
var createUseStrictDirective = traceur.get('codegeneration/ParseTreeFactory.js').createUseStrictDirective; | ||
var Promise = require('bluebird'); | ||
@@ -41,3 +42,3 @@ function hasRemoveUseStrict(list) { | ||
if (tree.operand.identifierToken && tree.operand.identifierToken.value == this.requireName | ||
&& tree.args.args.length && tree.args.args[0].type == 'LITERAL_EXPRESSION' && tree.args.args.length == 1) { | ||
&& tree.args.args.length && tree.args.args.length == 1) { | ||
var requireModule = tree.args.args[0].literalToken.processedValue; | ||
@@ -94,6 +95,12 @@ var requireModuleMapped = this.map && this.map(requireModule) || requireModule; | ||
var value = tree.identifierToken.value; | ||
if (!this.usesFilePaths && value == '__filename' || value == '__dirname') | ||
if (value == '__filename' || value == '__dirname') | ||
this.usesFilePaths = true; | ||
return ParseTreeTransformer.prototype.transformIdentifierExpression.call(this, tree); | ||
}; | ||
CJSRegisterTransformer.prototype.transformerBindingIdentifier = function(tree) { | ||
var value = tree.identifierToken.value; | ||
if (value == '__filename' || value == '__dirname') | ||
this.usesFilePaths = true; | ||
return ParseTreeTransformer.prototype.transformBindingIdentifier.call(this, tree); | ||
}; | ||
@@ -108,3 +115,3 @@ CJSRegisterTransformer.prototype.transformScript = function(tree) { | ||
scriptItemList = parseStatements([ | ||
"var __filename = module.id, __dirname = module.id.split('/').splice(0, module.id.split('/').length - 1).join('/');" | ||
"var $__pathVars = " + this.systemGlobal + ".get('@@cjs-helpers').getPathVars(module.id), __filename = $__pathVars.filename, __dirname = $__pathVars.dirname;" | ||
]).concat(scriptItemList); | ||
@@ -184,2 +191,6 @@ | ||
exports.sfx = function(loader) { | ||
return require('fs').readFileSync(require('path').resolve(__dirname, '../templates/cjs-helpers.js')).toString(); | ||
}; | ||
function remap(source, map, fileName) { | ||
@@ -186,0 +197,0 @@ var options = {script: true}; |
@@ -6,3 +6,25 @@ var traceur = require('traceur'); | ||
var createStringLiteralToken = traceur.get('codegeneration/ParseTreeFactory.js').createStringLiteralToken; | ||
var InstantiateModuleTransformer = traceur.get('codegeneration/InstantiateModuleTransformer.js').InstantiateModuleTransformer; | ||
var CollectingErrorReporter = traceur.get('util/CollectingErrorReporter.js').CollectingErrorReporter; | ||
var UniqueIdentifierGenerator = traceur.get('codegeneration/UniqueIdentifierGenerator.js').UniqueIdentifierGenerator; | ||
function InstantiateOnlyCompiler() { | ||
traceur.Compiler.apply(this, arguments); | ||
} | ||
InstantiateOnlyCompiler.prototype = Object.create(traceur.Compiler.prototype); | ||
InstantiateOnlyCompiler.prototype.transform = function(tree, candidateModuleName, metadata) { | ||
var errorReporter = new CollectingErrorReporter(); | ||
var transformer = new InstantiateModuleTransformer(new UniqueIdentifierGenerator(), errorReporter, this.options_); | ||
if (candidateModuleName) | ||
tree.moduleName = candidateModuleName; | ||
var transformedTree = transformer.transformAny(tree); | ||
this.throwIfErrors(errorReporter); | ||
return transformedTree; | ||
}; | ||
function TraceurImportNormalizeTransformer(map) { | ||
@@ -35,8 +57,23 @@ this.map = map; | ||
// override System instantiate to handle esm tracing | ||
exports.attach = function(loader) { | ||
// NB for better performance, we should just parse and | ||
// cache the AST and store on the metadata, returning the deps only | ||
var loaderTranslate = loader.translate; | ||
loader.translate = function(load) { | ||
return loaderTranslate.call(this, load); | ||
var systemInstantiate = loader.instantiate; | ||
loader.instantiate = function(load) { | ||
// skip plugin loader attachment || non es modules || es modules handled by internal transpilation layer | ||
if (!loader.builder || load.metadata.format != 'esm' || load.metadata.originalSource) | ||
return systemInstantiate.call(this, load); | ||
var compiler = new traceur.Compiler({ script: false, sourceRoot: true }); | ||
load.metadata.parseTree = compiler.parse(load.source, load.path); | ||
var depsList = load.metadata.deps.concat([]); | ||
var extractDependencyTransformer = new TraceurImportNormalizeTransformer(function(dep) { | ||
if (depsList.indexOf(dep) == -1) | ||
depsList.push(dep); | ||
}); | ||
extractDependencyTransformer.transformAny(load.metadata.parseTree); | ||
return Promise.resolve({ | ||
deps: depsList, | ||
execute: null | ||
}); | ||
}; | ||
@@ -54,2 +91,25 @@ }; | ||
// plugin to esm -> ONLY do traceur instantiate conversion, and nothing else | ||
if (load.metadata.loader && load.metadata.format == 'esm') { | ||
var compiler = new InstantiateOnlyCompiler({ | ||
script: false, | ||
sourceRoot: true, | ||
moduleName: !opts.anonymous, | ||
inputSourceMap: load.metadata.sourceMap, | ||
sourceMaps: opts.sourceMaps && 'memory', | ||
lowResolutionSourceMap: opts.lowResSourceMaps | ||
}); | ||
var tree = load.metadata.parseTree || compiler.parse(load.source, load.path); | ||
tree = compiler.transform(tree, load.name); | ||
var outputSource = compiler.write(tree, load.path); | ||
return Promise.resolve({ | ||
source: outputSource, | ||
sourceMap: compiler.getSourceMap() | ||
}); | ||
} | ||
return Promise.resolve(global[loader.transpiler == 'typescript' ? 'ts' : loader.transpiler] || loader.import(loader.transpiler)) | ||
@@ -56,0 +116,0 @@ .then(function(transpiler) { |
@@ -7,2 +7,4 @@ var traceur = require('traceur'); | ||
var createStringLiteral = traceur.get('codegeneration/ParseTreeFactory.js').createStringLiteral; | ||
var parseExpression = traceur.get('codegeneration/PlaceholderParser.js').parseExpression; | ||
var FunctionBody = traceur.get('syntax/trees/ParseTrees.js').FunctionBody; | ||
@@ -12,6 +14,8 @@ // converts anonymous System.register([] into named System.register('name', [], ... | ||
// also this should be rewritten with a proper parser! | ||
function RegisterTransformer(moduleName, map) { | ||
function RegisterTransformer(moduleName, map, systemGlobal) { | ||
this.name = moduleName; | ||
this.hasAnonRegister = false; | ||
this.map = map; | ||
this.systemOperand = parseExpression([systemGlobal + '.register']); | ||
this.usesModuleName = false; | ||
return ParseTreeTransformer.call(this); | ||
@@ -27,7 +31,28 @@ } | ||
&& tree.operand.operand.type == 'IDENTIFIER_EXPRESSION' | ||
&& tree.operand.operand.identifierToken.value == 'System') { | ||
&& tree.operand.operand.identifierToken.value == 'System' | ||
&& tree.args) { | ||
var firstArg = tree.args.args[0]; | ||
var declare; | ||
if (firstArg.type == 'ARRAY_LITERAL') | ||
declare = tree.args.args[1]; | ||
else | ||
declare = tree.args.args[2]; | ||
// contains a __moduleName reference, while System.register declare function doesn't have a __moduleName argument | ||
// so add it | ||
// this is backwards compatibility for https://github.com/systemjs/builder/issues/416 | ||
if (this.usesModuleName && declare && declare.parameterList && declare.parameterList.parameters.length == 1) { | ||
var newDeclare = parseExpression(['function() {}']); | ||
newDeclare.location = declare.location; | ||
newDeclare.body = new FunctionBody(declare.body.location, declare.body.statements); | ||
newDeclare.parameterList.parameters.push(declare.parameterList.parameters[0]); | ||
newDeclare.parameterList.parameters.push(parseExpression(['__moduleName'])); | ||
declare = newDeclare; | ||
} | ||
// System.register(deps, declare) | ||
if (firstArg.type == 'ARRAY_LITERAL') { | ||
if (this.hasAnonRegister) { | ||
@@ -46,11 +71,21 @@ throw 'Source ' + this.name + ' has multiple anonymous System.register calls.'; | ||
var newArgs = this.name ? [createStringLiteral(this.name), normalizedDepArray] : [normalizedDepArray]; | ||
var newArgs = this.name ? [createStringLiteral(this.name), normalizedDepArray, declare] : [normalizedDepArray, declare]; | ||
return new CallExpression(tree.location, tree.operand, | ||
new ArgumentList(tree.args.location, newArgs.concat(tree.args.args.splice(1)))); | ||
return new CallExpression(tree.location, this.systemOperand, new ArgumentList(tree.args.location, newArgs)); | ||
} | ||
// System.register(name, deps, declare) | ||
else { | ||
var args = tree.args.concat([]); | ||
args.splice(2, 1, declare); | ||
return new CallExpression(tree.location, this.systemOperand, args); | ||
} | ||
} | ||
return tree; | ||
} | ||
}; | ||
RegisterTransformer.prototype.transformIdentifierExpression = function(tree) { | ||
if (tree.identifierToken.value == '__moduleName') | ||
this.usesModuleName = true; | ||
return ParseTreeTransformer.prototype.transformIdentifierExpression.call(this, tree); | ||
}; | ||
@@ -71,3 +106,3 @@ exports.compile = function(load, opts, loader) { | ||
var transformer = new RegisterTransformer(!opts.anonymous && load.name, function(dep) { return opts.normalize ? load.depMap[dep] : dep; }); | ||
var transformer = new RegisterTransformer(!opts.anonymous && load.name, function(dep) { return opts.normalize ? load.depMap[dep] : dep; }, opts.systemGlobal); | ||
tree = transformer.transformAny(tree); | ||
@@ -84,5 +119,2 @@ | ||
if (opts.systemGlobal != 'System') | ||
output = output.replace(/System\.register\(/, opts.systemGlobal + '.register('); | ||
return Promise.resolve({ | ||
@@ -89,0 +121,0 @@ source: output, |
@@ -1,3 +0,3 @@ | ||
var asp = require('rsvp').denodeify; | ||
var Promise = require('rsvp').Promise; | ||
var asp = require('bluebird').promisify; | ||
var Promise = require('bluebird'); | ||
var glob = require('glob'); | ||
@@ -219,4 +219,5 @@ var path = require('path'); | ||
exports.traverseTree = traverseTree; | ||
function traverseTree(tree, moduleName, visitor, parent, seen) { | ||
verifyTree(tree); | ||
function traverseTree(tree, moduleName, visitor, reversePost, parent, seen) { | ||
if (!seen) | ||
verifyTree(tree); | ||
@@ -229,11 +230,11 @@ seen = seen || []; | ||
if (curNode && visitor(moduleName, parent) !== false) | ||
getLoadDependencies(curNode).forEach(function(dep) { | ||
if (curNode && visitor(moduleName, parent) !== false) { | ||
var deps = getLoadDependencies(curNode); | ||
if (reversePost) | ||
deps = deps.reverse(); | ||
deps.forEach(function(dep) { | ||
if (seen.indexOf(dep) == -1) | ||
traverseTree(tree, dep, visitor, moduleName, seen); | ||
traverseTree(tree, dep, visitor, reversePost, moduleName, seen); | ||
}); | ||
} | ||
} | ||
} |
@@ -1,5 +0,5 @@ | ||
var Promise = require('rsvp').Promise; | ||
var Promise = require('bluebird'); | ||
var System = require('systemjs'); | ||
var asp = require('rsvp').denodeify; | ||
var asp = require('bluebird').promisify; | ||
var fs = require('fs'); | ||
@@ -26,6 +26,9 @@ var path = require('path'); | ||
require('rsvp').on('error', function(reason) { | ||
throw new Error('Unhandled promise rejection.\n' + reason && reason.stack || reason || '' + '\n'); | ||
}); | ||
// new Builder(baseURL) | ||
// new Builder({cfg}) | ||
// new Builder(baseURL, {cfg}) | ||
// new Builder(baseURL, 'cfg-file.js') | ||
// | ||
// baseURL is ignored in cfg when given | ||
// cfg is saved and used by reset | ||
function Builder(baseURL, cfg) { | ||
@@ -38,2 +41,3 @@ if (typeof baseURL == 'object') { | ||
this.loader = null; | ||
this.resetConfig = function() {}; | ||
@@ -218,4 +222,4 @@ this.reset(); | ||
if (this.resetConfig) | ||
executeConfigFile.call(this, false, true, this.resetConfig); | ||
// run saved configuration functions against new loader instance | ||
this.resetConfig(); | ||
@@ -261,27 +265,17 @@ // create cache if not existing | ||
function executeConfigFile(saveForReset, ignoreBaseURL, source) { | ||
if (saveForReset) | ||
this.resetConfig = source; | ||
var self = this; | ||
var System = this.loader; | ||
// Save existing System.config function. | ||
var systemConfigFunc = System.config; | ||
// Assign a new temporary function which filters the config data; see `Builder.prototype.config`. | ||
System.config = function(config) { | ||
var cfg = {}; | ||
for (var p in config) { | ||
if (ignoreBaseURL && p == 'baseURL' || p == 'bundles' || p == 'depCache') | ||
continue; | ||
cfg[p] = config[p]; | ||
} | ||
// Invoke existing loader config function. | ||
systemConfigFunc(cfg); | ||
// create a safe loader to give to the config execution | ||
var configLoader = Object.create(this.loader); | ||
configLoader.config = function(cfg) { | ||
self.config(cfg, saveForReset, ignoreBaseURL); | ||
}; | ||
// jshint evil:true | ||
eval(source.toString()); | ||
// Assign back to System.config the original saved function. | ||
System.config = systemConfigFunc; | ||
// make everything in global available to config file code | ||
// only substitute local copy of System | ||
// and prevent that code from adding anything to the real global | ||
var context = Object.create(global); | ||
context.System = configLoader; | ||
context.global = context.GLOBAL = context.root = context; | ||
require('vm').runInNewContext(source.toString(), context); | ||
} | ||
@@ -300,3 +294,3 @@ | ||
// note ignore argument is part of API | ||
Builder.prototype.config = function(config, ignoreBaseURL) { | ||
Builder.prototype.config = function(config, saveForReset, ignoreBaseURL) { | ||
var cfg = {}; | ||
@@ -309,2 +303,10 @@ for (var p in config) { | ||
this.loader.config(cfg); | ||
if (saveForReset) { | ||
// multiple config calls can be saved for reset | ||
var curReset = this.resetConfig; | ||
this.resetConfig = function() { | ||
curReset.call(this); | ||
this.loader.config(cfg); | ||
}; | ||
} | ||
}; | ||
@@ -584,3 +586,3 @@ | ||
var load = tree[moduleName]; | ||
if (load && load.deps.length) | ||
if (load && load.deps && load.deps.length) | ||
depCache[moduleName] = load.deps.map(function(dep) { | ||
@@ -587,0 +589,0 @@ return load.depMap[dep]; |
@@ -1,3 +0,3 @@ | ||
var Promise = require('rsvp').Promise; | ||
var asp = require('rsvp').denodeify; | ||
var Promise = require('bluebird'); | ||
var asp = require('bluebird').promisify; | ||
var fs = require('fs'); | ||
@@ -65,2 +65,5 @@ var path = require('path'); | ||
// used to support leading #!/usr/bin/env in scripts as supported in Node | ||
var hashBangRegEx = /^\#\!.*/; | ||
exports.compileLoad = compileLoad; | ||
@@ -99,3 +102,5 @@ function compileLoad(loader, load, compileOpts, cache) { | ||
if (format in compilerMap) | ||
if (format in compilerMap) { | ||
if (format == 'cjs') | ||
mappedLoad.source = mappedLoad.source.replace(hashBangRegEx, ''); | ||
return Promise.resolve(require(compilerMap[format]).compile(mappedLoad, compileOpts, loader)) | ||
@@ -115,2 +120,3 @@ .then(function(output) { | ||
}); | ||
} | ||
@@ -122,4 +128,4 @@ return Promise.reject(new TypeError('Unknown module format ' + format)); | ||
// (exported for unit testing) | ||
exports.getTreeModulesReversePreOrder = getTreeModulesReversePreOrder; | ||
function getTreeModulesReversePreOrder(tree) { | ||
exports.getTreeModulesPostOrder = getTreeModulesPostOrder; | ||
function getTreeModulesPostOrder(tree) { | ||
var entryPoints = []; | ||
@@ -130,3 +136,5 @@ | ||
var moduleList = Object.keys(tree).sort(); | ||
var moduleList = Object.keys(tree).filter(function(module) { | ||
return tree[module] !== false; | ||
}).sort(); | ||
@@ -158,7 +166,7 @@ // for each module in the tree, we traverse the whole tree | ||
entryPoints.forEach(function(moduleName) { | ||
entryPoints.reverse().forEach(function(moduleName) { | ||
traverseTree(tree, moduleName, function(depName, parentName) { | ||
if (modules.indexOf(depName) == -1) | ||
modules.push(depName); | ||
}); | ||
}, true); | ||
}); | ||
@@ -177,3 +185,3 @@ | ||
var ordered = getTreeModulesReversePreOrder(tree); | ||
var ordered = getTreeModulesPostOrder(tree); | ||
@@ -265,2 +273,3 @@ // get entrypoints from graph algorithm | ||
.then(function(compiled) { | ||
compiled = compiled || []; | ||
compiled.forEach(function(output) { | ||
@@ -320,3 +329,3 @@ if (output instanceof Array) | ||
// exact meta | ||
if (pkg.modules && pkg.modules[subPath]) { | ||
if (pkg.modules && typeof pkg.modules[subPath] == 'object') { | ||
var fromMeta = pkg.modules[subPath]; | ||
@@ -394,6 +403,3 @@ | ||
return { | ||
outputs: outputs, | ||
assets: assets | ||
}; | ||
return outputs; | ||
} | ||
@@ -409,3 +415,8 @@ | ||
var externalDeps = []; | ||
var modules = Object.keys(tree).filter(function(module) { | ||
if (tree[module] === false) | ||
externalDeps.push(module); | ||
return tree[module] && !tree[module].conditional; | ||
@@ -429,4 +440,2 @@ }); | ||
// determine if the SFX bundle has any external dependencies it relies on | ||
var externalDeps = []; | ||
var externalDepIds = []; | ||
var globalDeps = []; | ||
@@ -443,12 +452,3 @@ modules.forEach(function(name) { | ||
var alias = getAlias(loader, key); | ||
if (compileOpts.format == 'global') { | ||
if (!compileOpts.globalDeps[alias]) | ||
throw new TypeError('Global SFX bundle dependency "' + alias + '" (' + key + ') must be configured to an environment global via the globalDeps option.'); | ||
globalDeps.push(compileOpts.globalDeps[alias]); | ||
} | ||
externalDeps.push(alias); | ||
externalDepIds.push(compileOpts.encodeNames ? getEncoding(key, cache.encodings) : key); | ||
externalDeps.push(getAlias(loader, key)); | ||
} | ||
@@ -458,2 +458,15 @@ }); | ||
var externalDepIds = externalDeps.map(function(dep) { | ||
if (compileOpts.format == 'global') { | ||
if (!compileOpts.globalDeps[dep]) | ||
throw new TypeError('Global SFX bundle dependency "' + dep + '" must be configured to an environment global via the globalDeps option.'); | ||
globalDeps.push(compileOpts.globalDeps[dep]); | ||
} | ||
if (compileOpts.encodeNames) | ||
return getEncoding(dep, cache.encodings); | ||
else | ||
return dep; | ||
}); | ||
// next wrap with the core code | ||
@@ -460,0 +473,0 @@ return asp(fs.readFile)(path.resolve(__dirname, '../templates/sfx-core.js')) |
@@ -7,2 +7,4 @@ var traceur = require('traceur'); | ||
var Promise = require('bluebird'); | ||
function DeferredImportsTransformer(map) { | ||
@@ -9,0 +11,0 @@ this.imports = []; |
var path = require('path'); | ||
var mkdirp = require('mkdirp'); | ||
var fs = require('fs'); | ||
var Promise = require('rsvp').Promise; | ||
var asp = require('rsvp').denodeify; | ||
var Promise = require('bluebird'); | ||
var asp = require('bluebird').promisify; | ||
@@ -7,0 +7,0 @@ var fromFileURL = require('./utils').fromFileURL; |
@@ -83,9 +83,2 @@ var sourceMap = require('source-map'); | ||
normalized.sources = normalized.sources.map(function(source) { | ||
if (isFileURL(source)) | ||
source = fromFileURL(source); | ||
return path.relative(outPath, path.resolve(basePath, source)).replace(/\\/g, '/'); | ||
}); | ||
if (sourceMapContents) { | ||
@@ -103,3 +96,10 @@ normalized.sourcesContent = normalized.sources.map(function(source) { | ||
normalized.sources = normalized.sources.map(function(source) { | ||
if (isFileURL(source)) | ||
source = fromFileURL(source); | ||
return path.relative(outPath, path.resolve(basePath, source)).replace(/\\/g, '/'); | ||
}); | ||
return JSON.stringify(normalized); | ||
}; |
@@ -5,6 +5,7 @@ var getCanonicalName = require('./utils').getCanonicalName; | ||
var fromFileURL = require('./utils').fromFileURL; | ||
var asp = require('rsvp').denodeify; | ||
var asp = require('bluebird').promisify; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var extend = require('./utils').extend; | ||
var Promise = require('bluebird'); | ||
@@ -356,2 +357,3 @@ module.exports = Trace; | ||
curHook = 'instantiate'; | ||
return loader.instantiate({ name: normalized, metadata: load.metadata, address: address, source: source }); | ||
@@ -366,3 +368,3 @@ }) | ||
// es modules currently translate to get the source, so we need to revert for re-compilation | ||
// es modules currently translate to get the dependencies, so we need to revert for re-compilation | ||
// this will go away with transpilers as plugins | ||
@@ -383,6 +385,8 @@ if (load.metadata.format == 'esm') | ||
var msg = (curHook ? ('Error on ' + curHook + ' for ') : 'Error tracing ') + canonical + ' at ' + normalized; | ||
parentStack.forEach(function(parent) { | ||
msg += '\n\tLoading ' + parent; | ||
}); | ||
if (parentStack) | ||
parentStack.forEach(function(parent) { | ||
msg += '\n\tLoading ' + parent; | ||
}); | ||
// rethrow loader hook errors with the hook information | ||
@@ -389,0 +393,0 @@ var newErr; |
{ | ||
"name": "systemjs-builder", | ||
"version": "0.14.11", | ||
"version": "0.14.12", | ||
"description": "SystemJS Build Tool", | ||
"main": "index.js", | ||
"dependencies": { | ||
"bluebird": "^3.0.6", | ||
"es6-template-strings": "^2.0.0", | ||
"glob": "^5.0.14", | ||
"glob": "^6.0.1", | ||
"mkdirp": "^0.5.1", | ||
"rsvp": "^3.0.20", | ||
"source-map": "^0.4.4", | ||
"systemjs": "0.19.6", | ||
"traceur": "0.0.92", | ||
"uglify-js": "^2.4.23" | ||
"source-map": "^0.5.3", | ||
"systemjs": "0.19.7", | ||
"traceur": "0.0.93", | ||
"uglify-js": "^2.6.1" | ||
}, | ||
@@ -16,0 +16,0 @@ "devDependencies": { |
@@ -118,6 +118,6 @@ SystemJS Build Tool [![Build Status][travis-image]][travis-url] | ||
This is handled via the `sfxFormat` option: | ||
This is handled via the `format` (previously `sfxFormat`) option: | ||
```javascript | ||
builder.buildStatic('myModule.js', 'outfile.js', { sfxFormat: 'cjs' }); | ||
builder.buildStatic('myModule.js', 'outfile.js', { format: 'cjs' }); | ||
``` | ||
@@ -124,0 +124,0 @@ |
@@ -19,3 +19,3 @@ (function(__global) { | ||
// bare minimum ignores for IE8 | ||
var ignoredGlobalProps = ['_g', 'sessionStorage', 'localStorage', 'clipboardData', 'frames', 'external', 'mozAnimationStartTime', 'webkitStorageInfo', 'webkitIndexedDB']; | ||
var ignoredGlobalProps = ['_g', 'sessionStorage', 'localStorage', 'clipboardData', 'frames', 'frameElement', 'external', 'mozAnimationStartTime', 'webkitStorageInfo', 'webkitIndexedDB']; | ||
@@ -64,3 +64,3 @@ var globalSnapshot; | ||
for (var g in globals) { | ||
oldGlobals[g] = globals[g]; | ||
oldGlobals[g] = __global[g]; | ||
__global[g] = globals[g]; | ||
@@ -67,0 +67,0 @@ } |
@@ -176,3 +176,3 @@ (function(global) { | ||
return value; | ||
}); | ||
}, entry.name); | ||
@@ -179,0 +179,0 @@ module.setters = declaration.setters; |
@@ -39,4 +39,4 @@ var Builder = require('../index'); | ||
assert.deepEqual(Object.keys(tree).sort(), [ | ||
'Buffer.js', 'amd.js', 'babel', 'cjs-globals.js', 'cjs.js', 'component.jsx!jsx.js', 'first.js', | ||
'global-inner.js', 'global-outer.js', 'global.js', 'jquery-cdn', 'jquery.js', 'jsx.js', 'plugin.js', 'runtime.js', | ||
'Buffer.js', 'amd.js', 'babel', 'cjs-globals.js', 'cjs.js', 'component.jsx!jsx.js', 'file.json', 'first.js', | ||
'global-inner.js', 'global-outer.js', 'global.js', 'jquery-cdn', 'jquery.js', 'json-plugin.js', 'jsx.js', 'plugin.js', 'runtime.js', | ||
'second.js', 'some.js!plugin.js', 'text-plugin.js', 'text.txt!text-plugin.js', 'third.js', 'umd.js']); | ||
@@ -43,0 +43,0 @@ }) |
@@ -22,4 +22,7 @@ System.config({ | ||
} | ||
}, | ||
'*.json': { | ||
loader: 'json-plugin.js' | ||
} | ||
} | ||
}); |
@@ -8,2 +8,2 @@ | ||
define({ amd: '2' }); | ||
define(window.m = { amd: '2' }); |
@@ -6,4 +6,7 @@ import 'jquery-cdn'; | ||
import './component.jsx!./jsx.js'; | ||
import {some} from './file.json'; | ||
export var j = some; | ||
export var p = 5; | ||
q; |
@@ -7,4 +7,5 @@ System.register(['./second.js'], function($__export) { | ||
$__export('pi', 'π'); | ||
$__export('name', __moduleName); | ||
} | ||
}; | ||
}); |
@@ -1,2 +0,2 @@ | ||
global.Promise = require('rsvp').Promise; | ||
global.Promise = require('bluebird'); | ||
global.assert = require('chai').assert; |
var Builder = require('../index'); | ||
var inline = require('../lib/output').inlineSourceMap; | ||
var fs = require('fs'); | ||
var Promise = require('rsvp').Promise; | ||
var spawn = require('child_process').spawn; | ||
@@ -156,10 +155,22 @@ if (process.argv[2] == 'typescript') | ||
builder.reset(); | ||
builder.config({transpiler: transpiler }); | ||
builder.config({ transpiler: transpiler }); | ||
builder.config({ | ||
map: { | ||
'jquery-cdn': '@empty', | ||
'toamd1': 'amd-1.js' | ||
}, | ||
meta: { | ||
'jquery-cdn': { | ||
build: false | ||
} | ||
} | ||
}); | ||
return builder.buildStatic('toamd1', 'test/output/sfx.js', { runtime: true, minify: minify, globalDefs: { DEBUG: false }, globalName: 'amd1' }) | ||
return builder.buildStatic('toamd1', 'test/output/sfx.js', { | ||
runtime: true, | ||
minify: minify, | ||
globalDefs: { DEBUG: false }, | ||
globalName: 'amd1', | ||
globalDeps: { | ||
'jquery-cdn': '$' | ||
} | ||
}) | ||
.then(function() { | ||
@@ -166,0 +177,0 @@ return testPhantom('test/test-sfx.html'); |
var Builder = require('../index'); | ||
var fs = require('fs'); | ||
var Promise = require('rsvp').Promise; | ||
suite('Test builder.loadConfig', function() { | ||
@@ -25,4 +23,4 @@ | ||
var configFile2 = 'test/output/builder2Config.js'; | ||
fs.writeFileSync(configFile1, 'System.config({map: {m1: "./m1.js"}});'); | ||
fs.writeFileSync(configFile2, 'System.config({map: {m2: "./m2.js"}});'); | ||
fs.writeFileSync(configFile1, 'System.config({baseURL: "base1", map: {m1: "./m1.js"}, packages: {p1: {main: "index1.js"}}});'); | ||
fs.writeFileSync(configFile2, 'System.config({baseURL: "base2", map: {m2: "./m2.js"}, packages: {p2: {main: "index2.js"}}});'); | ||
@@ -37,10 +35,41 @@ var builder1 = new Builder(); | ||
Promise.all([p1, p2]).then(function() { | ||
assert.match(builder1.loader.baseURL, /base1\/$/, 'builder1 baseURL'); | ||
assert.match(builder2.loader.baseURL, /base2\/$/, 'builder2 baseURL'); | ||
assert.equal(builder1.loader.map['m1'], './m1.js', 'builder1.loader map was loaded from config'); | ||
assert.equal(builder1.loader.map['m2'], undefined, 'map for builder1.loader only'); | ||
assert.equal(builder2.loader.map['m2'], './m2.js', 'builder2.loader map was loaded from config'); | ||
}).then(done, done); | ||
assert.equal(builder2.loader.map['m1'], undefined, 'map for builder2.loader only'); | ||
builder1.loader.normalize('p1').then(function(p1) { | ||
assert.match(p1, /base1\/p1\/index1\.js$/, 'builder1 package p1'); | ||
assert.equal(builder1.loader.packages['p2'], undefined, 'builder1 package p2'); | ||
assert.equal(builder2.loader.packages['p1'], undefined, 'builder2 package p1'); | ||
builder2.loader.normalize('p2').then(function(p2) { | ||
assert.match(p2, /base2\/p2\/index2\.js$/, 'builder2 package p2'); | ||
}).then(done, done); | ||
}); | ||
}); | ||
}); | ||
}); | ||
test('builder.loadConfig does not affect global variables', function(done) { | ||
global._tmp_1 = '1'; | ||
var configFile = 'test/output/builderConfig.js'; | ||
var builder = new Builder(); | ||
fs.writeFileSync(configFile, '_tmp_1=2; _tmp_2=3; global._tmp_1=4;'); | ||
builder.loadConfig(configFile).then(function() { | ||
assert.equal(global._tmp_1, '1', 'previously defined global variable is not affected'); | ||
assert.equal(global._tmp_2, undefined, 'new global variables are not defined'); | ||
delete global._tmp_1; | ||
}).then(done, done); | ||
}); | ||
}); |
var expect = require('unexpected'); | ||
var getTreeModulesPostOrder = require('../lib/compile').getTreeModulesReversePreOrder; | ||
var getTreeModulesPostOrder = require('../lib/compile').getTreeModulesPostOrder; | ||
@@ -31,3 +31,3 @@ suite('Test post order traversal', function() { | ||
return expect(getTreeModulesPostOrder(tree).modules, 'to satisfy', ['b', 'a']); | ||
return expect(getTreeModulesPostOrder(tree).modules, 'to satisfy', ['a', 'b']); | ||
}); | ||
@@ -83,3 +83,3 @@ | ||
return expect(getTreeModulesPostOrder(tree).modules, 'to satisfy', ['d', 'c', 'b', 'a']); | ||
return expect(getTreeModulesPostOrder(tree).modules, 'to satisfy', ['c', 'b', 'd', 'a']); | ||
}); | ||
@@ -115,36 +115,5 @@ | ||
return expect(getTreeModulesPostOrder(tree).modules, 'to satisfy', ['d', 'c', 'b', 'a']); | ||
return expect(getTreeModulesPostOrder(tree).modules, 'to satisfy', ['c', 'b', 'a', 'd']); | ||
}); | ||
test('should override alphabetical graph entry order with entryPoints array', function() { | ||
var tree = { | ||
'a': { | ||
name: 'a', | ||
deps: ['b'], | ||
depMap: { | ||
'b': 'b' | ||
} | ||
}, | ||
'b': { | ||
name: 'b', | ||
deps: ['c'], | ||
depMap: { | ||
'c': 'c' | ||
} | ||
}, | ||
'c': { | ||
name: 'c', | ||
deps: [], | ||
depMap: {} | ||
}, | ||
'd': { | ||
name: 'd', | ||
deps: [], | ||
depMap: {} | ||
} | ||
}; | ||
return expect(getTreeModulesPostOrder(tree, ['d', 'a']).modules, 'to satisfy', ['d', 'c', 'b', 'a']); | ||
}); | ||
test('should include entry points not present in given entryPoints order, in alphabetical order', function() { | ||
@@ -183,4 +152,4 @@ var tree = { | ||
return expect(getTreeModulesPostOrder(tree, ['d']).modules, 'to satisfy', ['e', 'd', 'c', 'b', 'a']); | ||
return expect(getTreeModulesPostOrder(tree).modules, 'to satisfy', ['c', 'b', 'a', 'd', 'e']); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
217135
102
4949
2
24
+ Addedbluebird@^3.0.6
+ Addedbluebird@3.7.2(transitive)
+ Addedglob@6.0.4(transitive)
+ Addedsystemjs@0.19.7(transitive)
+ Addedtraceur@0.0.93(transitive)
- Removedrsvp@^3.0.20
- Removedglob@5.0.15(transitive)
- Removedsource-map@0.4.4(transitive)
- Removedsystemjs@0.19.6(transitive)
- Removedtraceur@0.0.92(transitive)
Updatedglob@^6.0.1
Updatedsource-map@^0.5.3
Updatedsystemjs@0.19.7
Updatedtraceur@0.0.93
Updateduglify-js@^2.6.1