{"id":27532,"library":"vue-compiler","title":"vue-compiler","description":"A standalone Vue single-file component (SFC) compiler for projects that cannot use webpack. Current stable version is 4.2.1, released on an irregular cadence by a community maintainer. Unlike official vue-loader, this package compiles .vue files directly to CommonJS modules without requiring webpack, supporting both async (compile) and sync (compileSync) APIs. It includes template compilation (via vue-template-compiler), style processing, and custom compiler hooks. However, the package is not actively maintained by the Vue core team and relies on an outdated peer dependency of vue-template-compiler ^2.6.10, meaning it only supports Vue 2.x. For Vue 3, use @vue/compiler-sfc instead.","status":"active","version":"4.2.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install vue-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add vue-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add vue-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for compiling Vue 2 templates","package":"vue-template-compiler","optional":false}],"imports":[{"note":"The default export is the async compile function. Named exports are also available.","wrong":"const compile = require('vue-compiler').compile","symbol":"compile (default)","correct":"import compile from 'vue-compiler'"},{"note":"Only available as named export, not as a default property.","wrong":"const compileSync = require('vue-compiler').compileSync","symbol":"compileSync","correct":"import { compileSync } from 'vue-compiler'"},{"note":"Exported as a named function for parsing SFC descriptors.","wrong":null,"symbol":"parse","correct":"import { parse } from 'vue-compiler'"},{"note":"Used to combine compiled parts into a final module.","wrong":null,"symbol":"assemble","correct":"import { assemble } from 'vue-compiler'"}],"quickstart":{"code":"import compile from 'vue-compiler';\n\nconst source = `<template><div>{{ msg }}</div></template><script>export default { data() { return { msg: 'Hello' } } }</script><style scoped>div { color: red }</style>`;\n\nconst result = await compile(source, { filename: 'App.vue' });\nconsole.log(result.code);\n","lang":"javascript","description":"Demonstrates async compilation of a Vue single-file component string to a CommonJS module."},"warnings":[{"fix":"Use @vue/compiler-sfc for Vue 3 projects.","message":"Vue 2 only; does not support Vue 3 SFC syntax.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Update your project's vue-template-compiler to a newer patch within 2.6.x, or migrate to Vue 3.","message":"The peer dependency vue-template-compiler ^2.6.10 is outdated and may have security vulnerabilities.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Use `import compile from 'vue-compiler'` for the async function.","message":"The default export is the async compile function. Importing as `import { compile }` will not work.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Add a .d.ts file: `declare module 'vue-compiler'` or use @types/vue-compiler if available.","message":"When using TypeScript, the package does not ship its own type definitions. You may need to create a declaration file.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"search_vec":"'2':103 '2.6.10':97 '3':107 '4.2.1':23 'activ':78 'api':57 'async':52 'cadenc':28 'cannot':16 'commonj':45 'communiti':31 'compil':3,12,40,53,61,66,71,96 'compilesync':56 'compon':10 'core':83 'current':19 'custom':70 'depend':91 'direct':43 'file':9,42 'hook':72 'howev':73 'includ':59 'instead':110 'irregular':27 'javascript':111 'loader':37 'maintain':32,79 'mean':98 'modul':46 'offici':34 'outdat':89 'packag':39,75 'peer':90 'process':68 'project':14 'releas':24 'reli':86 'requir':48 'sfc':11 'singl':8 'single-fil':7 'stabl':20 'standalon':5 'style':67 'support':50,101 'sync':55 'team':84 'templat':60,65,95 'unlik':33 'use':17,108 'version':21 'via':62 'vue':2,6,36,41,64,82,94,102,106 'vue-compil':1 'vue-load':35 'vue-template-compil':63,93 'vue/compiler-sfc':109 'webpack':18,49 'without':47 'x':104","created_at":"2026-05-01T17:46:44.727997+00:00","updated_at":"2026-05-01T17:46:44.727997+00:00","problems":[{"fix":"Run `npm install vue-template-compiler@^2.6.10` in your project.","cause":"Missing peer dependency.","error":"Cannot find module 'vue-template-compiler'"},{"fix":"Use `import compile from 'vue-compiler'` instead of `import { compile } from 'vue-compiler'`.","cause":"Improper import: using named import for default export.","error":"TypeError: (0 , _vueCompiler.default) is not a function"},{"fix":"Ensure you have vue-template-compiler@^2.6.10 installed, not @vue/compiler-sfc.","cause":"Incompatible version of vue-template-compiler (e.g., Vue 3 version installed).","error":"Expected vue-template-compiler to be a function, got object"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vue-compiler","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}