Skip to content

Commit

Permalink
Merge pull request #205 from chriseppstein/degenerate-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue authored Aug 28, 2020
2 parents 6a7d00f + 26fd570 commit 7ae4004
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,12 @@ class Dependencies {
*/
static deserialize(dependencyData: Dependencies.SerializedDependencies, customFS: Dependencies.FSFacade, inputEncoding: string): Dependencies {
let dependencies = new Dependencies(customFS, inputEncoding);
if (typeof dependencyData.fsTrees[0].fsRoot === 'string') {
let prevFsTree = dependencyData.fsTrees[0];
if (prevFsTree && typeof prevFsTree.fsRoot === 'string') {
// Ideally the serialized cache would be invalidated when this code changes,
// but just to be safe we handle the situation where old serialized data
// that doesn't work with the current implementation might be present.
dependencies.seal();
return dependencies;
}
let files = Object.keys(dependencyData.dependencies);
Expand Down
22 changes: 22 additions & 0 deletions test/filter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,9 @@ describe('Filter', function() {
it('calls processString if work is needed', async function() {
input = await createTempDir();
input.write({
'dep-tracking-0': {
'unrelated-file.js': `console.log('pay me no mind.')\n`
},
'dep-tracking-1': {
'has-inlines.js': `// << ./local.js\n// << ${input.path('external-deps/external.js')}\n`,
'local.js': `console.log('local');\n`,
Expand All @@ -1436,6 +1439,25 @@ describe('Filter', function() {
}
});

// First we make sure the dependency tracking doesn't cause errors with
// no dependencies.
subject = new Inliner(path.join(input.path(), 'dep-tracking-0'), {
persist: true
});
rimraf(subject.processor.processor._cache.root);
rimraf(subject.processor.processor._syncCache.root);
output = createBuilder(subject);
await output.build();

// Next we make sure the dependency tracking doesn't cause errors with
// no dependencies in the previous build.
subject = new Inliner(path.join(input.path(), 'dep-tracking-0'), {
persist: true
});
output = createBuilder(subject);
await output.build();

// Now we test if there's dependencies.
subject = new Inliner(path.join(input.path(), 'dep-tracking-1'), {
persist: true
});
Expand Down

0 comments on commit 7ae4004

Please sign in to comment.