Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtbandes/ts-workspaces-repro
https://github.com/jtbandes/ts-workspaces-repro
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jtbandes/ts-workspaces-repro
- Owner: jtbandes
- Created: 2021-05-11T00:53:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-14T23:19:58.000Z (over 3 years ago)
- Last Synced: 2024-10-31T01:23:27.067Z (2 months ago)
- Language: JavaScript
- Homepage: https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/611
- Size: 635 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Issue when combining yarn workspaces, type-only imports, `webpack --watch`, `fork-ts-checker-webpack-plugin`
Type-only imports (`import type X`, or `import X` where X is only used as a type) result in incorrect `webpack --watch` behavior. When files residing in workspace packages are modified, the importing code does not always get recompiled.
Steps to reproduce:
1. Run `yarn install && yarn webpack --watch --progress --mode=development`
2. Modify `type Example1` in [packages/pkg1/index.ts](packages/pkg1/index.ts). Observe that webpack **does not** recompile `src/index.ts` nor display new type errors. ❌
3. Modify `function Example2` in [packages/pkg2/index.ts](packages/pkg2/index.ts). Observe that webpack **does** recompile `src/index.ts` and display new type errors (this is not a type-only import). ✅
4. Add
`"compilerOptions": { "importsNotUsedAsValues": "preserve" }` to [tsconfig.json](tsconfig.json). Now, observe that changing `pkg1/index.ts` **does** cause webpack to recompile. ✅
- Change `import {Example1} from 'pkg1'` to `import type {Example1} from 'pkg1'` in [src/index.ts](src/index.ts). Observe that changing `pkg1/index.ts` again **does not** result in a recompile. ❌ (This is because `"importsNotUsedAsValues": "preserve"` does not affect explicit `import type` imports, which are always removed.)