🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@vue/language-core

Package Overview
Dependencies
Maintainers
2
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vue/language-core

<

latest
Source
npmnpm
Version
3.2.7
Version published
Weekly downloads
7.8M
3.73%
Maintainers
2
Weekly downloads
 
Created
Source

@vue/language-core

NPM version License

The core module for Vue Language Tools, responsible for parsing Vue Single File Components (SFCs) and transforming them into virtual code structures that TypeScript can understand. This package is a low-level dependency for @vue/language-server and vue-tsc.

Installation

npm install @vue/language-core

Core API

createVueLanguagePlugin

Creates a Vue language plugin for integration with Volar language services.

import { createVueLanguagePlugin } from '@vue/language-core';
import type { LanguagePlugin } from '@volar/language-core';
import ts from 'typescript';

const plugin: LanguagePlugin<string> = createVueLanguagePlugin(
  ts,
  compilerOptions,    // ts.CompilerOptions
  vueCompilerOptions, // VueCompilerOptions
  (scriptId) => scriptId  // asFileName: Converts scriptId to a file name
);

createParsedCommandLine

Parses TypeScript and Vue compiler options from tsconfig.json.

import { createParsedCommandLine } from '@vue/language-core';
import ts from 'typescript';

const parsed = createParsedCommandLine(ts, ts.sys, '/path/to/tsconfig.json');
// parsed.options: ts.CompilerOptions
// parsed.vueOptions: VueCompilerOptions

parse

Parses Vue SFC source code and returns an SFCParseResult.

import { parse } from '@vue/language-core';

const result = parse(`
<template>
  <div>{{ msg }}</div>
</template>
<script setup lang="ts">
const msg = 'Hello'
</script>
`);

// result.descriptor.template
// result.descriptor.scriptSetup
// result.descriptor.styles
// result.errors

vueCompilerOptions

Configure Vue compiler behavior through the vueCompilerOptions field in tsconfig.json:

{
  "compilerOptions": { /* ... */ },
  "vueCompilerOptions": {
    "target": 3.5,
    "strictTemplates": true,
    "plugins": ["@vue/language-plugin-pug"]
  }
}

File Handling Options

OptionTypeDefaultDescription
targetnumber | 'auto''auto'Vue version. 'auto' reads from node_modules/vue/package.json.
extensionsstring[]['.vue']File extensions to be treated as Vue SFCs.
vitePressExtensionsstring[][]File extensions to be treated as VitePress Markdown.
petiteVueExtensionsstring[][]File extensions to be treated as Petite Vue HTML.
pluginsstring[][]Custom language plugins, e.g., @vue/language-plugin-pug.

Type Checking Options

OptionTypeDefaultDescription
strictTemplatesbooleanfalseA convenience option that enables the four check* options below and strictVModel.
checkUnknownPropsbooleanfalseCheck for unknown props.
checkUnknownEventsbooleanfalseCheck for unknown events.
checkUnknownComponentsbooleanfalseCheck for unknown components.
checkUnknownDirectivesbooleanfalseCheck for unknown directives.
strictVModelbooleanfalseStrictly check v-model bindings.
strictCssModulesbooleanfalseStrictly check CSS Modules class names (not affected by strictTemplates).

Advanced Options

OptionTypeDefaultDescription
libstring'vue'Vue package name, used for generating import statements.
skipTemplateCodegenbooleanfalseSkip virtual code generation for templates.
fallthroughAttributesbooleanfalseEnable type inference for fallthrough attributes.
jsxSlotsbooleanfalseUse JSX-style slots types.
dataAttributesstring[][]Allowed data-* attribute patterns.
htmlAttributesstring[]['aria-*']Allowed HTML attribute patterns.
resolveStyleImportsbooleanfalseResolve import statements in styles.
resolveStyleClassNamesboolean | 'scoped''scoped'Resolve class names in styles.

Built-in Plugins

This package includes the following built-in plugins to handle different file types and blocks:

File Parsing Plugins

PluginFunctionControlled By
file-vueParses .vue files into an SFC structure.extensions
file-mdParses Markdown files into an SFC structure.vitePressExtensions
file-htmlParses HTML files into an SFC structure.petiteVueExtensions

Virtual Code Generation Plugins

PluginFunction
vue-tsxGenerates TypeScript virtual code from an SFC.
vue-template-htmlCompiles HTML templates.
vue-template-inline-tsHandles TypeScript expressions in templates.
vue-template-inline-cssHandles inline styles in templates.
vue-style-cssCompiles CSS styles.
vue-script-jsHandles JavaScript script blocks.

Embedded Code Extraction Plugins

PluginFunction
vue-sfc-templateExtracts the <template> block.
vue-sfc-stylesExtracts <style> blocks.
vue-sfc-scriptsExtracts <script> blocks (for formatting).
vue-sfc-customblocksExtracts custom blocks.

License

MIT License

FAQs

Package last updated on 19 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts