-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use webpack's built-in watching instead of polling
Centralize files watching using webpack's `WatchFileSystem`. The default implementation of `NodeWatchFileSystem` doesn't fill our needs, so we've implemented `InclusiveNodeWatchFileSystem` BREAKING CHANGE: 🧨 Remove issue.scope option and use new watch architecture
- Loading branch information
1 parent
b964d05
commit fb22e47
Showing
49 changed files
with
1,164 additions
and
836 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
module.exports = { | ||
presets: [ | ||
'@babel/preset-env', | ||
[ | ||
'@babel/preset-typescript', | ||
{ | ||
onlyRemoveTypeImports: true, // this is important for proper files watching | ||
}, | ||
], | ||
], | ||
presets: ['@babel/preset-env', ['@babel/preset-typescript']], | ||
}; |
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
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 |
---|---|---|
@@ -1,21 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import webpack from 'webpack'; | ||
import path from 'path'; | ||
import { getWatcher } from './getWatcher'; | ||
import { CompilerWithWatchFileSystem } from '../watch/CompilerWithWatchFileSystem'; | ||
import { InclusiveNodeWatchFileSystem } from '../watch/InclusiveNodeWatchFileSystem'; | ||
|
||
function getChangedFiles(compiler: webpack.Compiler): string[] { | ||
let changedFiles: string[] = []; | ||
const watchFileSystem = (compiler as CompilerWithWatchFileSystem<InclusiveNodeWatchFileSystem>) | ||
.watchFileSystem; | ||
|
||
if ((compiler as any).modifiedFiles) { | ||
// webpack 5+ | ||
changedFiles = Array.from((compiler as any).modifiedFiles); | ||
} else { | ||
const watcher = getWatcher(compiler); | ||
// webpack 4 | ||
changedFiles = Object.keys((watcher && watcher.mtimes) || {}); | ||
} | ||
|
||
return changedFiles.map((changedFile) => path.normalize(changedFile)); | ||
return watchFileSystem | ||
? Array.from(watchFileSystem.changedFiles).map((changedFile) => path.normalize(changedFile)) | ||
: []; | ||
} | ||
|
||
export { getChangedFiles }; |
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,23 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import webpack from 'webpack'; | ||
import path from 'path'; | ||
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState'; | ||
import { CompilerWithWatchFileSystem } from '../watch/CompilerWithWatchFileSystem'; | ||
import { InclusiveNodeWatchFileSystem } from '../watch/InclusiveNodeWatchFileSystem'; | ||
|
||
function getDeletedFiles( | ||
compiler: webpack.Compiler, | ||
state: ForkTsCheckerWebpackPluginState | ||
): string[] { | ||
let deletedFiles: string[] = []; | ||
function getDeletedFiles(compiler: webpack.Compiler): string[] { | ||
const watchFileSystem = (compiler as CompilerWithWatchFileSystem<InclusiveNodeWatchFileSystem>) | ||
.watchFileSystem; | ||
|
||
if ((compiler as any).removedFiles) { | ||
// webpack 5+ | ||
deletedFiles = Array.from((compiler as any).removedFiles || []); | ||
} else { | ||
// webpack 4 | ||
deletedFiles = [...state.removedFiles]; | ||
} | ||
|
||
return deletedFiles.map((changedFile) => path.normalize(changedFile)); | ||
return watchFileSystem | ||
? Array.from(watchFileSystem.removedFiles).map((removeFile) => path.normalize(removeFile)) | ||
: []; | ||
} | ||
|
||
export { getDeletedFiles }; |
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,22 @@ | ||
import webpack from 'webpack'; | ||
import { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState'; | ||
import { InclusiveNodeWatchFileSystem } from '../watch/InclusiveNodeWatchFileSystem'; | ||
import { CompilerWithWatchFileSystem } from '../watch/CompilerWithWatchFileSystem'; | ||
|
||
function tapAfterEnvironmentToPatchWatching( | ||
compiler: webpack.Compiler, | ||
state: ForkTsCheckerWebpackPluginState | ||
) { | ||
compiler.hooks.afterEnvironment.tap('ForkTsCheckerWebpackPlugin', () => { | ||
const watchFileSystem = (compiler as CompilerWithWatchFileSystem).watchFileSystem; | ||
if (watchFileSystem) { | ||
// wrap original watch file system | ||
(compiler as CompilerWithWatchFileSystem).watchFileSystem = new InclusiveNodeWatchFileSystem( | ||
watchFileSystem, | ||
state | ||
); | ||
} | ||
}); | ||
} | ||
|
||
export { tapAfterEnvironmentToPatchWatching }; |
Oops, something went wrong.