-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2904 from parcel-bundler/wbinnssmith/no-duplicate…
…-connectedfiles Make connectedFiles and dependencies Maps
- Loading branch information
Showing
9 changed files
with
155 additions
and
65 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
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,53 @@ | ||
// @flow strict-local | ||
|
||
import assert from 'assert'; | ||
import Asset from '../src/Asset'; | ||
import Environment from '../src/Environment'; | ||
|
||
describe('Asset', () => { | ||
it('only includes connected files once per filePath', () => { | ||
let asset = new Asset({ | ||
filePath: '/foo/asset.js', | ||
env: new Environment(), | ||
type: 'js' | ||
}); | ||
asset.addConnectedFile({filePath: '/foo/file', hash: 'abc'}); | ||
asset.addConnectedFile({filePath: '/foo/file', hash: 'bcd'}); | ||
assert.deepEqual(asset.getConnectedFiles(), [ | ||
{ | ||
filePath: '/foo/file', | ||
hash: 'bcd' | ||
} | ||
]); | ||
}); | ||
|
||
it('only includes dependencies once per id', () => { | ||
let asset = new Asset({ | ||
filePath: '/foo/asset.js', | ||
env: new Environment(), | ||
type: 'js' | ||
}); | ||
|
||
asset.addDependency({moduleSpecifier: './foo'}); | ||
asset.addDependency({moduleSpecifier: './foo'}); | ||
let dependencies = asset.getDependencies(); | ||
assert(dependencies.length === 1); | ||
assert(dependencies[0].moduleSpecifier === './foo'); | ||
}); | ||
|
||
it('includes different dependencies if their id differs', () => { | ||
let asset = new Asset({ | ||
filePath: '/foo/asset.js', | ||
env: new Environment(), | ||
type: 'js' | ||
}); | ||
|
||
asset.addDependency({moduleSpecifier: './foo'}); | ||
asset.addDependency({ | ||
moduleSpecifier: './foo', | ||
env: {context: 'web-worker', engines: {}} | ||
}); | ||
let dependencies = asset.getDependencies(); | ||
assert(dependencies.length === 2); | ||
}); | ||
}); |
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.