Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve circular dependency execution order
- Loading branch information
1 parent
51e727c
commit 7d42c4d
Showing
137 changed files
with
403 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Chunk from '../Chunk'; | ||
import ExternalModule from '../ExternalModule'; | ||
import Module from '../Module'; | ||
|
||
export function getStaticDependencies( | ||
chunk: Chunk, | ||
orderedModules: Module[], | ||
chunkByModule: Map<Module, Chunk> | ||
): Set<Chunk | ExternalModule> { | ||
const staticDependencyBlocks: (Chunk | ExternalModule)[][] = []; | ||
const handledDependencies = new Set<Module>(); | ||
for (let modulePos = orderedModules.length - 1; modulePos >= 0; modulePos--) { | ||
const module = orderedModules[modulePos]; | ||
if (!handledDependencies.has(module)) { | ||
const staticDependencies: (Chunk | ExternalModule)[] = []; | ||
addStaticDependencies(module, staticDependencies, handledDependencies, chunk, chunkByModule); | ||
staticDependencyBlocks.unshift(staticDependencies); | ||
} | ||
} | ||
const dependencies = new Set<Chunk | ExternalModule>(); | ||
for (const block of staticDependencyBlocks) { | ||
for (const dependency of block) { | ||
dependencies.add(dependency); | ||
} | ||
} | ||
return dependencies; | ||
} | ||
|
||
function addStaticDependencies( | ||
module: Module, | ||
staticDependencies: (Chunk | ExternalModule)[], | ||
handledModules: Set<Module>, | ||
chunk: Chunk, | ||
chunkByModule: Map<Module, Chunk> | ||
): void { | ||
const dependencies = module.getDependenciesToBeIncluded(); | ||
for (const dependency of dependencies) { | ||
if (dependency instanceof ExternalModule) { | ||
staticDependencies.push(dependency); | ||
continue; | ||
} | ||
const dependencyChunk = chunkByModule.get(dependency)!; | ||
if (dependencyChunk !== chunk) { | ||
staticDependencies.push(dependencyChunk); | ||
continue; | ||
} | ||
if (!handledModules.has(dependency)) { | ||
handledModules.add(dependency); | ||
addStaticDependencies(dependency, staticDependencies, handledModules, chunk, chunkByModule); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
'use strict'; | ||
|
||
require('./generated-dep1.js'); | ||
var shared2 = require('./generated-shared2.js'); | ||
require('./generated-dep1.js'); | ||
require('./generated-dep2.js'); | ||
|
||
console.log(shared2.x + shared2.y); |
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
require('./generated-dep1.js'); | ||
require('./generated-shared2.js'); | ||
require('./generated-dep1.js'); | ||
require('./generated-dep2.js'); | ||
|
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import './generated-dep1.js'; | ||
import { x, y } from './generated-shared2.js'; | ||
import './generated-dep1.js'; | ||
import './generated-dep2.js'; | ||
|
||
console.log(x + y); |
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import './generated-dep1.js'; | ||
import './generated-shared2.js'; | ||
import './generated-dep1.js'; | ||
import './generated-dep2.js'; |
6 changes: 3 additions & 3 deletions
6
test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-execution-order/_expected/cjs/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
require('./generated-dep11.js'); | ||
require('./generated-dep111.js'); | ||
require('./generated-dep112.js'); | ||
require('./generated-dep11.js'); | ||
|
4 changes: 2 additions & 2 deletions
4
test/chunking-form/samples/chunk-execution-order/_expected/es/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-execution-order/_expected/es/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import './generated-dep11.js'; | ||
import './generated-dep111.js'; | ||
import './generated-dep112.js'; | ||
import './generated-dep11.js'; |
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-execution-order/_expected/system/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunk-execution-order/_expected/system/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import './dep111'; | ||
import './dep111.js'; | ||
export { x } from './dep112.js'; | ||
console.log('11'); |
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunking-reexport/_expected/amd/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunking-reexport/_expected/amd/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunking-reexport/_expected/es/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { asdf as dep } from 'external'; | ||
import './generated-dep.js'; | ||
export { asdf as dep } from 'external'; |
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunking-reexport/_expected/es/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { asdf as dep } from 'external'; | ||
import './generated-dep.js'; | ||
export { asdf as dep } from 'external'; |
6 changes: 3 additions & 3 deletions
6
test/chunking-form/samples/chunking-reexport/_expected/system/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
test/chunking-form/samples/chunking-reexport/_expected/system/main2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/chunking-star-external/_expected/amd/main1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.