fork-ts-checker-webpack-plugin 7.0.0-alpha.14 → 7.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -106,7 +106,7 @@ Options for the TypeScript checker (`typescript` option object).
106
106
  | `configOverwrite` | `object` | `{ compilerOptions: { skipLibCheck: true, sourceMap: false, inlineSourceMap: false, declarationMap: false } }` | This configuration will overwrite configuration from the `tsconfig.json` file. Supported fields are: `extends`, `compilerOptions`, `include`, `exclude`, `files`, and `references`. |
107
107
  | `context` | `string` | `dirname(configuration.configFile)` | The base path for finding files specified in the `tsconfig.json`. Same as the `context` option from the [ts-loader](https://github.com/TypeStrong/ts-loader#context). Useful if you want to keep your `tsconfig.json` in an external package. Keep in mind that **not** having a `tsconfig.json` in your project root can cause different behaviour between `fork-ts-checker-webpack-plugin` and `tsc`. When using editors like `VS Code` it is advised to add a `tsconfig.json` file to the root of the project and extend the config file referenced in option `configFile`. |
108
108
  | `build` | `boolean` | `false` | The equivalent of the `--build` flag for the `tsc` command. |
109
- | `mode` | `'readonly'` or `'write-tsbuildinfo'` or `'write-references'` | `'write-tsbuildinfo'` | If you use the `babel-loader`, it's recommended to use `write-references` mode to improve initial compilation time. If you use `ts-loader`, it's recommended to use `write-tsbuildinfo` mode to not overwrite files emitted by the `ts-loader`. |
109
+ | `mode` | `'readonly'` or `'write-tsbuildinfo'` or `'write-dts'` or `'write-references'` | `'write-tsbuildinfo'` | If you use the `babel-loader`, it's recommended to use `write-references` mode to improve initial compilation time. If you use `ts-loader`, it's recommended to use `write-tsbuildinfo` mode to not overwrite files emitted by the `ts-loader`. If you use `ts-loader` with `transpileOnly` flag set to `true`, use `'write-dts` to emit the type definition files. |
110
110
  | `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
111
111
  | `extensions` | `object` | `{}` | See [TypeScript extensions options](#typescript-extensions-options). |
112
112
  | `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
@@ -299,24 +299,37 @@ When we call this method with a [webpack compiler instance](https://webpack.js.o
299
299
  [tapable](https://github.com/webpack/tapable) hooks where you can pass in your callbacks.
300
300
 
301
301
  ```js
302
- const webpack = require('webpack');
302
+ // ./src/webpack/MyWebpackPlugin.js
303
303
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
304
304
 
305
- const compiler = webpack({
306
- // ... webpack config
307
- });
305
+ class MyWebpackPlugin {
306
+ apply(compiler) {
307
+ const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
308
+
309
+ // log some message on waiting
310
+ hooks.waiting.tap('MyPlugin', () => {
311
+ console.log('waiting for issues');
312
+ });
313
+ // don't show warnings
314
+ hooks.issues.tap('MyPlugin', (issues) =>
315
+ issues.filter((issue) => issue.severity === 'error')
316
+ );
317
+ }
318
+ }
308
319
 
309
- // optionally add the plugin to the compiler
310
- // **don't do this if already added through configuration**
311
- new ForkTsCheckerWebpackPlugin().apply(compiler);
320
+ module.exports = MyWebpackPlugin;
312
321
 
313
- // now get the plugin hooks from compiler
314
- const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
322
+ // webpack.config.js
323
+ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
324
+ const MyWebpackPlugin = require('./src/webpack/MyWebpackPlugin');
315
325
 
316
- // say we want to show some message when plugin is waiting for issues results
317
- hooks.waiting.tap('yourListenerName', () => {
318
- console.log('waiting for issues');
319
- });
326
+ module.exports = {
327
+ /* ... */
328
+ plugins: [
329
+ new ForkTsCheckerWebpackPlugin(),
330
+ new MyWebpackPlugin()
331
+ ]
332
+ };
320
333
  ```
321
334
 
322
335
  ## Typings
@@ -334,7 +347,7 @@ yarn add --dev @types/webpack
334
347
 
335
348
  ## Profiling types resolution
336
349
 
337
- Starting from TypeScript 4.1.0 (currently in beta), you can profile long type checks by
350
+ Starting from TypeScript 4.1.0, you can profile long type checks by
338
351
  setting "generateTrace" compiler option. This is an instruction from [microsoft/TypeScript#40063](https://github.com/microsoft/TypeScript/pull/40063):
339
352
 
340
353
  1. Set "generateTrace": "{folderName}" in your `tsconfig.json`
@@ -129,9 +129,10 @@
129
129
  "enum": [
130
130
  "readonly",
131
131
  "write-tsbuildinfo",
132
+ "write-dts",
132
133
  "write-references"
133
134
  ],
134
- "description": "`readonly` keeps all emitted files in memory, `write-tsbuildinfo` which writes only .tsbuildinfo files and `write-references` which writes both .tsbuildinfo and referenced projects output"
135
+ "description": "`readonly` keeps all emitted files in memory, `write-tsbuildinfo` which writes only .tsbuildinfo files, `write-dts` writes .tsbuildinfo and type definition files, and `write-references` which writes both .tsbuildinfo and referenced projects output"
135
136
  },
136
137
  "compilerOptions": {
137
138
  "type": "object",
package/lib/plugin.js CHANGED
@@ -70,7 +70,7 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
70
70
  /**
71
71
  * Current version of the plugin
72
72
  */
73
- ForkTsCheckerWebpackPlugin.version = '7.0.0-alpha.14'; // will be replaced by the @semantic-release/exec
73
+ ForkTsCheckerWebpackPlugin.version = '7.0.0-alpha.15'; // will be replaced by the @semantic-release/exec
74
74
  /**
75
75
  * Default pools for the plugin concurrency limit
76
76
  */
@@ -10,7 +10,7 @@ interface TypeScriptWorkerConfig {
10
10
  configOverwrite: TypeScriptConfigOverwrite;
11
11
  build: boolean;
12
12
  context: string;
13
- mode: 'readonly' | 'write-tsbuildinfo' | 'write-references';
13
+ mode: 'readonly' | 'write-tsbuildinfo' | 'write-dts' | 'write-references';
14
14
  diagnosticOptions: TypeScriptDiagnosticsOptions;
15
15
  extensions: {
16
16
  vue: TypeScriptVueExtensionConfig;
@@ -7,7 +7,7 @@ declare type TypeScriptWorkerOptions = {
7
7
  configOverwrite?: TypeScriptConfigOverwrite;
8
8
  context?: string;
9
9
  build?: boolean;
10
- mode?: 'readonly' | 'write-tsbuildinfo' | 'write-references';
10
+ mode?: 'readonly' | 'write-tsbuildinfo' | 'write-dts' | 'write-references';
11
11
  diagnosticOptions?: Partial<TypeScriptDiagnosticsOptions>;
12
12
  extensions?: {
13
13
  vue?: TypeScriptVueExtensionOptions;
@@ -24,9 +24,9 @@ const tsbuildinfo_1 = require("./lib/tsbuildinfo");
24
24
  const worker_config_1 = require("./lib/worker-config");
25
25
  const getIssuesWorker = ({ changedFiles = [], deletedFiles = [] }, watching) => __awaiter(void 0, void 0, void 0, function* () {
26
26
  system_1.system.invalidateCache();
27
+ dependencies_1.invalidateDependencies();
27
28
  if (config_1.didConfigFileChanged({ changedFiles, deletedFiles })) {
28
29
  config_1.invalidateConfig();
29
- dependencies_1.invalidateDependencies();
30
30
  artifacts_1.invalidateArtifacts();
31
31
  diagnostics_1.invalidateDiagnostics();
32
32
  program_1.invalidateProgram(true);
@@ -35,7 +35,6 @@ const getIssuesWorker = ({ changedFiles = [], deletedFiles = [] }, watching) =>
35
35
  tsbuildinfo_1.invalidateTsBuildInfo();
36
36
  }
37
37
  else if (config_1.didRootFilesChanged()) {
38
- dependencies_1.invalidateDependencies();
39
38
  artifacts_1.invalidateArtifacts();
40
39
  watch_program_1.invalidateWatchProgramRootFileNames();
41
40
  solution_builder_1.invalidateSolutionBuilder();
@@ -34,7 +34,10 @@ const deletedFiles = new Map();
34
34
  const timeoutCallbacks = new Set();
35
35
  // based on the ts.ignorePaths
36
36
  const ignoredPaths = ['/node_modules/.', '/.git', '/.#'];
37
- exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), { useCaseSensitiveFileNames: true, fileExists(path) {
37
+ exports.system = Object.assign(Object.assign({}, typescript_1.typescript.sys), { useCaseSensitiveFileNames: true, realpath(path) {
38
+ return getReadFileSystem(path).realPath(path);
39
+ },
40
+ fileExists(path) {
38
41
  const stats = getReadFileSystem(path).readStats(path);
39
42
  return !!stats && stats.isFile();
40
43
  },
@@ -192,14 +195,27 @@ function isArtifact(path) {
192
195
  artifacts.extensions.some((extension) => path.endsWith(extension)));
193
196
  }
194
197
  function getReadFileSystem(path) {
195
- if (!isInitialRun && (mode === 'readonly' || mode === 'write-tsbuildinfo') && isArtifact(path)) {
196
- return mem_file_system_1.memFileSystem;
198
+ if ((mode === 'readonly' || mode === 'write-tsbuildinfo') && isArtifact(path)) {
199
+ if (isInitialRun && !mem_file_system_1.memFileSystem.exists(path) && passive_file_system_1.passiveFileSystem.exists(path)) {
200
+ // copy file to memory on initial run
201
+ const stats = passive_file_system_1.passiveFileSystem.readStats(path);
202
+ if (stats === null || stats === void 0 ? void 0 : stats.isFile()) {
203
+ const content = passive_file_system_1.passiveFileSystem.readFile(path);
204
+ if (content) {
205
+ mem_file_system_1.memFileSystem.writeFile(path, content);
206
+ mem_file_system_1.memFileSystem.updateTimes(path, stats.atime, stats.mtime);
207
+ }
208
+ }
209
+ return mem_file_system_1.memFileSystem;
210
+ }
197
211
  }
198
212
  return passive_file_system_1.passiveFileSystem;
199
213
  }
200
214
  function getWriteFileSystem(path) {
201
215
  if (mode === 'write-references' ||
202
- (mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo'))) {
216
+ (mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo')) ||
217
+ (mode === 'write-dts' &&
218
+ ['.tsbuildinfo', '.d.ts', '.d.ts.map'].some((suffix) => path.endsWith(suffix)))) {
203
219
  return real_file_system_1.realFileSystem;
204
220
  }
205
221
  return passive_file_system_1.passiveFileSystem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fork-ts-checker-webpack-plugin",
3
- "version": "7.0.0-alpha.14",
3
+ "version": "7.0.0-alpha.15",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "fast",
@@ -70,7 +70,13 @@
70
70
  },
71
71
  "peerDependencies": {
72
72
  "typescript": ">3.6.0",
73
- "webpack": "^5.11.0"
73
+ "webpack": "^5.11.0",
74
+ "vue-template-compiler": "*"
75
+ },
76
+ "peerDependenciesMeta": {
77
+ "vue-template-compiler": {
78
+ "optional": true
79
+ }
74
80
  },
75
81
  "devDependencies": {
76
82
  "@commitlint/config-conventional": "^13.1.0",