Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
fix package configuration cache handling (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Mar 12, 2016
1 parent 718ed48 commit 8ced74a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function compileTree(loader, tree, traceOpts, compileOpts, outputOpts, cache) {
var entryPoints = inputEntryPoints || [];

ordered.entryPoints.forEach(function(entryPoint) {
if (entryPoints.indexOf(entryPoint == -1))
if (entryPoints.indexOf(entryPoint) == -1)
entryPoints.push(entryPoint);
});

Expand Down
25 changes: 17 additions & 8 deletions lib/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ function isLoadFresh(load, loader, loads) {
if (load.conditional)
return false;

// stat to check freshness
if (load.plugin) {
var plugin = loads[load.plugin];
if (!isLoadFresh(plugin, loader, loads))
return false;
}

// stat to check freshness
try {
var timestamp = fs.statSync(path.resolve(fromFileURL(loader.baseURL), load.path)).mtime.getTime();
}
Expand Down Expand Up @@ -121,14 +122,14 @@ Trace.prototype.getLoadRecord = function(canonical, excludeURLs, parentStack) {

return this.tracing[canonical] = Promise.resolve(loader.decanonicalize(canonical))
.then(function(normalized) {

// modules already set in the registry are system modules
if (loader.has(normalized))
return false;

// package conditional fallback normalization
if (!isPackageConditional)
normalized = normalized.replace('/#:', '/');

// -- conditional load record creation: sourceless intermediate load record --

// boolean conditional
Expand All @@ -148,7 +149,6 @@ Trace.prototype.getLoadRecord = function(canonical, excludeURLs, parentStack) {
}

// package environment conditional
// NB handle subpaths as tracked in https://github.com/systemjs/builder/issues/440
var pkgEnvIndex = canonical.indexOf('/#:');
if (pkgEnvIndex != -1) {
// NB handle a package plugin load here too
Expand All @@ -160,8 +160,6 @@ Trace.prototype.getLoadRecord = function(canonical, excludeURLs, parentStack) {

var normalizedPkgName = loader.decanonicalize(pkgName);

var pkg = loader.packages[normalizedPkgName];

// record package config paths
var loadPackageConfig;
var packageConfigPath = getPackageConfigPath(loader.packageConfigPaths, normalizedPkgName);
Expand Down Expand Up @@ -213,11 +211,22 @@ Trace.prototype.getLoadRecord = function(canonical, excludeURLs, parentStack) {
}
}

var envMap = pkg.map[subPath];
var pkg
var envMap;
var metadata = {};

// resolve the fallback
return toPackagePath(subPath)
// ensure we have loaded any package config first
// NB this does not properly deal with package config file invalidation
// we should handle some kind of invalidation process where a package config file change
// must invalidate all load records as we can't know the scope of the normalization changes
return loader.normalize(normalizedPkgName)
.then(function() {
pkg = loader.packages[normalizedPkgName];
envMap = pkg.map[subPath];

// resolve the fallback
return toPackagePath(subPath);
})
.then(function(resolvedPath) {
// if the fallback is itself a conditional then use that directly
if (resolvedPath.match(/\#[\:\?\{]/))
Expand Down

0 comments on commit 8ced74a

Please sign in to comment.