fork-ts-checker-webpack-plugin 6.4.1 → 6.5.1

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
@@ -157,7 +157,7 @@ Options for the TypeScript checker (`typescript` option object).
157
157
  | `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`. |
158
158
  | `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`. |
159
159
  | `build` | `boolean` | `false` | The equivalent of the `--build` flag for the `tsc` command. |
160
- | `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`. |
160
+ | `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. |
161
161
  | `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
162
162
  | `extensions` | `object` | `{}` | See [TypeScript extensions options](#typescript-extensions-options). |
163
163
  | `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
@@ -76,7 +76,7 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
76
76
  /**
77
77
  * Current version of the plugin
78
78
  */
79
- ForkTsCheckerWebpackPlugin.version = '6.4.1'; // will be replaced by the @semantic-release/exec
79
+ ForkTsCheckerWebpackPlugin.version = '6.5.1'; // will be replaced by the @semantic-release/exec
80
80
  /**
81
81
  * Default pools for the plugin concurrency limit
82
82
  */
@@ -138,8 +138,8 @@
138
138
  },
139
139
  "mode": {
140
140
  "type": "string",
141
- "enum": ["readonly", "write-tsbuildinfo", "write-references"],
142
- "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"
141
+ "enum": ["readonly", "write-tsbuildinfo", "write-dts", "write-references"],
142
+ "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"
143
143
  },
144
144
  "compilerOptions": {
145
145
  "type": "object",
@@ -10,7 +10,7 @@ interface TypeScriptReporterConfiguration {
10
10
  configOverwrite: TypeScriptConfigurationOverwrite;
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: TypeScriptVueExtensionConfiguration;
@@ -8,7 +8,7 @@ declare type TypeScriptReporterOptions = boolean | {
8
8
  configOverwrite?: TypeScriptConfigurationOverwrite;
9
9
  context?: string;
10
10
  build?: boolean;
11
- mode?: 'readonly' | 'write-tsbuildinfo' | 'write-references';
11
+ mode?: 'readonly' | 'write-tsbuildinfo' | 'write-dts' | 'write-references';
12
12
  diagnosticOptions?: Partial<TypeScriptDiagnosticsOptions>;
13
13
  extensions?: {
14
14
  vue?: TypeScriptVueExtensionOptions;
@@ -58,17 +58,6 @@ function createTypeScriptVueExtension(configuration) {
58
58
  extension: getExtensionByLang(lang),
59
59
  };
60
60
  }
61
- function mergeVueScriptsContent(scriptContent, scriptSetupContent) {
62
- var _a, _b;
63
- const scriptLines = (_a = scriptContent === null || scriptContent === void 0 ? void 0 : scriptContent.split(/\r?\n/)) !== null && _a !== void 0 ? _a : [];
64
- const scriptSetupLines = (_b = scriptSetupContent === null || scriptSetupContent === void 0 ? void 0 : scriptSetupContent.split(/\r?\n/)) !== null && _b !== void 0 ? _b : [];
65
- const maxScriptLines = Math.max(scriptLines.length, scriptSetupLines.length);
66
- const mergedScriptLines = [];
67
- for (let line = 0; line < maxScriptLines; ++line) {
68
- mergedScriptLines.push(scriptLines[line] || scriptSetupLines[line]);
69
- }
70
- return mergedScriptLines.join('\n');
71
- }
72
61
  function getVueEmbeddedSource(fileName) {
73
62
  if (!fs_extra_1.default.existsSync(fileName)) {
74
63
  return undefined;
@@ -78,37 +67,23 @@ function createTypeScriptVueExtension(configuration) {
78
67
  let script;
79
68
  if (isVueTemplateCompilerV2(compiler)) {
80
69
  const parsed = compiler.parseComponent(vueSourceText, {
81
- pad: 'line',
70
+ pad: 'space',
82
71
  });
83
72
  script = parsed.script;
84
73
  }
85
74
  else if (isVueTemplateCompilerV3(compiler)) {
86
- const parsed = compiler.parse(vueSourceText, {
87
- pad: 'line',
88
- });
89
- if (parsed.descriptor) {
90
- const parsedScript = parsed.descriptor.script;
91
- const parsedScriptSetup = parsed.descriptor.scriptSetup;
92
- let parsedContent = mergeVueScriptsContent(parsedScript === null || parsedScript === void 0 ? void 0 : parsedScript.content, parsedScriptSetup === null || parsedScriptSetup === void 0 ? void 0 : parsedScriptSetup.content);
93
- if (parsedScriptSetup) {
94
- // a little bit naive, but should work in 99.9% cases without need for parsing script
95
- const alreadyHasExportDefault = /export\s+default[\s|{]/gm.test(parsedContent);
96
- if (!alreadyHasExportDefault) {
97
- parsedContent += '\nexport default {};';
98
- }
99
- // add script setup lines at the end
100
- parsedContent +=
101
- "\n// @ts-ignore\nimport { defineProps, defineEmits, defineExpose, withDefaults } from '@vue/runtime-core';";
102
- }
103
- if (parsedScript || parsedScriptSetup) {
104
- // map newer version of SFCScriptBlock to the generic one
105
- script = {
106
- content: parsedContent,
107
- attrs: {
108
- lang: (parsedScript === null || parsedScript === void 0 ? void 0 : parsedScript.lang) || (parsedScriptSetup === null || parsedScriptSetup === void 0 ? void 0 : parsedScriptSetup.lang),
109
- },
110
- };
111
- }
75
+ const parsed = compiler.parse(vueSourceText);
76
+ if (parsed.descriptor && parsed.descriptor.script) {
77
+ const scriptV3 = parsed.descriptor.script;
78
+ // map newer version of SFCScriptBlock to the generic one
79
+ script = {
80
+ content: scriptV3.content,
81
+ attrs: scriptV3.attrs,
82
+ start: scriptV3.loc.start.offset,
83
+ end: scriptV3.loc.end.offset,
84
+ lang: scriptV3.lang,
85
+ src: scriptV3.src,
86
+ };
112
87
  }
113
88
  }
114
89
  else {
@@ -126,7 +101,10 @@ function createTypeScriptVueExtension(configuration) {
126
101
  }
127
102
  else {
128
103
  // <script lang="ts"></script> block
129
- return createVueInlineScriptEmbeddedSource(script.content, script.attrs.lang);
104
+ // pad blank lines to retain diagnostics location
105
+ const lineOffset = vueSourceText.slice(0, script.start).split(/\r?\n/g).length;
106
+ const paddedSourceText = Array(lineOffset).join('\n') + vueSourceText.slice(script.start, script.end);
107
+ return createVueInlineScriptEmbeddedSource(paddedSourceText, script.attrs.lang);
130
108
  }
131
109
  }
132
110
  return TypeScriptEmbeddedExtension_1.createTypeScriptEmbeddedExtension({
@@ -20,7 +20,6 @@ interface SFCDescriptor {
20
20
  filename: string;
21
21
  template: SFCBlock | null;
22
22
  script: SFCBlock | null;
23
- scriptSetup: SFCBlock | null;
24
23
  styles: SFCBlock[];
25
24
  customBlocks: SFCBlock[];
26
25
  }
@@ -32,10 +31,7 @@ interface SFCParseResult {
32
31
  descriptor: SFCDescriptor;
33
32
  errors: CompilerError[];
34
33
  }
35
- interface SFCParserOptionsV3 {
36
- pad?: true | 'line' | 'space';
37
- }
38
34
  export interface VueTemplateCompilerV3 {
39
- parse(template: string, options?: SFCParserOptionsV3): SFCParseResult;
35
+ parse(template: string, options?: any): SFCParseResult;
40
36
  }
41
37
  export {};
@@ -16,6 +16,6 @@ interface ControlledTypeScriptSystem extends ts.System {
16
16
  waitForQueued(): Promise<void>;
17
17
  setArtifacts(artifacts: FilesMatch): void;
18
18
  }
19
- declare type FileSystemMode = 'readonly' | 'write-tsbuildinfo' | 'write-references';
19
+ declare type FileSystemMode = 'readonly' | 'write-tsbuildinfo' | 'write-dts' | 'write-references';
20
20
  declare function createControlledTypeScriptSystem(typescript: typeof ts, mode?: FileSystemMode): ControlledTypeScriptSystem;
21
21
  export { createControlledTypeScriptSystem, ControlledTypeScriptSystem };
@@ -113,7 +113,9 @@ function createControlledTypeScriptSystem(typescript, mode = 'readonly') {
113
113
  }
114
114
  function getWriteFileSystem(path) {
115
115
  if (mode === 'write-references' ||
116
- (mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo'))) {
116
+ (mode === 'write-tsbuildinfo' && path.endsWith('.tsbuildinfo')) ||
117
+ (mode === 'write-dts' &&
118
+ ['.tsbuildinfo', '.d.ts', '.d.ts.map'].some((prefix) => path.endsWith(prefix)))) {
117
119
  return realFileSystem;
118
120
  }
119
121
  return passiveFileSystem;
@@ -8,6 +8,8 @@ const path_1 = require("path");
8
8
  const reporter_1 = require("../reporter");
9
9
  const minimatch_1 = __importDefault(require("minimatch"));
10
10
  const BUILTIN_IGNORED_DIRS = ['node_modules', '.git', '.yarn', '.pnp'];
11
+ // we ignore package.json file because of https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/674
12
+ const BUILTIN_IGNORED_FILES = ['package.json'];
11
13
  function createIsIgnored(ignored, excluded) {
12
14
  const ignoredPatterns = ignored ? (Array.isArray(ignored) ? ignored : [ignored]) : [];
13
15
  const ignoredFunctions = ignoredPatterns.map((pattern) => {
@@ -28,6 +30,7 @@ function createIsIgnored(ignored, excluded) {
28
30
  });
29
31
  ignoredFunctions.push((path) => excluded.some((excludedPath) => path.startsWith(excludedPath)));
30
32
  ignoredFunctions.push((path) => BUILTIN_IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`)));
33
+ ignoredFunctions.push((path) => BUILTIN_IGNORED_FILES.some((ignoredFile) => path.endsWith(`/${ignoredFile}`)));
31
34
  return function isIgnored(path) {
32
35
  return ignoredFunctions.some((ignoredFunction) => ignoredFunction(path));
33
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fork-ts-checker-webpack-plugin",
3
- "version": "6.4.1",
3
+ "version": "6.5.1",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "fast",