fork-ts-checker-webpack-plugin 6.4.0 → 6.4.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.
|
@@ -76,7 +76,7 @@ exports.ForkTsCheckerWebpackPlugin = ForkTsCheckerWebpackPlugin;
|
|
|
76
76
|
/**
|
|
77
77
|
* Current version of the plugin
|
|
78
78
|
*/
|
|
79
|
-
ForkTsCheckerWebpackPlugin.version = '6.4.
|
|
79
|
+
ForkTsCheckerWebpackPlugin.version = '6.4.1'; // will be replaced by the @semantic-release/exec
|
|
80
80
|
/**
|
|
81
81
|
* Default pools for the plugin concurrency limit
|
|
82
82
|
*/
|
|
@@ -58,6 +58,17 @@ 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
|
+
}
|
|
61
72
|
function getVueEmbeddedSource(fileName) {
|
|
62
73
|
if (!fs_extra_1.default.existsSync(fileName)) {
|
|
63
74
|
return undefined;
|
|
@@ -67,23 +78,37 @@ function createTypeScriptVueExtension(configuration) {
|
|
|
67
78
|
let script;
|
|
68
79
|
if (isVueTemplateCompilerV2(compiler)) {
|
|
69
80
|
const parsed = compiler.parseComponent(vueSourceText, {
|
|
70
|
-
pad: '
|
|
81
|
+
pad: 'line',
|
|
71
82
|
});
|
|
72
83
|
script = parsed.script;
|
|
73
84
|
}
|
|
74
85
|
else if (isVueTemplateCompilerV3(compiler)) {
|
|
75
|
-
const parsed = compiler.parse(vueSourceText
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
+
}
|
|
87
112
|
}
|
|
88
113
|
}
|
|
89
114
|
else {
|
|
@@ -101,10 +126,7 @@ function createTypeScriptVueExtension(configuration) {
|
|
|
101
126
|
}
|
|
102
127
|
else {
|
|
103
128
|
// <script lang="ts"></script> block
|
|
104
|
-
|
|
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);
|
|
129
|
+
return createVueInlineScriptEmbeddedSource(script.content, script.attrs.lang);
|
|
108
130
|
}
|
|
109
131
|
}
|
|
110
132
|
return TypeScriptEmbeddedExtension_1.createTypeScriptEmbeddedExtension({
|
|
@@ -20,6 +20,7 @@ interface SFCDescriptor {
|
|
|
20
20
|
filename: string;
|
|
21
21
|
template: SFCBlock | null;
|
|
22
22
|
script: SFCBlock | null;
|
|
23
|
+
scriptSetup: SFCBlock | null;
|
|
23
24
|
styles: SFCBlock[];
|
|
24
25
|
customBlocks: SFCBlock[];
|
|
25
26
|
}
|
|
@@ -31,7 +32,10 @@ interface SFCParseResult {
|
|
|
31
32
|
descriptor: SFCDescriptor;
|
|
32
33
|
errors: CompilerError[];
|
|
33
34
|
}
|
|
35
|
+
interface SFCParserOptionsV3 {
|
|
36
|
+
pad?: true | 'line' | 'space';
|
|
37
|
+
}
|
|
34
38
|
export interface VueTemplateCompilerV3 {
|
|
35
|
-
parse(template: string, options?:
|
|
39
|
+
parse(template: string, options?: SFCParserOptionsV3): SFCParseResult;
|
|
36
40
|
}
|
|
37
41
|
export {};
|