Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

add simple tracing API #141

Merged
merged 1 commit into from
May 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions dist/es6-module-loader-sans-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ function logloads(loads) {
// 15.2.4.6 ProcessLoadDependencies
load.dependencies = [];
load.depsList = depsList;

var loadPromises = [];
for (var i = 0, l = depsList.length; i < l; i++) (function(request) {
loadPromises.push(
Expand Down Expand Up @@ -526,6 +527,26 @@ function logloads(loads) {
return;

var startingLoad = linkSet.loads[0];

// non-executing link variation for loader tracing
// on the server
if (linkSet.loader.loaderObj.execute === false) {
var loads = [].concat(linkSet.loads);
for (var i = 0; i < loads.length; i++) {
var load = loads[i];
load.module = load.kind == 'dynamic' ? {
module: Module({})
} : {
name: load.name,
module: Module({}),
evaluated: true
};
load.status = 'linked';
finishLoad(linkSet.loader, load);
}
return linkSet.resolve(startingLoad);
}

try {
link(linkSet);
}
Expand Down Expand Up @@ -557,6 +578,19 @@ function logloads(loads) {

// 15.2.5.2.5
function finishLoad(loader, load) {
// add to global trace if tracing
if (loader.loaderObj.trace) {
if (!loader.loaderObj.loads)
loader.loaderObj.loads = {};
loader.loaderObj.loads[load.name] = {
name: load.name,
dependencies: load.dependencies,
address: load.address,
metadata: load.metadata,
source: load.source,
kind: load.kind
};
}
// if not anonymous, add to the module table
if (load.name) {
console.assert(!loader.modules[load.name], 'load not in module table');
Expand Down
2 changes: 1 addition & 1 deletion dist/es6-module-loader-sans-promises.min.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions dist/es6-module-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ function logloads(loads) {
// 15.2.4.6 ProcessLoadDependencies
load.dependencies = [];
load.depsList = depsList;

var loadPromises = [];
for (var i = 0, l = depsList.length; i < l; i++) (function(request) {
loadPromises.push(
Expand Down Expand Up @@ -1210,6 +1211,26 @@ function logloads(loads) {
return;

var startingLoad = linkSet.loads[0];

// non-executing link variation for loader tracing
// on the server
if (linkSet.loader.loaderObj.execute === false) {
var loads = [].concat(linkSet.loads);
for (var i = 0; i < loads.length; i++) {
var load = loads[i];
load.module = load.kind == 'dynamic' ? {
module: Module({})
} : {
name: load.name,
module: Module({}),
evaluated: true
};
load.status = 'linked';
finishLoad(linkSet.loader, load);
}
return linkSet.resolve(startingLoad);
}

try {
link(linkSet);
}
Expand Down Expand Up @@ -1241,6 +1262,19 @@ function logloads(loads) {

// 15.2.5.2.5
function finishLoad(loader, load) {
// add to global trace if tracing
if (loader.loaderObj.trace) {
if (!loader.loaderObj.loads)
loader.loaderObj.loads = {};
loader.loaderObj.loads[load.name] = {
name: load.name,
dependencies: load.dependencies,
address: load.address,
metadata: load.metadata,
source: load.source,
kind: load.kind
};
}
// if not anonymous, add to the module table
if (load.name) {
console.assert(!loader.modules[load.name], 'load not in module table');
Expand Down
Loading