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

Commit 933db64

Browse files
committed
document trace API
1 parent 9232f15 commit 933db64

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,43 @@ Running the application:
246246
NodeJS test
247247
```
248248

249+
### Tracing API
250+
251+
This is not in the specification, but is provided since it is such a natural extension of loading and not much code at all.
252+
253+
Enable tracing and start importing modules:
254+
255+
```javascript
256+
loader.trace = true;
257+
loader.execute = true; // optional, disables execution of module bodies
258+
259+
loader.import('some/module').then(function() {
260+
/*
261+
Now we have:
262+
263+
loader.loads['some/module'] == {
264+
name: 'some/module',
265+
deps: ['./unnormalized', 'deps'],
266+
depMap: {
267+
'./unnormalized': 'normalized',
268+
'deps': 'deps'
269+
},
270+
address: '/resolvedURL',
271+
metadata: { metadata object from load },
272+
source: 'translated source code string',
273+
kind: 'dynamic' (instantiated) or 'declarative' (ES6 module pipeline)
274+
}
275+
276+
With the dependency load records
277+
loader.loads['normalized']
278+
loader.loads['deps']
279+
also set.
280+
*/
281+
});
282+
```
283+
284+
Then start importing modules
285+
249286
### Extending the Loader
250287

251288
The loader in its default state provides only ES6 loading.

0 commit comments

Comments
 (0)