@vue/language-core 2.0.6 → 2.0.10

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.
@@ -43,6 +43,7 @@ export declare function parseScriptSetupRanges(ts: typeof import('typescript'),
43
43
  name: TextRange | undefined;
44
44
  nameIsString: boolean;
45
45
  type: TextRange | undefined;
46
+ modifierType?: TextRange | undefined;
46
47
  defaultValue: TextRange | undefined;
47
48
  required: boolean;
48
49
  isModel?: boolean | undefined;
@@ -87,6 +87,7 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
87
87
  name,
88
88
  nameIsString: true,
89
89
  type: node.typeArguments?.length ? _getStartEnd(node.typeArguments[0]) : undefined,
90
+ modifierType: node.typeArguments && node.typeArguments?.length >= 2 ? _getStartEnd(node.typeArguments[1]) : undefined,
90
91
  defaultValue: undefined,
91
92
  required,
92
93
  isModel: true,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const parseSfc_1 = require("../utils/parseSfc");
4
- const plugin = (_ctx) => {
4
+ const plugin = _ctx => {
5
5
  return {
6
6
  version: 2,
7
7
  parseSFC(_fileName, content) {
@@ -5,21 +5,47 @@ const plugin = () => {
5
5
  return {
6
6
  version: 2,
7
7
  getEmbeddedCodes(_fileName, sfc) {
8
- return sfc.styles.map((style, i) => ({
9
- id: 'style_' + i,
10
- lang: style.lang,
11
- }));
8
+ const result = [];
9
+ for (let i = 0; i < sfc.styles.length; i++) {
10
+ const style = sfc.styles[i];
11
+ if (style) {
12
+ result.push({
13
+ id: 'style_' + i,
14
+ lang: style.lang,
15
+ });
16
+ if (style.cssVars.length) {
17
+ result.push({
18
+ id: 'style_' + i + '_inline_ts',
19
+ lang: 'ts',
20
+ });
21
+ }
22
+ }
23
+ }
24
+ return result;
12
25
  },
13
26
  resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
14
27
  if (embeddedFile.id.startsWith('style_')) {
15
- const index = parseInt(embeddedFile.id.slice('style_'.length));
28
+ const index = parseInt(embeddedFile.id.split('_')[1]);
16
29
  const style = sfc.styles[index];
17
- embeddedFile.content.push([
18
- style.content,
19
- style.name,
20
- 0,
21
- (0, utils_1.enableAllFeatures)({}),
22
- ]);
30
+ if (embeddedFile.id.endsWith('_inline_ts')) {
31
+ embeddedFile.parentCodeId = 'style_' + index;
32
+ for (const cssVar of style.cssVars) {
33
+ embeddedFile.content.push('(', [
34
+ cssVar.text,
35
+ style.name,
36
+ cssVar.offset,
37
+ (0, utils_1.enableAllFeatures)({}),
38
+ ], ');\n');
39
+ }
40
+ }
41
+ else {
42
+ embeddedFile.content.push([
43
+ style.content,
44
+ style.name,
45
+ 0,
46
+ (0, utils_1.enableAllFeatures)({}),
47
+ ]);
48
+ }
23
49
  }
24
50
  },
25
51
  };
@@ -0,0 +1,3 @@
1
+ import type { VueLanguagePlugin } from '../types';
2
+ declare const plugin: VueLanguagePlugin;
3
+ export default plugin;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const inlineCss_1 = require("../generators/inlineCss");
4
+ const plugin = () => {
5
+ return {
6
+ version: 2,
7
+ getEmbeddedCodes(_fileName, sfc) {
8
+ if (!sfc.template?.ast) {
9
+ return [];
10
+ }
11
+ return [{ id: 'template_inline_css', lang: 'css' }];
12
+ },
13
+ resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
14
+ if (embeddedFile.id !== 'template_inline_css' || !sfc.template?.ast) {
15
+ return;
16
+ }
17
+ embeddedFile.parentCodeId = 'template';
18
+ embeddedFile.content.push(...(0, inlineCss_1.generate)(sfc.template.ast));
19
+ },
20
+ };
21
+ };
22
+ exports.default = plugin;
23
+ //# sourceMappingURL=vue-template-inline-css.js.map
@@ -0,0 +1,3 @@
1
+ import type { VueLanguagePlugin } from '../types';
2
+ declare const plugin: VueLanguagePlugin;
3
+ export default plugin;
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const template_1 = require("../generators/template");
4
+ const utils_1 = require("../generators/utils");
5
+ const CompilerDOM = require("@vue/compiler-dom");
6
+ const codeFeatures = (0, utils_1.disableAllFeatures)({
7
+ format: true,
8
+ // autoInserts: true, // TODO: support vue-autoinsert-parentheses
9
+ });
10
+ const formatBrackets = {
11
+ normal: ['`${', '}`;'],
12
+ if: ['if (', ') { }'],
13
+ for: ['for (', ') { }'],
14
+ // fix https://github.com/vuejs/language-tools/issues/3572
15
+ params: ['(', ') => {};'],
16
+ // fix https://github.com/vuejs/language-tools/issues/1210
17
+ // fix https://github.com/vuejs/language-tools/issues/2305
18
+ curly: ['0 +', '+ 0;'],
19
+ event: ['() => ', ';'],
20
+ };
21
+ const plugin = ctx => {
22
+ const parseds = new WeakMap();
23
+ return {
24
+ version: 2,
25
+ getEmbeddedCodes(_fileName, sfc) {
26
+ if (!sfc.template?.ast) {
27
+ return [];
28
+ }
29
+ const parsed = parse(sfc);
30
+ parseds.set(sfc, parsed);
31
+ const result = [];
32
+ for (const [id] of parsed) {
33
+ result.push({ id, lang: 'ts' });
34
+ }
35
+ return result;
36
+ },
37
+ resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
38
+ // access template content to watch change
39
+ (() => sfc.template?.content)();
40
+ const parsed = parseds.get(sfc);
41
+ if (parsed) {
42
+ const codes = parsed.get(embeddedFile.id);
43
+ if (codes) {
44
+ embeddedFile.content.push(...codes);
45
+ embeddedFile.parentCodeId = 'template';
46
+ }
47
+ }
48
+ },
49
+ };
50
+ function parse(sfc) {
51
+ const data = new Map();
52
+ if (!sfc.template?.ast) {
53
+ return data;
54
+ }
55
+ const templateContent = sfc.template.content;
56
+ let i = 0;
57
+ sfc.template.ast.children.forEach(visit);
58
+ return data;
59
+ function visit(node) {
60
+ if (node.type === CompilerDOM.NodeTypes.ELEMENT) {
61
+ for (const prop of node.props) {
62
+ if (prop.type !== CompilerDOM.NodeTypes.DIRECTIVE) {
63
+ continue;
64
+ }
65
+ const isShorthand = prop.arg?.loc.start.offset === prop.exp?.loc.start.offset; // vue 3.4+
66
+ if (isShorthand) {
67
+ continue;
68
+ }
69
+ if (prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && !prop.arg.isStatic) {
70
+ addFormatCodes(prop.arg.content, prop.arg.loc.start.offset, formatBrackets.normal);
71
+ }
72
+ if (prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
73
+ && prop.exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY // style='z-index: 2' will compile to {'z-index':'2'}
74
+ ) {
75
+ if (prop.name === 'on') {
76
+ const ast = (0, template_1.createTsAst)(ctx.modules.typescript, prop.exp, prop.exp.content);
77
+ addFormatCodes(prop.exp.content, prop.exp.loc.start.offset, (0, template_1.isCompoundExpression)(ctx.modules.typescript, ast)
78
+ ? formatBrackets.event
79
+ : formatBrackets.normal);
80
+ }
81
+ else {
82
+ addFormatCodes(prop.exp.content, prop.exp.loc.start.offset, formatBrackets.normal);
83
+ }
84
+ }
85
+ }
86
+ for (const child of node.children) {
87
+ visit(child);
88
+ }
89
+ }
90
+ else if (node.type === CompilerDOM.NodeTypes.IF) {
91
+ for (let i = 0; i < node.branches.length; i++) {
92
+ const branch = node.branches[i];
93
+ if (branch.condition?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
94
+ addFormatCodes(branch.condition.content, branch.condition.loc.start.offset, formatBrackets.if);
95
+ }
96
+ for (const childNode of branch.children) {
97
+ visit(childNode);
98
+ }
99
+ }
100
+ }
101
+ else if (node.type === CompilerDOM.NodeTypes.FOR) {
102
+ const { leftExpressionRange, leftExpressionText } = (0, template_1.parseVForNode)(node);
103
+ const { source } = node.parseResult;
104
+ if (leftExpressionRange && leftExpressionText && source.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
105
+ const start = leftExpressionRange.start;
106
+ const end = source.loc.start.offset + source.content.length;
107
+ addFormatCodes(templateContent.substring(start, end), start, formatBrackets.for);
108
+ }
109
+ for (const child of node.children) {
110
+ visit(child);
111
+ }
112
+ }
113
+ else if (node.type === CompilerDOM.NodeTypes.TEXT_CALL) {
114
+ // {{ var }}
115
+ visit(node.content);
116
+ }
117
+ else if (node.type === CompilerDOM.NodeTypes.COMPOUND_EXPRESSION) {
118
+ // {{ ... }} {{ ... }}
119
+ for (const childNode of node.children) {
120
+ if (typeof childNode === 'object') {
121
+ visit(childNode);
122
+ }
123
+ }
124
+ }
125
+ else if (node.type === CompilerDOM.NodeTypes.INTERPOLATION) {
126
+ // {{ ... }}
127
+ const [content, start] = (0, template_1.parseInterpolationNode)(node, templateContent);
128
+ const lines = content.split('\n');
129
+ addFormatCodes(content, start, lines.length <= 1 ? formatBrackets.curly : [
130
+ lines[0].trim() === '' ? '(' : formatBrackets.curly[0],
131
+ lines[lines.length - 1].trim() === '' ? ');' : formatBrackets.curly[1],
132
+ ]);
133
+ }
134
+ }
135
+ function addFormatCodes(code, offset, wrapper) {
136
+ const id = 'template_inline_ts_' + i++;
137
+ data.set(id, [
138
+ wrapper[0],
139
+ [
140
+ code,
141
+ 'template',
142
+ offset,
143
+ codeFeatures,
144
+ ],
145
+ wrapper[1],
146
+ ]);
147
+ }
148
+ }
149
+ };
150
+ exports.default = plugin;
151
+ //# sourceMappingURL=vue-template-inline-ts.js.map
@@ -53,6 +53,7 @@ export declare const tsCodegen: WeakMap<Sfc, {
53
53
  name: import("../types").TextRange | undefined;
54
54
  nameIsString: boolean;
55
55
  type: import("../types").TextRange | undefined;
56
+ modifierType?: import("../types").TextRange | undefined;
56
57
  defaultValue: import("../types").TextRange | undefined;
57
58
  required: boolean;
58
59
  isModel?: boolean | undefined;
@@ -67,10 +68,6 @@ export declare const tsCodegen: WeakMap<Sfc, {
67
68
  generatedTemplate: () => {
68
69
  codes: Code[];
69
70
  codeStacks: string[];
70
- formatCodes: Code[];
71
- formatCodeStacks: string[];
72
- cssCodes: Code[];
73
- cssCodeStacks: string[];
74
71
  tagOffsetsMap: Map<string, number[]>;
75
72
  accessedGlobalVariables: Set<string>;
76
73
  hasSlot: boolean;
@@ -5,11 +5,10 @@ const language_core_1 = require("@volar/language-core");
5
5
  const computeds_1 = require("computeds");
6
6
  const script_1 = require("../generators/script");
7
7
  const template_1 = require("../generators/template");
8
- const utils_1 = require("../generators/utils");
9
8
  const scriptRanges_1 = require("../parsers/scriptRanges");
10
9
  const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
11
10
  exports.tsCodegen = new WeakMap();
12
- const plugin = (ctx) => {
11
+ const plugin = ctx => {
13
12
  return {
14
13
  version: 2,
15
14
  requiredCompilerOptions: [
@@ -22,10 +21,6 @@ const plugin = (ctx) => {
22
21
  if (['js', 'ts', 'jsx', 'tsx'].includes(tsx.lang())) {
23
22
  files.push({ id: 'script_' + tsx.lang(), lang: tsx.lang() });
24
23
  }
25
- if (sfc.template) {
26
- files.push({ id: 'template_format', lang: 'ts' });
27
- files.push({ id: 'template_style', lang: 'css' });
28
- }
29
24
  return files;
30
25
  },
31
26
  resolveEmbeddedCode(fileName, sfc, embeddedFile) {
@@ -34,52 +29,11 @@ const plugin = (ctx) => {
34
29
  const tsx = _tsx.generatedScript();
35
30
  if (tsx) {
36
31
  const [content, contentStacks] = ctx.codegenStack ? (0, language_core_1.track)([...tsx.codes], [...tsx.codeStacks]) : [[...tsx.codes], [...tsx.codeStacks]];
37
- content.forEach(code => {
38
- if (typeof code !== 'string') {
39
- code[3].structure = false;
40
- code[3].format = false;
41
- }
42
- });
43
32
  embeddedFile.content = content;
44
33
  embeddedFile.contentStacks = contentStacks;
45
34
  embeddedFile.linkedCodeMappings = [...tsx.linkedCodeMappings];
46
35
  }
47
36
  }
48
- else if (embeddedFile.id === 'template_format') {
49
- embeddedFile.parentCodeId = 'template';
50
- const template = _tsx.generatedTemplate();
51
- if (template) {
52
- const [content, contentStacks] = ctx.codegenStack
53
- ? (0, language_core_1.track)([...template.formatCodes], template.formatCodeStacks.map(stack => ({ stack, length: 1 })))
54
- : [[...template.formatCodes], template.formatCodeStacks.map(stack => ({ stack, length: 1 }))];
55
- embeddedFile.content = content;
56
- embeddedFile.contentStacks = contentStacks;
57
- }
58
- for (const style of sfc.styles) {
59
- embeddedFile.content.push('\n\n');
60
- for (const cssVar of style.cssVars) {
61
- embeddedFile.content.push('(');
62
- embeddedFile.content.push([
63
- cssVar.text,
64
- style.name,
65
- cssVar.offset,
66
- (0, utils_1.enableAllFeatures)({}),
67
- ]);
68
- embeddedFile.content.push(');\n');
69
- }
70
- }
71
- }
72
- else if (embeddedFile.id === 'template_style') {
73
- embeddedFile.parentCodeId = 'template';
74
- const template = _tsx.generatedTemplate();
75
- if (template) {
76
- const [content, contentStacks] = ctx.codegenStack
77
- ? (0, language_core_1.track)([...template.cssCodes], template.cssCodeStacks.map(stack => ({ stack, length: 1 })))
78
- : [[...template.cssCodes], template.cssCodeStacks.map(stack => ({ stack, length: 1 }))];
79
- embeddedFile.content = content;
80
- embeddedFile.contentStacks = contentStacks;
81
- }
82
- }
83
37
  },
84
38
  };
85
39
  function useTsx(fileName, sfc) {
@@ -126,37 +80,18 @@ function createTsx(fileName, _sfc, ctx) {
126
80
  return classes;
127
81
  });
128
82
  const generatedTemplate = (0, computeds_1.computed)(() => {
129
- if (!_sfc.template)
83
+ if (!_sfc.template) {
130
84
  return;
85
+ }
131
86
  const tsCodes = [];
132
- const tsFormatCodes = [];
133
- const inlineCssCodes = [];
134
87
  const tsCodegenStacks = [];
135
- const tsFormatCodegenStacks = [];
136
- const inlineCssCodegenStacks = [];
137
88
  const codegen = (0, template_1.generate)(ts, ctx.compilerOptions, ctx.vueCompilerOptions, _sfc.template, shouldGenerateScopedClasses(), stylesScopedClasses(), hasScriptSetupSlots(), slotsAssignName(), propsAssignName(), ctx.codegenStack);
138
89
  let current = codegen.next();
139
90
  while (!current.done) {
140
- const [type, code, stack] = current.value;
141
- if (type === 'ts') {
142
- tsCodes.push(code);
143
- }
144
- else if (type === 'tsFormat') {
145
- tsFormatCodes.push(code);
146
- }
147
- else if (type === 'inlineCss') {
148
- inlineCssCodes.push(code);
149
- }
91
+ const [code, stack] = current.value;
92
+ tsCodes.push(code);
150
93
  if (ctx.codegenStack) {
151
- if (type === 'ts') {
152
- tsCodegenStacks.push(stack);
153
- }
154
- else if (type === 'tsFormat') {
155
- tsFormatCodegenStacks.push(stack);
156
- }
157
- else if (type === 'inlineCss') {
158
- inlineCssCodegenStacks.push(stack);
159
- }
94
+ tsCodegenStacks.push(stack);
160
95
  }
161
96
  current = codegen.next();
162
97
  }
@@ -164,10 +99,6 @@ function createTsx(fileName, _sfc, ctx) {
164
99
  ...current.value,
165
100
  codes: tsCodes,
166
101
  codeStacks: tsCodegenStacks,
167
- formatCodes: tsFormatCodes,
168
- formatCodeStacks: tsFormatCodegenStacks,
169
- cssCodes: inlineCssCodes,
170
- cssCodeStacks: inlineCssCodegenStacks,
171
102
  };
172
103
  });
173
104
  const hasScriptSetupSlots = (0, computeds_1.computed)(() => !!scriptSetupRanges()?.slots.define);
package/lib/plugins.js CHANGED
@@ -9,6 +9,8 @@ const vue_sfc_scripts_1 = require("./plugins/vue-sfc-scripts");
9
9
  const vue_sfc_styles_1 = require("./plugins/vue-sfc-styles");
10
10
  const vue_sfc_template_1 = require("./plugins/vue-sfc-template");
11
11
  const vue_template_html_1 = require("./plugins/vue-template-html");
12
+ const vue_template_inline_css_1 = require("./plugins/vue-template-inline-css");
13
+ const vue_template_inline_ts_1 = require("./plugins/vue-template-inline-ts");
12
14
  const vue_tsx_1 = require("./plugins/vue-tsx");
13
15
  const types_1 = require("./types");
14
16
  function getDefaultVueLanguagePlugins(pluginContext) {
@@ -17,6 +19,8 @@ function getDefaultVueLanguagePlugins(pluginContext) {
17
19
  file_html_1.default, // .html for PetiteVue
18
20
  file_vue_1.default, // .vue and others for Vue
19
21
  vue_template_html_1.default,
22
+ vue_template_inline_css_1.default,
23
+ vue_template_inline_ts_1.default,
20
24
  vue_sfc_styles_1.default,
21
25
  vue_sfc_customblocks_1.default,
22
26
  vue_sfc_scripts_1.default,
@@ -27,7 +31,9 @@ function getDefaultVueLanguagePlugins(pluginContext) {
27
31
  const pluginInstances = plugins
28
32
  .map(plugin => {
29
33
  try {
30
- return plugin(pluginContext);
34
+ const instance = plugin(pluginContext);
35
+ instance.name ??= plugin.__moduleName;
36
+ return instance;
31
37
  }
32
38
  catch (err) {
33
39
  console.warn('[Vue] Failed to create plugin', err);
@@ -39,10 +45,10 @@ function getDefaultVueLanguagePlugins(pluginContext) {
39
45
  const bOrder = b.order ?? 0;
40
46
  return aOrder - bOrder;
41
47
  });
42
- return pluginInstances.filter((plugin) => {
48
+ return pluginInstances.filter(plugin => {
43
49
  const valid = plugin.version === types_1.pluginVersion;
44
50
  if (!valid) {
45
- console.warn(`[Vue] Plugin ${JSON.stringify(plugin.name)} API version incompatible, expected ${JSON.stringify(types_1.pluginVersion)} but got ${JSON.stringify(plugin.version)}`);
51
+ console.warn(`[Vue] Plugin ${JSON.stringify(plugin.name)} API version incompatible, expected "${types_1.pluginVersion}" but got "${plugin.version}".`);
46
52
  }
47
53
  return valid;
48
54
  });
@@ -103,8 +103,9 @@ function walkIdentifiers(ts, node, ast, cb, localVars, blockVars = [], isRoot =
103
103
  for (const varName of blockVars) {
104
104
  localVars.set(varName, (localVars.get(varName) ?? 0) + 1);
105
105
  }
106
- if (node.initializer)
106
+ if (node.initializer) {
107
107
  walkIdentifiers(ts, node.initializer, ast, cb, localVars, blockVars, false);
108
+ }
108
109
  }
109
110
  else if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
110
111
  const functionArgs = [];
@@ -114,11 +115,13 @@ function walkIdentifiers(ts, node, ast, cb, localVars, blockVars = [], isRoot =
114
115
  walkIdentifiers(ts, param.type, ast, cb, localVars, blockVars, false);
115
116
  }
116
117
  }
117
- for (const varName of functionArgs)
118
+ for (const varName of functionArgs) {
118
119
  localVars.set(varName, (localVars.get(varName) ?? 0) + 1);
120
+ }
119
121
  walkIdentifiers(ts, node.body, ast, cb, localVars, blockVars, false);
120
- for (const varName of functionArgs)
122
+ for (const varName of functionArgs) {
121
123
  localVars.set(varName, localVars.get(varName) - 1);
124
+ }
122
125
  }
123
126
  else if (ts.isObjectLiteralExpression(node)) {
124
127
  for (const prop of node.properties) {
package/lib/utils/ts.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type * as ts from 'typescript';
2
2
  import type { VueCompilerOptions } from '../types';
3
3
  export type ParsedCommandLine = ts.ParsedCommandLine & {
4
- vueOptions: Partial<VueCompilerOptions>;
4
+ vueOptions: VueCompilerOptions;
5
5
  };
6
6
  export declare function createParsedCommandLineByJson(ts: typeof import('typescript'), parseConfigHost: ts.ParseConfigHost, rootDir: string, json: any, configFileName?: string): ParsedCommandLine;
7
7
  export declare function createParsedCommandLine(ts: typeof import('typescript'), parseConfigHost: ts.ParseConfigHost, tsConfigPath: string): ParsedCommandLine;
package/lib/utils/ts.js CHANGED
@@ -15,7 +15,8 @@ function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, confi
15
15
  }
16
16
  catch (err) { }
17
17
  }
18
- const parsed = ts.parseJsonConfigFileContent(json, proxyHost.host, rootDir, {}, configFileName, undefined, (vueOptions.extensions ?? ['.vue']).map(extension => ({
18
+ const resolvedVueOptions = resolveVueCompilerOptions(vueOptions);
19
+ const parsed = ts.parseJsonConfigFileContent(json, proxyHost.host, rootDir, {}, configFileName, undefined, resolvedVueOptions.extensions.map(extension => ({
19
20
  extension: extension.slice(1),
20
21
  isMixedContent: true,
21
22
  scriptKind: ts.ScriptKind.Deferred,
@@ -26,7 +27,7 @@ function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, confi
26
27
  parsed.options.outDir = undefined;
27
28
  return {
28
29
  ...parsed,
29
- vueOptions,
30
+ vueOptions: resolvedVueOptions,
30
31
  };
31
32
  }
32
33
  exports.createParsedCommandLineByJson = createParsedCommandLineByJson;
@@ -45,7 +46,8 @@ function createParsedCommandLine(ts, parseConfigHost, tsConfigPath) {
45
46
  }
46
47
  catch (err) { }
47
48
  }
48
- const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost.host, path.dirname(tsConfigPath), {}, tsConfigPath, undefined, (vueOptions.extensions ?? ['.vue']).map(extension => ({
49
+ const resolvedVueOptions = resolveVueCompilerOptions(vueOptions);
50
+ const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost.host, path.dirname(tsConfigPath), {}, tsConfigPath, undefined, resolvedVueOptions.extensions.map(extension => ({
49
51
  extension: extension.slice(1),
50
52
  isMixedContent: true,
51
53
  scriptKind: ts.ScriptKind.Deferred,
@@ -56,7 +58,7 @@ function createParsedCommandLine(ts, parseConfigHost, tsConfigPath) {
56
58
  parsed.options.outDir = undefined;
57
59
  return {
58
60
  ...parsed,
59
- vueOptions,
61
+ vueOptions: resolvedVueOptions,
60
62
  };
61
63
  }
62
64
  catch (err) {
@@ -118,7 +120,9 @@ function getPartialVueCompilerOptions(ts, tsConfigSourceFile) {
118
120
  try {
119
121
  const resolvedPath = resolvePath(pluginPath);
120
122
  if (resolvedPath) {
121
- return require(resolvedPath);
123
+ const plugin = require(resolvedPath);
124
+ plugin.__moduleName = pluginPath;
125
+ return plugin;
122
126
  }
123
127
  else {
124
128
  console.warn('[Vue] Load plugin failed:', pluginPath);
@@ -9,7 +9,7 @@ const compile = (template, options = {}) => {
9
9
  }
10
10
  const onError = options.onError;
11
11
  const onWarn = options.onWarn;
12
- options.onError = (error) => {
12
+ options.onError = error => {
13
13
  if (error.code === 33 // :key binding allowed in v-for template child in vue 2
14
14
  || error.code === 29 // fix https://github.com/vuejs/language-tools/issues/1638
15
15
  ) {
@@ -57,7 +57,7 @@ const compile = (template, options = {}) => {
57
57
  };
58
58
  exports.compile = compile;
59
59
  function baseCompile(template, options = {}) {
60
- const onError = options.onError || ((error) => { throw error; });
60
+ const onError = options.onError || (error => { throw error; });
61
61
  const isModuleMode = options.mode === 'module';
62
62
  const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
63
63
  if (!prefixIdentifiers && options.cacheHandlers) {
@@ -36,16 +36,7 @@ function computedFiles(plugins, fileName, sfc, codegenStack) {
36
36
  break;
37
37
  }
38
38
  }
39
- for (const { file, snapshot, mappings, codegenStacks } of remain) {
40
- embeddedCodes.push({
41
- id: file.id,
42
- languageId: (0, language_core_1.resolveCommonLanguageId)(`/dummy.${file.lang}`),
43
- linkedCodeMappings: file.linkedCodeMappings,
44
- snapshot,
45
- mappings,
46
- codegenStacks,
47
- embeddedCodes: [],
48
- });
39
+ for (const { file } of remain) {
49
40
  console.error('Unable to resolve embedded: ' + file.parentCodeId + ' -> ' + file.id);
50
41
  }
51
42
  return embeddedCodes;
@@ -20,7 +20,7 @@ function computedMappings(snapshot, sfc) {
20
20
  }
21
21
  const mappings = str
22
22
  .filter(s => typeof s !== 'string')
23
- .map((m) => {
23
+ .map(m => {
24
24
  const text = m[0];
25
25
  const start = m[2];
26
26
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "2.0.6",
3
+ "version": "2.0.10",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/language-core"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "~2.1.2",
15
+ "@volar/language-core": "~2.2.0-alpha.5",
16
16
  "@vue/compiler-dom": "^3.4.0",
17
17
  "@vue/shared": "^3.4.0",
18
18
  "computeds": "^0.0.1",
@@ -34,5 +34,5 @@
34
34
  "optional": true
35
35
  }
36
36
  },
37
- "gitHead": "feb990ccec85f6330bba37c8b1d1287f0980274c"
37
+ "gitHead": "a20a2ee950b63a949660b7e8faf0faed0e5bad33"
38
38
  }