feat(node): expose webpack watchOptions to executor (#11453)

This commit is contained in:
Herb 2022-08-18 12:34:33 -04:00 committed by GitHub
parent 09112ccd24
commit 86b2015ddd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 0 deletions

View File

@ -302,6 +302,22 @@
"description": "Run build when files change.",
"default": false
},
"watchOptions": {
"type": "object",
"description": "A set of options used to customize watch mode.",
"properties": {
"aggregateTimeout": { "type": "integer" },
"ignored": {
"oneOf": [
{ "type": "array", "items": { "type": "string" } },
{ "type": "string" }
]
},
"poll": { "type": "integer" },
"followSymlinks": { "type": "boolean" },
"stdin": { "type": "boolean" }
}
},
"poll": {
"type": "number",
"description": "Frequency of file watcher in ms."

View File

@ -26,6 +26,37 @@
"description": "Run build when files change.",
"default": false
},
"watchOptions": {
"type": "object",
"description": "A set of options used to customize watch mode.",
"properties": {
"aggregateTimeout": {
"type": "integer"
},
"ignored": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "string"
}
]
},
"poll": {
"type": "integer"
},
"followSymlinks": {
"type": "boolean"
},
"stdin": {
"type": "boolean"
}
}
},
"poll": {
"type": "number",
"description": "Frequency of file watcher in ms."

View File

@ -84,6 +84,27 @@ describe('Node Build Executor', () => {
);
});
it('should use watchOptions if passed in', async () => {
await webpackExecutor(
{
...options,
watchOptions: {
ignored: ['path1'],
},
},
context
).next();
expect(runWebpack).toHaveBeenCalledWith(
expect.objectContaining({
watchOptions: {
ignored: ['path1'],
aggregateTimeout: 200,
},
})
);
});
describe('webpackConfig', () => {
it('should handle custom path', async () => {
jest.mock(

View File

@ -113,6 +113,7 @@ export function getBaseWebpackPartial(
// two builds on a single file change.
aggregateTimeout: 200,
poll: options.poll,
...options.watchOptions,
},
stats: getStatsConfig(options),
experiments: {

View File

@ -59,11 +59,20 @@ export interface AdditionalEntryPoint {
entryPath: string;
}
export interface WebpackWatchOptions {
aggregateTimeout?: number;
ignored?: Array<string> | string;
poll?: number;
followSymlinks?: boolean;
stdin?: boolean;
}
export interface BuildBuilderOptions {
main: string;
outputPath: string;
tsConfig: string;
watch?: boolean;
watchOptions?: WebpackWatchOptions;
sourceMap?: boolean | SourceMapOptions;
optimization?: boolean | OptimizationOptions;
maxWorkers?: number;