diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09b8b02 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.DS_Store +jspm_packages/* diff --git a/config.js b/config.js new file mode 100644 index 0000000..ca5d332 --- /dev/null +++ b/config.js @@ -0,0 +1,31 @@ +System.config({ + baseURL: "/", + defaultJSExtensions: true, + transpiler: "babel", + babelOptions: { + "optional": [ + "runtime", + "optimisation.modules.system" + ] + }, + paths: { + "github:*": "jspm_packages/github/*", + "npm:*": "jspm_packages/npm/*" + }, + + map: { + "babel": "npm:babel-core@5.8.22", + "babel-runtime": "npm:babel-runtime@5.8.20", + "core-js": "npm:core-js@1.0.1", + "github:jspm/nodelibs-process@0.1.1": { + "process": "npm:process@0.10.1" + }, + "npm:babel-runtime@5.8.20": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:core-js@1.0.1": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.1" + } + } +}); diff --git a/index.js b/index.js new file mode 100644 index 0000000..fd8c2d3 --- /dev/null +++ b/index.js @@ -0,0 +1,60 @@ +var imports = {}; +var systemNormalize = System.normalize; +System.normalize = function (path, importFrom) { + var promise = systemNormalize.apply(this, arguments); + promise.then(function (normalizedPath) { + imports[normalizedPath] = { + importPath: path, + path: normalizedPath, + from: importFrom, + deps: [] + }; + }); + return promise; +}; +var systemInstantiate = System.instantiate; +System.instantiate = function (load) { + return systemInstantiate.apply(this, arguments) + .then(function (result) { + var importData = imports[load.name]; + importData.metadata = load.metadata; + var fromData = imports[importData.from]; + if (fromData) { + fromData.deps.push(importData); + } + return result; + }); +}; + +export function logImport (importData) { + console.groupCollapsed(importData.importPath); + console.log('path: ', importData.path); + var metadata = importData.metadata; + for (let metaKey in metadata) { + if (metaKey === 'deps') continue; + var metaValue = metadata[metaKey]; + if (metaValue !== undefined) { + console.log(`${metaKey}: ${metaValue}`); + } + } + console.group(' deps: ', importData.deps.length); + for (let depData of importData.deps) { + logImport(depData); + } + console.groupEnd(); + console.groupEnd(); +} +export function logImports () { + console.group('Imports'); + for (let index in imports) { + var importData = imports[index]; + // root imports? + if (importData.from === undefined) { + logImport(importData); + } + } + console.groupEnd(); +} +export function getImports () { + return imports; +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..dca3897 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "systemjs-debugger", + "version": "0.0.1", + "description": "SystemJS debugger", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/peteruithoven/systemjs-debugger.git" + }, + "keywords": [ + "systemjs", + "jspm" + ], + "author": "Peter Uithoven", + "license": "MIT", + "jspm": { + "directories": {}, + "devDependencies": { + "babel": "npm:babel-core@^5.8.21", + "babel-runtime": "npm:babel-runtime@^5.8.20", + "core-js": "npm:core-js@^1.0.0" + } + } +}