diff --git a/.gitignore b/.gitignore index b4f2a6a6..418930f2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ node_modules .DS_Store dist bower_components +code.asm +hydrogen.cfg diff --git a/irhydra/load.js b/irhydra/load.js new file mode 100644 index 00000000..95f33782 --- /dev/null +++ b/irhydra/load.js @@ -0,0 +1,16 @@ +var System = require('../'); + +function load () { + var loader = new System.constructor(); + return loader.import('./test/tests/register-circular1.js'); +} + +var i = 100; + +function again () { + i--; + if (i) + return load().then(again); +} + +again(); diff --git a/package.json b/package.json index 36eeffed..78dc2023 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "test": "npm run test:babel && npm run test:traceur && npm run test:typescript", "test:traceur": "mocha test/test-traceur.js -u tdd --reporter dot", "test:babel": "mocha test/test-babel.js -u tdd --reporter dot", - "test:typescript": "mocha test/test-typescript.js -u tdd --reporter dot" + "test:typescript": "mocha test/test-typescript.js -u tdd --reporter dot", + "irhydra": "node --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces --redirect-code-traces-to=code.asm --print-opt-code --trace_hydrogen_file=hydrogen.cfg irhydra/load.js" } } diff --git a/src/common.js b/src/common.js index 1436daf2..1d116452 100644 --- a/src/common.js +++ b/src/common.js @@ -188,18 +188,6 @@ export function readMemberExpression (p, value) { return value; } -function checkMap (p) { - var name = this.name; - // can add ':' here if we want paths to match the behaviour of map - if (name.substr(0, p.length) === p && (name.length === p.length || name[p.length] === '/' || p[p.length - 1] === '/' || p[p.length - 1] === ':')) { - var curLen = p.split('/').length; - if (curLen > this.len) { - this.match = p; - this.len = curLen; - } - } -} - export function normalizePaths (config) { for (var p in config.paths) { if (!Object.hasOwnProperty.call(config.paths, p)) @@ -214,9 +202,7 @@ export function normalizePaths (config) { } // separate out paths cache as a baseURL lock process -export function applyPaths (config, key) { - var paths = config.paths; - +export function applyPaths (baseURL, paths, key) { var mapMatch = getMapMatch(paths, key); if (mapMatch) { var target = paths[mapMatch] + key.substr(mapMatch.length); @@ -225,17 +211,26 @@ export function applyPaths (config, key) { if (resolved !== undefined) return resolved; - resolved = target; + return baseURL + target; } else if (key.indexOf(':') !== -1) { return key; } else { - resolved = key; + return baseURL + key; } +} - // plain paths map, or plain to begin with -> baseURL - return config.baseURL + resolved; +function checkMap (p) { + var name = this.name; + // can add ':' here if we want paths to match the behaviour of map + if (name.substr(0, p.length) === p && (name.length === p.length || name[p.length] === '/' || p[p.length - 1] === '/' || p[p.length - 1] === ':')) { + var curLen = p.split('/').length; + if (curLen > this.len) { + this.match = p; + this.len = curLen; + } + } } export function getMapMatch (map, name) { diff --git a/src/resolve.js b/src/resolve.js index a39da1c0..394fce65 100644 --- a/src/resolve.js +++ b/src/resolve.js @@ -138,7 +138,7 @@ export function coreResolve (config, key, parentKey, doMap) { if (relativeResolved) { if (!config.pathsLocked) normalizePaths(config); - return applyPaths(config, relativeResolved, true); + return applyPaths(config.baseURL, config.paths, relativeResolved); } // plain keys not starting with './', 'x://' and '/' go through custom resolution @@ -162,7 +162,7 @@ export function coreResolve (config, key, parentKey, doMap) { if (!config.pathsLocked) normalizePaths(config); - return applyPaths(config, key, false); + return applyPaths(config.baseURL, config.paths, key); } function pluginResolve (config, key, parentKey, metadata, parentMetadata) { diff --git a/src/systemjs-production-loader.js b/src/systemjs-production-loader.js index 0e09275b..a8610e00 100644 --- a/src/systemjs-production-loader.js +++ b/src/systemjs-production-loader.js @@ -48,7 +48,8 @@ systemJSPrototype[RESOLVE] = function (key, parentKey) { .then(function (resolved) { // then apply paths // baseURL is fallback - return applyPaths(loader[CONFIG], resolved || key); + var config = loader[CONFIG]; + return applyPaths(config.baseURL, config.paths, resolved || key); }); }; @@ -61,7 +62,8 @@ systemJSPrototype.resolveSync = function (key, parentKey) { resolved = this[PLAIN_RESOLVE_SYNC](key, parentKey); // then apply paths - return applyPaths(this[CONFIG], resolved || key); + var config = this[CONFIG]; + return applyPaths(config.baseURL, config.paths, resolved || key); }; systemJSPrototype[PLAIN_RESOLVE] = systemJSPrototype[PLAIN_RESOLVE_SYNC] = plainResolve; @@ -92,7 +94,7 @@ systemJSPrototype.config = function (cfg) { // object submap else { // normalize parent with URL and paths only - var resolvedParent = resolveIfNotPlain(p, baseURI) || applyPaths(config, p); + var resolvedParent = resolveIfNotPlain(p, baseURI) || applyPaths(config.baseURL, config.paths, p); extend(config.submap[resolvedParent] || (config.submap[resolvedParent] = {}), v); } }