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

add simple tracing API #141

merged 1 commit into from
May 14, 2014

Conversation

guybedford
Copy link
Member

The API works as:

  System.trace = true;
  System.execute = false; // optionally disable execution. Still executes wrappers.

  System.import('some/module').then(function() {
    // System.loads['some/module'] is the load record
    // System.loads['some/module'].dependencies == [{ name, value from unnormalized to normalized dependencies }]
    // System.loads['some/module'].metadata is metadata object
    // System.loads['some/module'].address is the resolved address
    // System.loads['some/module'].source is the translated source string
  });

The information above provides everything a build tool would need - translation, resolution, dependencies.

If this seems obscure, let me know - happy to consider other APIs too.

@guybedford
Copy link
Member Author

/cc @justinbmeyer - is this very different to what you were doing?

@guybedford
Copy link
Member Author

I've just updated and simplified this PR from the previous suggestions.

guybedford added a commit that referenced this pull request May 14, 2014
@guybedford guybedford merged commit 95420b7 into master May 14, 2014
@briandipalma
Copy link

This should just output to the console?

I'm not seeing it in my simple tests in this webpage.

@guybedford
Copy link
Member Author

It stores the trace at System.loads.

So you can read off the meta-information.

@briandipalma
Copy link

@guybedford Excellent thank you, very helpful debug information.

@briandipalma
Copy link

It seems like when there is a loading error System.loads isn't populated, it's left undefined, is that as expected?

@guybedford
Copy link
Member Author

Yes this is correct. It is actually up to the trace implementation to
ensure the fetch function doesn't throw errors during tracing for example.
The goal would be for it to be completely resilient though certainly.

Perhaps try something like -

var systemFetch = System.fetch;
System.fetch = function(load) {
return Promise.resolve(systemFetch(load))
.catch(function(err) {
console.log(err); //just note the err
load.metadata.build = false; // tell trace tree consumer to ignore
this module
return ''; // becomes empty module
});
}

So it doesn't escalate the fetch error. Something along those lines...

If the error is in instantiate, a similar idea can apply I expect.

On Tuesday, May 27, 2014, Brian Di Palma notifications@github.com wrote:

It seems like when there is a loading error System.loads isn't populated,
it's left undefined, is that as expected?

Reply to this email directly or view it on GitHubhttps://github.com//pull/141#issuecomment-44266021
.

@guybedford guybedford deleted the trace branch July 29, 2014 22:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants