Skip to content

Commit

Permalink
handle metadata.deps for esm via injection for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed May 19, 2016
1 parent 114e638 commit 273432b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/esm.js
Expand Up @@ -20,6 +20,13 @@

load.metadata.format = 'esm';

if (load.metadata.deps) {
var depInject = '';
for (var i = 0; i < load.metadata.deps.length; i++)
depInject += 'import "' + load.metadata.deps[i] + '"; ';
load.source = depInject + source;
}

if (loader.transpiler === false) {
// we accept translation to esm for builds though to enable eg rollup optimizations
if (loader.builder)
Expand Down
6 changes: 4 additions & 2 deletions lib/register.js
Expand Up @@ -285,8 +285,7 @@ function createEntry() {
var importerModule = module.importers[i];
if (!importerModule.locked) {
var importerIndex = indexOf.call(importerModule.dependencies, module);
if (importerModule.setters[importerIndex])
importerModule.setters[importerIndex](exports);
importerModule.setters[importerIndex](exports);
}
}

Expand Down Expand Up @@ -515,6 +514,9 @@ function createEntry() {
// first we check if this module has already been defined in the registry
if (loader.defined[load.name]) {
entry = loader.defined[load.name];
// don't support deps for ES modules
if (!entry.declarative)
entry.deps = entry.deps.concat(load.metadata.deps);
entry.deps = entry.deps.concat(load.metadata.deps);
}

Expand Down

0 comments on commit 273432b

Please sign in to comment.