fork-ts-checker-webpack-plugin 7.3.0 → 8.0.0
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 +1 -126
- package/lib/plugin-options.json +0 -29
- package/lib/plugin.js +1 -1
- package/lib/typescript/type-script-support.js +0 -4
- package/lib/typescript/type-script-worker-config.d.ts +0 -4
- package/lib/typescript/type-script-worker-config.js +1 -4
- package/lib/typescript/type-script-worker-options.d.ts +0 -4
- package/lib/typescript/worker/lib/config.js +1 -7
- package/lib/typescript/worker/lib/dependencies.js +0 -6
- package/lib/typescript/worker/lib/diagnostics.js +1 -8
- package/lib/typescript/worker/lib/host/compiler-host.js +1 -8
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +1 -13
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +1 -8
- package/lib/utils/path/is-inside-another-path.d.ts +2 -0
- package/lib/utils/path/is-inside-another-path.js +22 -0
- package/lib/watch/inclusive-node-watch-file-system.js +2 -1
- package/package.json +1 -7
- package/lib/typescript/extension/type-script-embedded-extension.d.ts +0 -19
- package/lib/typescript/extension/type-script-embedded-extension.js +0 -112
- package/lib/typescript/extension/type-script-extension.d.ts +0 -16
- package/lib/typescript/extension/type-script-extension.js +0 -2
- package/lib/typescript/extension/vue/type-script-vue-extension-config.d.ts +0 -7
- package/lib/typescript/extension/vue/type-script-vue-extension-config.js +0 -7
- package/lib/typescript/extension/vue/type-script-vue-extension-options.d.ts +0 -5
- package/lib/typescript/extension/vue/type-script-vue-extension-options.js +0 -2
- package/lib/typescript/extension/vue/type-script-vue-extension-support.d.ts +0 -3
- package/lib/typescript/extension/vue/type-script-vue-extension-support.js +0 -20
- package/lib/typescript/extension/vue/type-script-vue-extension.d.ts +0 -4
- package/lib/typescript/extension/vue/type-script-vue-extension.js +0 -116
- package/lib/typescript/extension/vue/types/vue-template-compiler.d.ts +0 -28
- package/lib/typescript/extension/vue/types/vue-template-compiler.js +0 -2
- package/lib/typescript/extension/vue/types/vue__compiler-sfc.d.ts +0 -37
- package/lib/typescript/extension/vue/types/vue__compiler-sfc.js +0 -2
- package/lib/typescript/worker/lib/extensions.d.ts +0 -3
- package/lib/typescript/worker/lib/extensions.js +0 -11
package/README.md
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
* Speeds up [TypeScript](https://github.com/Microsoft/TypeScript) type checking (by moving it to a separate process) 🏎
|
|
21
21
|
* Supports modern TypeScript features like [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) and [incremental mode](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#faster-subsequent-builds-with-the---incremental-flag) ✨
|
|
22
|
-
* Supports [Vue Single File Component](https://vuejs.org/v2/guide/single-file-components.html) ✅
|
|
23
22
|
* Displays nice error messages with the [code frame](https://babeljs.io/docs/en/next/babel-code-frame.html) formatter 🌈
|
|
24
23
|
|
|
25
24
|
## Installation
|
|
@@ -28,6 +27,7 @@ This plugin requires **Node.js >=12.13.0+**, **Webpack ^5.11.0**, **TypeScript ^
|
|
|
28
27
|
|
|
29
28
|
* If you depend on **TypeScript 2.1 - 2.6.2**, please use [version 4](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v4.1.4) of the plugin.
|
|
30
29
|
* If you depend on **Webpack 4**, **TypeScript 2.7 - 3.5.3** or **ESLint** feature, please use [version 6](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v6.2.6) of the plugin.
|
|
30
|
+
* If you need Vue.js support, please use [version 6](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v6.5.2) of ths plugin
|
|
31
31
|
|
|
32
32
|
```sh
|
|
33
33
|
# with npm
|
|
@@ -115,20 +115,9 @@ Options for the TypeScript checker (`typescript` option object).
|
|
|
115
115
|
| `build` | `boolean` | `false` | The equivalent of the `--build` flag for the `tsc` command. |
|
|
116
116
|
| `mode` | `'readonly'` or `'write-dts'` or `'write-tsbuildinfo'` or `'write-references'` | `build === true ? 'write-tsbuildinfo' ? 'readonly'` | Use `readonly` if you don't want to write anything on the disk, `write-dts` to write only `.d.ts` files, `write-tsbuildinfo` to write only `.tsbuildinfo` files, `write-references` to write both `.js` and `.d.ts` files of project references (last 2 modes requires `build: true`). |
|
|
117
117
|
| `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
|
|
118
|
-
| `extensions` | `object` | `{}` | See [TypeScript extensions options](#typescript-extensions-options). |
|
|
119
118
|
| `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
|
|
120
119
|
| `typescriptPath` | `string` | `require.resolve('typescript')` | If supplied this is a custom path where TypeScript can be found. |
|
|
121
120
|
|
|
122
|
-
#### TypeScript extensions options
|
|
123
|
-
|
|
124
|
-
Options for the TypeScript checker extensions (`typescript.extensions` option object).
|
|
125
|
-
|
|
126
|
-
| Name | Type | Default value | Description |
|
|
127
|
-
|----------------|-----------------------|---------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
128
|
-
| `vue` | `object` or `boolean` | `false` | If `true`, it enables Vue [Single File Component](https://vuejs.org/v2/guide/single-file-components.html) support. |
|
|
129
|
-
| `vue.enabled` | `boolean` | `false` | Same as the `vue` option |
|
|
130
|
-
| `vue.compiler` | `string` | `'vue-template-compiler'` | The package name of the compiler that will be used to parse `.vue` files. You can use `'nativescript-vue-template-compiler'` if you use [nativescript-vue](https://github.com/nativescript-vue/nativescript-vue) |
|
|
131
|
-
|
|
132
121
|
### Issues options
|
|
133
122
|
|
|
134
123
|
Options for the issues filtering (`issue` option object).
|
|
@@ -176,120 +165,6 @@ module.exports = {
|
|
|
176
165
|
|
|
177
166
|
</details>
|
|
178
167
|
|
|
179
|
-
## Vue.js
|
|
180
|
-
|
|
181
|
-
⚠️ There are additional **constraints** regarding Vue.js Single File Component support: ⚠️
|
|
182
|
-
* It requires **TypeScript >= 3.8.0** (it's a limitation of the `transpileOnly` mode from `ts-loader`)
|
|
183
|
-
* It doesn't work with the `build` mode (project references)
|
|
184
|
-
|
|
185
|
-
To enable Vue.js support, follow these steps:
|
|
186
|
-
|
|
187
|
-
<details>
|
|
188
|
-
<summary>Expand Vue.js set up instruction</summary>
|
|
189
|
-
|
|
190
|
-
1. Ensure you have all required packages installed:
|
|
191
|
-
```sh
|
|
192
|
-
# with npm
|
|
193
|
-
npm install --save vue vue-class-component
|
|
194
|
-
npm install --save-dev vue-loader ts-loader css-loader vue-template-compiler
|
|
195
|
-
|
|
196
|
-
# with yarn
|
|
197
|
-
yarn add vue vue-class-component
|
|
198
|
-
yarn add --dev vue-loader ts-loader css-loader vue-template-compiler
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
2. Add `tsconfig.json` configuration:
|
|
202
|
-
```json
|
|
203
|
-
{
|
|
204
|
-
"compilerOptions": {
|
|
205
|
-
"experimentalDecorators": true,
|
|
206
|
-
"jsx": "preserve",
|
|
207
|
-
"target": "ES5",
|
|
208
|
-
"lib": ["ES6", "DOM"],
|
|
209
|
-
"baseUrl": ".",
|
|
210
|
-
"paths": {
|
|
211
|
-
"@/*": ["src/*"],
|
|
212
|
-
"~/*": ["src/*"]
|
|
213
|
-
},
|
|
214
|
-
"sourceMap": true,
|
|
215
|
-
"importsNotUsedAsValues": "preserve"
|
|
216
|
-
},
|
|
217
|
-
"include": [
|
|
218
|
-
"src/**/*.ts",
|
|
219
|
-
"src/**/*.vue"
|
|
220
|
-
],
|
|
221
|
-
"exclude": [
|
|
222
|
-
"node_modules"
|
|
223
|
-
]
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
3. Add `webpack.config.js` configuration:
|
|
228
|
-
```js
|
|
229
|
-
const path = require('path');
|
|
230
|
-
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
|
231
|
-
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
232
|
-
|
|
233
|
-
module.exports = {
|
|
234
|
-
entry: './src/index.ts',
|
|
235
|
-
output: {
|
|
236
|
-
filename: 'index.js',
|
|
237
|
-
path: path.resolve(__dirname, 'dist'),
|
|
238
|
-
},
|
|
239
|
-
module: {
|
|
240
|
-
rules: [
|
|
241
|
-
{
|
|
242
|
-
test: /\.vue$/,
|
|
243
|
-
loader: 'vue-loader'
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
test: /\.ts$/,
|
|
247
|
-
loader: 'ts-loader',
|
|
248
|
-
exclude: /node_modules/,
|
|
249
|
-
options: {
|
|
250
|
-
appendTsSuffixTo: [/\.vue$/],
|
|
251
|
-
// add transpileOnly option if you use ts-loader < 9.3.0
|
|
252
|
-
// transpileOnly: true
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
test: /\.css$/,
|
|
257
|
-
loader: 'css-loader'
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
},
|
|
261
|
-
resolve: {
|
|
262
|
-
extensions: ['.ts', '.js', '.vue', '.json'],
|
|
263
|
-
alias: {
|
|
264
|
-
'@': path.resolve(__dirname, './src'),
|
|
265
|
-
'~': path.resolve(__dirname, './src'),
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
plugins: [
|
|
269
|
-
new VueLoaderPlugin(),
|
|
270
|
-
new ForkTsCheckerWebpackPlugin({
|
|
271
|
-
typescript: {
|
|
272
|
-
extensions: {
|
|
273
|
-
vue: true
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
})
|
|
277
|
-
]
|
|
278
|
-
};
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
4. Add `src/types/vue.d.ts` file to shim `.vue` modules:
|
|
282
|
-
```typescript
|
|
283
|
-
declare module "*.vue" {
|
|
284
|
-
import Vue from "vue";
|
|
285
|
-
export default Vue;
|
|
286
|
-
}
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
5. If you are working in VSCode, you can get the [Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur) extension to complete the developer workflow.
|
|
290
|
-
|
|
291
|
-
</details>
|
|
292
|
-
|
|
293
168
|
## Plugin hooks
|
|
294
169
|
|
|
295
170
|
This plugin provides some custom webpack hooks:
|
package/lib/plugin-options.json
CHANGED
|
@@ -159,14 +159,6 @@
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
},
|
|
162
|
-
"extensions": {
|
|
163
|
-
"type": "object",
|
|
164
|
-
"properties": {
|
|
165
|
-
"vue": {
|
|
166
|
-
"$ref": "#/definitions/TypeScriptVueExtensionOptions"
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
162
|
"profile": {
|
|
171
163
|
"type": "boolean",
|
|
172
164
|
"description": "Measures and prints timings related to the TypeScript performance."
|
|
@@ -177,27 +169,6 @@
|
|
|
177
169
|
}
|
|
178
170
|
}
|
|
179
171
|
},
|
|
180
|
-
"TypeScriptVueExtensionOptions": {
|
|
181
|
-
"oneOf": [
|
|
182
|
-
{
|
|
183
|
-
"type": "boolean",
|
|
184
|
-
"description": "Enable TypeScript Vue extension."
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
"type": "object",
|
|
188
|
-
"properties": {
|
|
189
|
-
"enabled": {
|
|
190
|
-
"type": "boolean",
|
|
191
|
-
"description": "Enable TypeScript Vue extension."
|
|
192
|
-
},
|
|
193
|
-
"compiler": {
|
|
194
|
-
"type": "string",
|
|
195
|
-
"description": "Custom vue-template-compiler package"
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
]
|
|
200
|
-
},
|
|
201
172
|
"FormatterOptions": {
|
|
202
173
|
"oneOf": [
|
|
203
174
|
{
|
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 = '
|
|
73
|
+
ForkTsCheckerWebpackPlugin.version = '8.0.0'; // will be replaced by the @semantic-release/exec
|
|
74
74
|
/**
|
|
75
75
|
* Default pools for the plugin concurrency limit
|
|
76
76
|
*/
|
|
@@ -26,7 +26,6 @@ exports.assertTypeScriptSupport = void 0;
|
|
|
26
26
|
const os_1 = __importDefault(require("os"));
|
|
27
27
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
28
28
|
const semver = __importStar(require("semver"));
|
|
29
|
-
const type_script_vue_extension_support_1 = require("./extension/vue/type-script-vue-extension-support");
|
|
30
29
|
function assertTypeScriptSupport(config) {
|
|
31
30
|
let typescriptVersion;
|
|
32
31
|
try {
|
|
@@ -60,8 +59,5 @@ function assertTypeScriptSupport(config) {
|
|
|
60
59
|
' - wrong `typescript.configFile` path in the plugin configuration (should be a relative or absolute path)',
|
|
61
60
|
].join(os_1.default.EOL));
|
|
62
61
|
}
|
|
63
|
-
if (config.extensions.vue.enabled) {
|
|
64
|
-
(0, type_script_vue_extension_support_1.assertTypeScriptVueExtensionSupport)(config.extensions.vue);
|
|
65
|
-
}
|
|
66
62
|
}
|
|
67
63
|
exports.assertTypeScriptSupport = assertTypeScriptSupport;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type webpack from 'webpack';
|
|
2
|
-
import type { TypeScriptVueExtensionConfig } from './extension/vue/type-script-vue-extension-config';
|
|
3
2
|
import type { TypeScriptConfigOverwrite } from './type-script-config-overwrite';
|
|
4
3
|
import type { TypeScriptDiagnosticsOptions } from './type-script-diagnostics-options';
|
|
5
4
|
import type { TypeScriptWorkerOptions } from './type-script-worker-options';
|
|
@@ -12,9 +11,6 @@ interface TypeScriptWorkerConfig {
|
|
|
12
11
|
context: string;
|
|
13
12
|
mode: 'readonly' | 'write-dts' | 'write-tsbuildinfo' | 'write-references';
|
|
14
13
|
diagnosticOptions: TypeScriptDiagnosticsOptions;
|
|
15
|
-
extensions: {
|
|
16
|
-
vue: TypeScriptVueExtensionConfig;
|
|
17
|
-
};
|
|
18
14
|
profile: boolean;
|
|
19
15
|
typescriptPath: string;
|
|
20
16
|
}
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createTypeScriptWorkerConfig = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const type_script_vue_extension_config_1 = require("./extension/vue/type-script-vue-extension-config");
|
|
9
8
|
function createTypeScriptWorkerConfig(compiler, options) {
|
|
10
9
|
let configFile = typeof options === 'object' ? options.configFile || 'tsconfig.json' : 'tsconfig.json';
|
|
11
10
|
// ensure that `configFile` is an absolute normalized path
|
|
@@ -14,8 +13,6 @@ function createTypeScriptWorkerConfig(compiler, options) {
|
|
|
14
13
|
: path_1.default.resolve(compiler.options.context || process.cwd(), configFile));
|
|
15
14
|
const optionsAsObject = typeof options === 'object' ? options : {};
|
|
16
15
|
const typescriptPath = optionsAsObject.typescriptPath || require.resolve('typescript');
|
|
17
|
-
return Object.assign(Object.assign({ enabled: options !== false, memoryLimit: 2048, build: false, mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly', profile: false }, optionsAsObject), { configFile: configFile, configOverwrite: optionsAsObject.configOverwrite || {}, context: optionsAsObject.context || path_1.default.dirname(configFile),
|
|
18
|
-
vue: (0, type_script_vue_extension_config_1.createTypeScriptVueExtensionConfig)(optionsAsObject.extensions ? optionsAsObject.extensions.vue : undefined),
|
|
19
|
-
}, diagnosticOptions: Object.assign({ syntactic: false, semantic: true, declaration: false, global: false }, (optionsAsObject.diagnosticOptions || {})), typescriptPath: typescriptPath });
|
|
16
|
+
return Object.assign(Object.assign({ enabled: options !== false, memoryLimit: 2048, build: false, mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly', profile: false }, optionsAsObject), { configFile: configFile, configOverwrite: optionsAsObject.configOverwrite || {}, context: optionsAsObject.context || path_1.default.dirname(configFile), diagnosticOptions: Object.assign({ syntactic: false, semantic: true, declaration: false, global: false }, (optionsAsObject.diagnosticOptions || {})), typescriptPath: typescriptPath });
|
|
20
17
|
}
|
|
21
18
|
exports.createTypeScriptWorkerConfig = createTypeScriptWorkerConfig;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TypeScriptVueExtensionOptions } from './extension/vue/type-script-vue-extension-options';
|
|
2
1
|
import type { TypeScriptConfigOverwrite } from './type-script-config-overwrite';
|
|
3
2
|
import type { TypeScriptDiagnosticsOptions } from './type-script-diagnostics-options';
|
|
4
3
|
declare type TypeScriptWorkerOptions = {
|
|
@@ -9,9 +8,6 @@ declare type TypeScriptWorkerOptions = {
|
|
|
9
8
|
build?: boolean;
|
|
10
9
|
mode?: 'readonly' | 'write-tsbuildinfo' | 'write-dts' | 'write-references';
|
|
11
10
|
diagnosticOptions?: Partial<TypeScriptDiagnosticsOptions>;
|
|
12
|
-
extensions?: {
|
|
13
|
-
vue?: TypeScriptVueExtensionOptions;
|
|
14
|
-
};
|
|
15
11
|
profile?: boolean;
|
|
16
12
|
typescriptPath?: string;
|
|
17
13
|
};
|
|
@@ -23,21 +23,15 @@ exports.didRootFilesChanged = exports.didDependenciesProbablyChanged = exports.d
|
|
|
23
23
|
const path = __importStar(require("path"));
|
|
24
24
|
const forward_slash_1 = require("../../../utils/path/forward-slash");
|
|
25
25
|
const diagnostics_1 = require("./diagnostics");
|
|
26
|
-
const extensions_1 = require("./extensions");
|
|
27
26
|
const system_1 = require("./system");
|
|
28
27
|
const typescript_1 = require("./typescript");
|
|
29
28
|
const worker_config_1 = require("./worker-config");
|
|
30
29
|
let parsedConfig;
|
|
31
30
|
let parseConfigDiagnostics = [];
|
|
32
31
|
// initialize ParseConfigFileHost
|
|
33
|
-
|
|
32
|
+
const parseConfigFileHost = Object.assign(Object.assign({}, system_1.system), { onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
34
33
|
parseConfigDiagnostics.push(diagnostic);
|
|
35
34
|
} });
|
|
36
|
-
for (const extension of extensions_1.extensions) {
|
|
37
|
-
if (extension.extendParseConfigFileHost) {
|
|
38
|
-
parseConfigFileHost = extension.extendParseConfigFileHost(parseConfigFileHost);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
35
|
function getUserProvidedConfigOverwrite() {
|
|
42
36
|
return worker_config_1.config.configOverwrite || {};
|
|
43
37
|
}
|
|
@@ -22,7 +22,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.invalidateDependencies = exports.getDependencies = void 0;
|
|
23
23
|
const path = __importStar(require("path"));
|
|
24
24
|
const config_1 = require("./config");
|
|
25
|
-
const extensions_1 = require("./extensions");
|
|
26
25
|
const typescript_1 = require("./typescript");
|
|
27
26
|
const worker_config_1 = require("./worker-config");
|
|
28
27
|
let dependencies;
|
|
@@ -30,11 +29,6 @@ function getDependencies(force = false) {
|
|
|
30
29
|
if (!dependencies || force) {
|
|
31
30
|
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
32
31
|
dependencies = getDependenciesWorker(parsedConfig, worker_config_1.config.context);
|
|
33
|
-
for (const extension of extensions_1.extensions) {
|
|
34
|
-
if (extension.extendDependencies) {
|
|
35
|
-
dependencies = extension.extendDependencies(dependencies);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
32
|
}
|
|
39
33
|
return dependencies;
|
|
40
34
|
}
|
|
@@ -22,7 +22,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.createIssuesFromDiagnostics = exports.getDiagnosticsOfProgram = exports.invalidateDiagnostics = exports.getIssues = exports.updateDiagnostics = void 0;
|
|
23
23
|
const os = __importStar(require("os"));
|
|
24
24
|
const issue_1 = require("../../../issue");
|
|
25
|
-
const extensions_1 = require("./extensions");
|
|
26
25
|
const typescript_1 = require("./typescript");
|
|
27
26
|
const worker_config_1 = require("./worker-config");
|
|
28
27
|
const diagnosticsPerConfigFile = new Map();
|
|
@@ -89,12 +88,6 @@ function createIssueFromDiagnostic(diagnostic) {
|
|
|
89
88
|
};
|
|
90
89
|
}
|
|
91
90
|
function createIssuesFromDiagnostics(diagnostics) {
|
|
92
|
-
|
|
93
|
-
extensions_1.extensions.forEach((extension) => {
|
|
94
|
-
if (extension.extendIssues) {
|
|
95
|
-
issues = extension.extendIssues(issues);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return issues;
|
|
91
|
+
return (0, issue_1.deduplicateAndSortIssues)(diagnostics.map((diagnostic) => createIssueFromDiagnostic(diagnostic)));
|
|
99
92
|
}
|
|
100
93
|
exports.createIssuesFromDiagnostics = createIssuesFromDiagnostics;
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCompilerHost = void 0;
|
|
4
|
-
const extensions_1 = require("../extensions");
|
|
5
4
|
const system_1 = require("../system");
|
|
6
5
|
const typescript_1 = require("../typescript");
|
|
7
6
|
function createCompilerHost(parsedConfig) {
|
|
8
7
|
const baseCompilerHost = typescript_1.typescript.createCompilerHost(parsedConfig.options);
|
|
9
|
-
|
|
10
|
-
extensions_1.extensions.forEach((extension) => {
|
|
11
|
-
if (extension.extendCompilerHost) {
|
|
12
|
-
controlledCompilerHost = extension.extendCompilerHost(controlledCompilerHost, parsedConfig);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
return controlledCompilerHost;
|
|
8
|
+
return Object.assign(Object.assign({}, baseCompilerHost), { fileExists: system_1.system.fileExists, readFile: system_1.system.readFile, directoryExists: system_1.system.directoryExists, getDirectories: system_1.system.getDirectories, realpath: system_1.system.realpath });
|
|
16
9
|
}
|
|
17
10
|
exports.createCompilerHost = createCompilerHost;
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWatchCompilerHost = void 0;
|
|
4
|
-
const extensions_1 = require("../extensions");
|
|
5
4
|
const system_1 = require("../system");
|
|
6
5
|
const typescript_1 = require("../typescript");
|
|
7
6
|
function createWatchCompilerHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate) {
|
|
8
7
|
const baseWatchCompilerHost = typescript_1.typescript.createWatchCompilerHost(parsedConfig.fileNames, parsedConfig.options, system_1.system, createProgram, reportDiagnostic, reportWatchStatus, parsedConfig.projectReferences);
|
|
9
|
-
|
|
10
|
-
extensions_1.extensions.forEach((extension) => {
|
|
11
|
-
if (compilerHost && extension.extendCompilerHost) {
|
|
12
|
-
compilerHost = extension.extendCompilerHost(compilerHost, parsedConfig);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
8
|
+
return Object.assign(Object.assign({}, baseWatchCompilerHost), { createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences) {
|
|
15
9
|
return baseWatchCompilerHost.createProgram(rootNames, options, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
16
10
|
},
|
|
17
11
|
afterProgramCreate(program) {
|
|
@@ -22,11 +16,5 @@ function createWatchCompilerHost(parsedConfig, createProgram, reportDiagnostic,
|
|
|
22
16
|
onWatchStatusChange() {
|
|
23
17
|
// do nothing
|
|
24
18
|
}, watchFile: system_1.system.watchFile, watchDirectory: system_1.system.watchDirectory, setTimeout: system_1.system.setTimeout, clearTimeout: system_1.system.clearTimeout, fileExists: system_1.system.fileExists, readFile: system_1.system.readFile, directoryExists: system_1.system.directoryExists, getDirectories: system_1.system.getDirectories, realpath: system_1.system.realpath });
|
|
25
|
-
extensions_1.extensions.forEach((extension) => {
|
|
26
|
-
if (extension.extendWatchCompilerHost) {
|
|
27
|
-
controlledWatchCompilerHost = extension.extendWatchCompilerHost(controlledWatchCompilerHost, parsedConfig);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return controlledWatchCompilerHost;
|
|
31
19
|
}
|
|
32
20
|
exports.createWatchCompilerHost = createWatchCompilerHost;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWatchSolutionBuilderHost = void 0;
|
|
4
|
-
const extensions_1 = require("../extensions");
|
|
5
4
|
const system_1 = require("../system");
|
|
6
5
|
const typescript_1 = require("../typescript");
|
|
7
6
|
const watch_compiler_host_1 = require("./watch-compiler-host");
|
|
8
7
|
function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, reportSolutionBuilderStatus, afterProgramCreate, afterProgramEmitAndDiagnostics) {
|
|
9
8
|
const controlledWatchCompilerHost = (0, watch_compiler_host_1.createWatchCompilerHost)(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate);
|
|
10
|
-
|
|
9
|
+
return Object.assign(Object.assign({}, controlledWatchCompilerHost), { reportDiagnostic(diagnostic) {
|
|
11
10
|
if (reportDiagnostic) {
|
|
12
11
|
reportDiagnostic(diagnostic);
|
|
13
12
|
}
|
|
@@ -44,11 +43,5 @@ function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagn
|
|
|
44
43
|
}
|
|
45
44
|
} }));
|
|
46
45
|
} });
|
|
47
|
-
extensions_1.extensions.forEach((extension) => {
|
|
48
|
-
if (extension.extendWatchSolutionBuilderHost) {
|
|
49
|
-
controlledWatchSolutionBuilderHost = extension.extendWatchSolutionBuilderHost(controlledWatchSolutionBuilderHost, parsedConfig);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return controlledWatchSolutionBuilderHost;
|
|
53
46
|
}
|
|
54
47
|
exports.createWatchSolutionBuilderHost = createWatchSolutionBuilderHost;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isInsideAnotherPath = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
function isInsideAnotherPath(parent, directory) {
|
|
6
|
+
const relativePart = (0, path_1.relative)(parent, directory);
|
|
7
|
+
// Tested folder is above parent.
|
|
8
|
+
if (relativePart.startsWith('..')) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
// Tested folder is the same as parent.
|
|
12
|
+
if (relativePart.length === 0) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
// Tested directory has nothing in common with parent.
|
|
16
|
+
if ((0, path_1.isAbsolute)(relativePart)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
// Last option, must be subfolder.
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
exports.isInsideAnotherPath = isInsideAnotherPath;
|
|
@@ -9,6 +9,7 @@ const chokidar_1 = __importDefault(require("chokidar"));
|
|
|
9
9
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
10
10
|
const files_change_1 = require("../files-change");
|
|
11
11
|
const infrastructure_logger_1 = require("../infrastructure-logger");
|
|
12
|
+
const is_inside_another_path_1 = require("../utils/path/is-inside-another-path");
|
|
12
13
|
const BUILTIN_IGNORED_DIRS = ['.git'];
|
|
13
14
|
function createIsIgnored(ignored, excluded) {
|
|
14
15
|
const ignoredPatterns = ignored ? (Array.isArray(ignored) ? ignored : [ignored]) : [];
|
|
@@ -25,7 +26,7 @@ function createIsIgnored(ignored, excluded) {
|
|
|
25
26
|
return () => false;
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
|
-
ignoredFunctions.push((path) => excluded.some((excludedPath) =>
|
|
29
|
+
ignoredFunctions.push((path) => excluded.some((excludedPath) => (0, is_inside_another_path_1.isInsideAnotherPath)(excludedPath, path)));
|
|
29
30
|
ignoredFunctions.push((path) => BUILTIN_IGNORED_DIRS.some((ignoredDir) => path.includes(`/${ignoredDir}/`) || path.includes(`\\${ignoredDir}\\`)));
|
|
30
31
|
return function isIgnored(path) {
|
|
31
32
|
return ignoredFunctions.some((ignoredFunction) => ignoredFunction(path));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fork-ts-checker-webpack-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Runs typescript type checker and linter on separate process.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -70,14 +70,8 @@
|
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"typescript": ">3.6.0",
|
|
73
|
-
"vue-template-compiler": "*",
|
|
74
73
|
"webpack": "^5.11.0"
|
|
75
74
|
},
|
|
76
|
-
"peerDependenciesMeta": {
|
|
77
|
-
"vue-template-compiler": {
|
|
78
|
-
"optional": true
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
75
|
"devDependencies": {
|
|
82
76
|
"@commitlint/config-conventional": "^16.0.0",
|
|
83
77
|
"@semantic-release/commit-analyzer": "^8.0.1",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { TypeScriptExtension } from './type-script-extension';
|
|
2
|
-
interface TypeScriptEmbeddedSource {
|
|
3
|
-
sourceText: string;
|
|
4
|
-
extension: '.ts' | '.tsx' | '.js';
|
|
5
|
-
}
|
|
6
|
-
interface TypeScriptEmbeddedExtensionHost {
|
|
7
|
-
embeddedExtensions: string[];
|
|
8
|
-
getEmbeddedSource(fileName: string): TypeScriptEmbeddedSource | undefined;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* It handles most of the logic required to process embedded TypeScript code (like in Vue components or MDX)
|
|
12
|
-
*
|
|
13
|
-
* @param embeddedExtensions List of file extensions that should be treated as an embedded TypeScript source
|
|
14
|
-
* (for example ['.vue'])
|
|
15
|
-
* @param getEmbeddedSource Function that returns embedded TypeScript source text and extension that this file
|
|
16
|
-
* would have if it would be a regular TypeScript file
|
|
17
|
-
*/
|
|
18
|
-
declare function createTypeScriptEmbeddedExtension({ embeddedExtensions, getEmbeddedSource, }: TypeScriptEmbeddedExtensionHost): TypeScriptExtension;
|
|
19
|
-
export { TypeScriptEmbeddedExtensionHost, TypeScriptEmbeddedSource, createTypeScriptEmbeddedExtension, };
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTypeScriptEmbeddedExtension = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
/**
|
|
6
|
-
* It handles most of the logic required to process embedded TypeScript code (like in Vue components or MDX)
|
|
7
|
-
*
|
|
8
|
-
* @param embeddedExtensions List of file extensions that should be treated as an embedded TypeScript source
|
|
9
|
-
* (for example ['.vue'])
|
|
10
|
-
* @param getEmbeddedSource Function that returns embedded TypeScript source text and extension that this file
|
|
11
|
-
* would have if it would be a regular TypeScript file
|
|
12
|
-
*/
|
|
13
|
-
function createTypeScriptEmbeddedExtension({ embeddedExtensions, getEmbeddedSource, }) {
|
|
14
|
-
const embeddedSourceCache = new Map();
|
|
15
|
-
function getCachedEmbeddedSource(fileName) {
|
|
16
|
-
if (!embeddedSourceCache.has(fileName)) {
|
|
17
|
-
embeddedSourceCache.set(fileName, getEmbeddedSource(fileName));
|
|
18
|
-
}
|
|
19
|
-
return embeddedSourceCache.get(fileName);
|
|
20
|
-
}
|
|
21
|
-
function parsePotentiallyEmbeddedFileName(fileName) {
|
|
22
|
-
const extension = (0, path_1.extname)(fileName);
|
|
23
|
-
const embeddedFileName = fileName.slice(0, fileName.length - extension.length);
|
|
24
|
-
const embeddedExtension = (0, path_1.extname)(embeddedFileName);
|
|
25
|
-
return {
|
|
26
|
-
extension,
|
|
27
|
-
embeddedFileName,
|
|
28
|
-
embeddedExtension,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function createEmbeddedFileExists(fileExists) {
|
|
32
|
-
return function embeddedFileExists(fileName) {
|
|
33
|
-
const { embeddedExtension, embeddedFileName, extension } = parsePotentiallyEmbeddedFileName(fileName);
|
|
34
|
-
if (embeddedExtensions.includes(embeddedExtension) && fileExists(embeddedFileName)) {
|
|
35
|
-
const embeddedSource = getCachedEmbeddedSource(embeddedFileName);
|
|
36
|
-
return !!(embeddedSource && embeddedSource.extension === extension);
|
|
37
|
-
}
|
|
38
|
-
return fileExists(fileName);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function createEmbeddedReadFile(readFile) {
|
|
42
|
-
return function embeddedReadFile(fileName, encoding) {
|
|
43
|
-
const { embeddedExtension, embeddedFileName, extension } = parsePotentiallyEmbeddedFileName(fileName);
|
|
44
|
-
if (embeddedExtensions.includes(embeddedExtension)) {
|
|
45
|
-
const embeddedSource = getCachedEmbeddedSource(embeddedFileName);
|
|
46
|
-
if (embeddedSource && embeddedSource.extension === extension) {
|
|
47
|
-
return embeddedSource.sourceText;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return readFile(fileName, encoding);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
extendIssues(issues) {
|
|
55
|
-
return issues.map((issue) => {
|
|
56
|
-
if (issue.file) {
|
|
57
|
-
const { embeddedExtension, embeddedFileName } = parsePotentiallyEmbeddedFileName(issue.file);
|
|
58
|
-
if (embeddedExtensions.includes(embeddedExtension)) {
|
|
59
|
-
return Object.assign(Object.assign({}, issue), { file: embeddedFileName });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return issue;
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
extendWatchCompilerHost(host) {
|
|
66
|
-
return Object.assign(Object.assign({}, host), { watchFile(fileName, callback, poolingInterval) {
|
|
67
|
-
const { embeddedExtension, embeddedFileName } = parsePotentiallyEmbeddedFileName(fileName);
|
|
68
|
-
if (embeddedExtensions.includes(embeddedExtension)) {
|
|
69
|
-
return host.watchFile(embeddedFileName, (innerFileName, eventKind) => {
|
|
70
|
-
embeddedSourceCache.delete(embeddedFileName);
|
|
71
|
-
return callback(fileName, eventKind);
|
|
72
|
-
}, poolingInterval);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return host.watchFile(fileName, callback, poolingInterval);
|
|
76
|
-
}
|
|
77
|
-
}, readFile: createEmbeddedReadFile(host.readFile), fileExists: createEmbeddedFileExists(host.fileExists) });
|
|
78
|
-
},
|
|
79
|
-
extendCompilerHost(host) {
|
|
80
|
-
return Object.assign(Object.assign({}, host), { readFile: createEmbeddedReadFile(host.readFile), fileExists: createEmbeddedFileExists(host.fileExists) });
|
|
81
|
-
},
|
|
82
|
-
extendParseConfigFileHost(host) {
|
|
83
|
-
return Object.assign(Object.assign({}, host), { readDirectory(rootDir, extensions, excludes, includes, depth) {
|
|
84
|
-
return host
|
|
85
|
-
.readDirectory(rootDir, [...extensions, ...embeddedExtensions], excludes, includes, depth)
|
|
86
|
-
.map((fileName) => {
|
|
87
|
-
const isEmbeddedFile = embeddedExtensions.some((embeddedExtension) => fileName.endsWith(embeddedExtension));
|
|
88
|
-
if (isEmbeddedFile) {
|
|
89
|
-
const embeddedSource = getCachedEmbeddedSource(fileName);
|
|
90
|
-
return embeddedSource ? `${fileName}${embeddedSource.extension}` : fileName;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
return fileName;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
} });
|
|
97
|
-
},
|
|
98
|
-
extendDependencies(dependencies) {
|
|
99
|
-
return Object.assign(Object.assign({}, dependencies), { files: dependencies.files.map((fileName) => {
|
|
100
|
-
const { embeddedExtension, embeddedFileName, extension } = parsePotentiallyEmbeddedFileName(fileName);
|
|
101
|
-
if (embeddedExtensions.includes(embeddedExtension)) {
|
|
102
|
-
const embeddedSource = getCachedEmbeddedSource(embeddedFileName);
|
|
103
|
-
if (embeddedSource && embeddedSource.extension === extension) {
|
|
104
|
-
return embeddedFileName;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return fileName;
|
|
108
|
-
}), extensions: [...dependencies.extensions, ...embeddedExtensions] });
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
exports.createTypeScriptEmbeddedExtension = createTypeScriptEmbeddedExtension;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript';
|
|
2
|
-
import type { FilesMatch } from '../../files-match';
|
|
3
|
-
import type { Issue } from '../../issue';
|
|
4
|
-
interface TypeScriptHostExtension {
|
|
5
|
-
extendWatchSolutionBuilderHost?<TProgram extends ts.BuilderProgram, THost extends ts.SolutionBuilderWithWatchHost<TProgram>>(host: THost, parsedCommandLine?: ts.ParsedCommandLine): THost;
|
|
6
|
-
extendWatchCompilerHost?<TProgram extends ts.BuilderProgram, THost extends ts.WatchCompilerHost<TProgram>>(host: THost, parsedCommandLine?: ts.ParsedCommandLine): THost;
|
|
7
|
-
extendCompilerHost?<THost extends ts.CompilerHost>(host: THost, parsedCommandLine?: ts.ParsedCommandLine): THost;
|
|
8
|
-
extendParseConfigFileHost?<THost extends ts.ParseConfigFileHost>(host: THost): THost;
|
|
9
|
-
}
|
|
10
|
-
interface TypeScriptReporterExtension {
|
|
11
|
-
extendIssues?(issues: Issue[]): Issue[];
|
|
12
|
-
extendDependencies?(dependencies: FilesMatch): FilesMatch;
|
|
13
|
-
}
|
|
14
|
-
interface TypeScriptExtension extends TypeScriptHostExtension, TypeScriptReporterExtension {
|
|
15
|
-
}
|
|
16
|
-
export { TypeScriptExtension, TypeScriptReporterExtension, TypeScriptHostExtension };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { TypeScriptVueExtensionOptions } from './type-script-vue-extension-options';
|
|
2
|
-
interface TypeScriptVueExtensionConfig {
|
|
3
|
-
enabled: boolean;
|
|
4
|
-
compiler: string;
|
|
5
|
-
}
|
|
6
|
-
declare function createTypeScriptVueExtensionConfig(options: TypeScriptVueExtensionOptions | undefined): TypeScriptVueExtensionConfig;
|
|
7
|
-
export { TypeScriptVueExtensionConfig, createTypeScriptVueExtensionConfig };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTypeScriptVueExtensionConfig = void 0;
|
|
4
|
-
function createTypeScriptVueExtensionConfig(options) {
|
|
5
|
-
return Object.assign({ enabled: options === true, compiler: 'vue-template-compiler' }, (typeof options === 'object' ? options : {}));
|
|
6
|
-
}
|
|
7
|
-
exports.createTypeScriptVueExtensionConfig = createTypeScriptVueExtensionConfig;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertTypeScriptVueExtensionSupport = void 0;
|
|
4
|
-
function assertTypeScriptVueExtensionSupport(config) {
|
|
5
|
-
// We need to import template compiler for vue lazily because it cannot be included it
|
|
6
|
-
// as direct dependency because it is an optional dependency of fork-ts-checker-webpack-plugin.
|
|
7
|
-
// Since its version must not mismatch with user-installed Vue.js,
|
|
8
|
-
// we should let the users install template compiler for vue by themselves.
|
|
9
|
-
const compilerName = config.compiler;
|
|
10
|
-
try {
|
|
11
|
-
require(compilerName);
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
throw new Error([
|
|
15
|
-
`Could not initialize '${compilerName}'. When you use 'typescript.extensions.vue' option, make sure to install '${compilerName}' and that the version matches that of 'vue'.`,
|
|
16
|
-
`Error details: ${String(error)}`,
|
|
17
|
-
].join('\n'));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.assertTypeScriptVueExtensionSupport = assertTypeScriptVueExtensionSupport;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TypeScriptExtension } from '../type-script-extension';
|
|
2
|
-
import type { TypeScriptVueExtensionConfig } from './type-script-vue-extension-config';
|
|
3
|
-
declare function createTypeScriptVueExtension(config: TypeScriptVueExtensionConfig): TypeScriptExtension;
|
|
4
|
-
export { createTypeScriptVueExtension };
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createTypeScriptVueExtension = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const type_script_embedded_extension_1 = require("../type-script-embedded-extension");
|
|
9
|
-
function createTypeScriptVueExtension(config) {
|
|
10
|
-
function loadVueTemplateCompiler() {
|
|
11
|
-
return require(config.compiler);
|
|
12
|
-
}
|
|
13
|
-
function isVueTemplateCompilerV2(compiler) {
|
|
14
|
-
return typeof compiler.parseComponent === 'function';
|
|
15
|
-
}
|
|
16
|
-
function isVueTemplateCompilerV3(compiler) {
|
|
17
|
-
return typeof compiler.parse === 'function';
|
|
18
|
-
}
|
|
19
|
-
function getExtensionByLang(lang) {
|
|
20
|
-
if (lang === true) {
|
|
21
|
-
return '.js';
|
|
22
|
-
}
|
|
23
|
-
switch (lang) {
|
|
24
|
-
case 'ts':
|
|
25
|
-
return '.ts';
|
|
26
|
-
case 'tsx':
|
|
27
|
-
return '.tsx';
|
|
28
|
-
case 'js':
|
|
29
|
-
case 'jsx':
|
|
30
|
-
default:
|
|
31
|
-
return '.js';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function createVueNoScriptEmbeddedSource() {
|
|
35
|
-
return {
|
|
36
|
-
sourceText: 'export default {};\n',
|
|
37
|
-
extension: '.js',
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function createVueSrcScriptEmbeddedSource(src, lang) {
|
|
41
|
-
// Import path cannot be end with '.ts[x]'
|
|
42
|
-
src = src.replace(/\.tsx?$/i, '');
|
|
43
|
-
// For now, ignore the error when the src file is not found since it will produce incorrect code location.
|
|
44
|
-
// It's not a large problem since it's handled on webpack side.
|
|
45
|
-
const text = [
|
|
46
|
-
'// @ts-ignore',
|
|
47
|
-
`export { default } from '${src}';`,
|
|
48
|
-
'// @ts-ignore',
|
|
49
|
-
`export * from '${src}';`,
|
|
50
|
-
].join('\n');
|
|
51
|
-
return {
|
|
52
|
-
sourceText: text,
|
|
53
|
-
extension: getExtensionByLang(lang),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function createVueInlineScriptEmbeddedSource(text, lang) {
|
|
57
|
-
return {
|
|
58
|
-
sourceText: text,
|
|
59
|
-
extension: getExtensionByLang(lang),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function getVueEmbeddedSource(fileName) {
|
|
63
|
-
if (!fs_extra_1.default.existsSync(fileName)) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
const compiler = loadVueTemplateCompiler();
|
|
67
|
-
const vueSourceText = fs_extra_1.default.readFileSync(fileName, { encoding: 'utf-8' });
|
|
68
|
-
let script;
|
|
69
|
-
if (isVueTemplateCompilerV2(compiler)) {
|
|
70
|
-
const parsed = compiler.parseComponent(vueSourceText, {
|
|
71
|
-
pad: 'space',
|
|
72
|
-
});
|
|
73
|
-
script = parsed.script;
|
|
74
|
-
}
|
|
75
|
-
else if (isVueTemplateCompilerV3(compiler)) {
|
|
76
|
-
const parsed = compiler.parse(vueSourceText);
|
|
77
|
-
if (parsed.descriptor && parsed.descriptor.script) {
|
|
78
|
-
const scriptV3 = parsed.descriptor.script;
|
|
79
|
-
// map newer version of SFCScriptBlock to the generic one
|
|
80
|
-
script = {
|
|
81
|
-
content: scriptV3.content,
|
|
82
|
-
attrs: scriptV3.attrs,
|
|
83
|
-
start: scriptV3.loc.start.offset,
|
|
84
|
-
end: scriptV3.loc.end.offset,
|
|
85
|
-
lang: scriptV3.lang,
|
|
86
|
-
src: scriptV3.src,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
throw new Error('Unsupported vue template compiler. Compiler should provide `parse` or `parseComponent` function.');
|
|
92
|
-
}
|
|
93
|
-
if (!script) {
|
|
94
|
-
// No <script> block
|
|
95
|
-
return createVueNoScriptEmbeddedSource();
|
|
96
|
-
}
|
|
97
|
-
else if (script.attrs.src) {
|
|
98
|
-
// <script src="file.ts" /> block
|
|
99
|
-
if (typeof script.attrs.src === 'string') {
|
|
100
|
-
return createVueSrcScriptEmbeddedSource(script.attrs.src, script.attrs.lang);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
// <script lang="ts"></script> block
|
|
105
|
-
// pad blank lines to retain diagnostics location
|
|
106
|
-
const lineOffset = vueSourceText.slice(0, script.start).split(/\r?\n/g).length;
|
|
107
|
-
const paddedSourceText = Array(lineOffset).join('\n') + vueSourceText.slice(script.start, script.end);
|
|
108
|
-
return createVueInlineScriptEmbeddedSource(paddedSourceText, script.attrs.lang);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return (0, type_script_embedded_extension_1.createTypeScriptEmbeddedExtension)({
|
|
112
|
-
embeddedExtensions: ['.vue'],
|
|
113
|
-
getEmbeddedSource: getVueEmbeddedSource,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
exports.createTypeScriptVueExtension = createTypeScriptVueExtension;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This declaration is copied from https://github.com/vuejs/vue/pull/7918
|
|
3
|
-
* which may included vue-template-compiler v2.6.0.
|
|
4
|
-
*/
|
|
5
|
-
interface SFCParserOptionsV2 {
|
|
6
|
-
pad?: true | 'line' | 'space';
|
|
7
|
-
}
|
|
8
|
-
export interface SFCBlockV2 {
|
|
9
|
-
type: string;
|
|
10
|
-
content: string;
|
|
11
|
-
attrs: Record<string, string>;
|
|
12
|
-
start?: number;
|
|
13
|
-
end?: number;
|
|
14
|
-
lang?: string;
|
|
15
|
-
src?: string;
|
|
16
|
-
scoped?: boolean;
|
|
17
|
-
module?: string | boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface SFCDescriptorV2 {
|
|
20
|
-
template: SFCBlockV2 | undefined;
|
|
21
|
-
script: SFCBlockV2 | undefined;
|
|
22
|
-
styles: SFCBlockV2[];
|
|
23
|
-
customBlocks: SFCBlockV2[];
|
|
24
|
-
}
|
|
25
|
-
export interface VueTemplateCompilerV2 {
|
|
26
|
-
parseComponent(file: string, options?: SFCParserOptionsV2): SFCDescriptorV2;
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
interface Position {
|
|
2
|
-
offset: number;
|
|
3
|
-
line: number;
|
|
4
|
-
column: number;
|
|
5
|
-
}
|
|
6
|
-
interface SourceLocation {
|
|
7
|
-
start: Position;
|
|
8
|
-
end: Position;
|
|
9
|
-
source: string;
|
|
10
|
-
}
|
|
11
|
-
export interface SFCBlock {
|
|
12
|
-
type: string;
|
|
13
|
-
content: string;
|
|
14
|
-
attrs: Record<string, string | true>;
|
|
15
|
-
loc: SourceLocation;
|
|
16
|
-
lang?: string;
|
|
17
|
-
src?: string;
|
|
18
|
-
}
|
|
19
|
-
interface SFCDescriptor {
|
|
20
|
-
filename: string;
|
|
21
|
-
template: SFCBlock | null;
|
|
22
|
-
script: SFCBlock | null;
|
|
23
|
-
styles: SFCBlock[];
|
|
24
|
-
customBlocks: SFCBlock[];
|
|
25
|
-
}
|
|
26
|
-
interface CompilerError extends SyntaxError {
|
|
27
|
-
code: number;
|
|
28
|
-
loc?: SourceLocation;
|
|
29
|
-
}
|
|
30
|
-
interface SFCParseResult {
|
|
31
|
-
descriptor: SFCDescriptor;
|
|
32
|
-
errors: CompilerError[];
|
|
33
|
-
}
|
|
34
|
-
export interface VueTemplateCompilerV3 {
|
|
35
|
-
parse(template: string, options?: any): SFCParseResult;
|
|
36
|
-
}
|
|
37
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a, _b;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.extensions = void 0;
|
|
5
|
-
const type_script_vue_extension_1 = require("../../extension/vue/type-script-vue-extension");
|
|
6
|
-
const worker_config_1 = require("./worker-config");
|
|
7
|
-
const extensions = [];
|
|
8
|
-
exports.extensions = extensions;
|
|
9
|
-
if ((_b = (_a = worker_config_1.config.extensions) === null || _a === void 0 ? void 0 : _a.vue) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
10
|
-
extensions.push((0, type_script_vue_extension_1.createTypeScriptVueExtension)(worker_config_1.config.extensions.vue));
|
|
11
|
-
}
|