-
Notifications
You must be signed in to change notification settings - Fork 789
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): respect project tsconfig watch options (#5916)
* fix(compiler): respect project tsconfig watch options Fixes: #5709 STENCIL-1079 * add tests * export function
- Loading branch information
1 parent
fd75952
commit 74adeee
Showing
6 changed files
with
121 additions
and
8 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,46 @@ | ||
import ts from 'typescript'; | ||
|
||
import { ValidatedConfig } from '../../../declarations'; | ||
import { mockValidatedConfig } from '../../../testing/mocks'; | ||
import { createTsWatchProgram } from '../create-watch-program'; | ||
|
||
describe('createWatchProgram', () => { | ||
let config: ValidatedConfig; | ||
|
||
beforeEach(() => { | ||
config = mockValidatedConfig(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('includes watchOptions in the watch program creation', async () => { | ||
config.tsWatchOptions = { | ||
fallbackPolling: 3, | ||
excludeFiles: ['src/components/my-component/my-component.tsx'], | ||
excludeDirectories: ['src/components/my-other-component'], | ||
} as ts.WatchOptions; | ||
config.tsconfig = ''; | ||
const tsSpy = jest.spyOn(ts, 'createWatchCompilerHost').mockReturnValue({} as any); | ||
jest.spyOn(ts, 'createWatchProgram').mockReturnValue({} as any); | ||
|
||
await createTsWatchProgram(config, () => new Promise(() => {})); | ||
|
||
expect(tsSpy.mock.calls[0][6]).toEqual({ | ||
excludeFiles: ['src/components/my-component/my-component.tsx'], | ||
excludeDirectories: ['src/components/my-other-component'], | ||
}); | ||
}); | ||
|
||
it('omits watchOptions when not provided', async () => { | ||
config.tsWatchOptions = undefined; | ||
config.tsconfig = ''; | ||
const tsSpy = jest.spyOn(ts, 'createWatchCompilerHost').mockReturnValue({} as any); | ||
jest.spyOn(ts, 'createWatchProgram').mockReturnValue({} as any); | ||
|
||
await createTsWatchProgram(config, () => new Promise(() => {})); | ||
|
||
expect(tsSpy.mock.calls[0][6]).toEqual(undefined); | ||
}); | ||
}); |
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