Skip to content

Commit 76f6b19

Browse files
committed
fix($refactor): provide consistent argument order to flush functions
1 parent 6d3b5ed commit 76f6b19

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

__tests__/flushChunks.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ describe('flushChunks() called as pure function', () => {
5656
/** BABEL VS. WEBPACK FLUSHING */
5757

5858
test('flushBabel()', () => {
59-
const files = flushBabel(stats, babelFilePaths, rootDir) /*? */
59+
const files = flushBabel(babelFilePaths, stats, rootDir) /*? */
6060
const allFiles = stats.chunks[0].files.concat(stats.chunks[1].files)
6161
expect(files).toEqual(allFiles)
6262
})
6363

6464
test('flushWebpack()', () => {
65-
const files = flushWebpack(stats, webpackModuleIds) /*? */
65+
const files = flushWebpack(webpackModuleIds, stats) /*? */
6666
const allFiles = stats.chunks[0].files.concat(stats.chunks[1].files)
6767
expect(files).toEqual(allFiles)
6868
})
6969

7070
test('flushBabel() throws with no rootDir argument', () => {
71-
const flush = () => flushBabel(stats, babelFilePaths) /*? */
71+
const flush = () => flushBabel(babelFilePaths, stats) /*? */
7272
expect(flush).toThrow()
7373
})
7474

@@ -94,8 +94,8 @@ test('createFilesByModuleId()', () => {
9494

9595
expect(Object.keys(filesByPath)).toEqual(webpackModuleIds)
9696

97-
expect(filesByPath['qwer']).toEqual(['0.js', '0.no_css.js', '0.css'])
98-
expect(filesByPath['zxcv']).toEqual([]) // test against arrays of undefined
97+
expect(filesByPath.qwer).toEqual(['0.js', '0.no_css.js', '0.css'])
98+
expect(filesByPath.zxcv).toEqual([]) // test against arrays of undefined
9999

100100
expect(filesByPath).toMatchSnapshot()
101101
})

src/flushChunks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ const flushChunks = (
5757
const beforeEntries = opts.before || defaults.before
5858

5959
const files = !isWebpack
60-
? flushBabel(stats, pathsOrIds, opts.rootDir)
61-
: flushWebpack(stats, pathsOrIds)
60+
? flushBabel(pathsOrIds, stats, opts.rootDir)
61+
: flushWebpack(pathsOrIds, stats)
6262

6363
const afterEntries = opts.after || defaults.after
6464

@@ -75,7 +75,7 @@ const flushChunks = (
7575

7676
/** BABEL VS. WEBPACK FLUSHING */
7777

78-
const flushBabel = (stats: Stats, paths: Files, rootDir: ?string): Files => {
78+
const flushBabel = (paths: Files, stats: Stats, rootDir: ?string): Files => {
7979
if (!rootDir) {
8080
throw new Error(
8181
`No \`rootDir\` was provided as an option to \`flushChunks\`.
@@ -94,7 +94,7 @@ const flushBabel = (stats: Stats, paths: Files, rootDir: ?string): Files => {
9494
return concatFilesAtKeys(filesByPath, paths.map(p => normalizePath(p, dir)))
9595
}
9696

97-
const flushWebpack = (stats: Stats, ids: Files): Files => {
97+
const flushWebpack = (ids: Files, stats: Stats): Files => {
9898
filesByModuleId = filesByModuleId && !IS_TEST
9999
? filesByModuleId // cached
100100
: createFilesByModuleId(stats)

0 commit comments

Comments
 (0)