Gathering detailed insights and metrics for @vue/compiler-sfc
Gathering detailed insights and metrics for @vue/compiler-sfc
Gathering detailed insights and metrics for @vue/compiler-sfc
Gathering detailed insights and metrics for @vue/compiler-sfc
@vue/component-compiler-utils
Lower level utilities for compiling Vue single file components
@vitejs/plugin-vue
> Note: as of `vue` 3.2.13+ and `@vitejs/plugin-vue` 1.9.0+, `@vue/compiler-sfc` is no longer required as a peer dependency.
@vuedx/compiler-sfc
This package extracts `parse()` function [@vue/compiler-sfc] as ES module.
vue-template-babel-compiler
Post compiler for Vue template render functions to support ES features with Babel
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
npm install @vue/compiler-sfc
Typescript
Module System
Node Version
NPM Version
TypeScript (96.32%)
JavaScript (1.89%)
HTML (1.28%)
Vue (0.48%)
CSS (0.03%)
Total Downloads
812,518,794
Last Day
1,486,808
Last Week
7,928,072
Last Month
34,749,824
Last Year
363,080,440
MIT License
49,961 Stars
6,609 Commits
8,635 Forks
752 Watchers
105 Branches
555 Contributors
Updated on May 09, 2025
Minified
Minified + Gzipped
Latest Version
3.5.13
Package Id
@vue/compiler-sfc@3.5.13
Unpacked Size
2.49 MB
Size
568.89 kB
File Count
6
NPM Version
10.8.2
Node Version
20.18.0
Published on
Nov 15, 2024
Cumulative downloads
Total Downloads
Lower level utilities for compiling Vue Single File Components
Note: as of 3.2.13+, this package is included as a dependency of the main vue
package and can be accessed as vue/compiler-sfc
. This means you no longer need to explicitly install this package and ensure its version match that of vue
's. Just use the main vue/compiler-sfc
deep import instead.
This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in vue-loader and @vitejs/plugin-vue.
The API is intentionally low-level due to the various considerations when integrating Vue SFCs in a build system:
Separate hot-module replacement (HMR) for script, template and styles
Leveraging the tool's plugin system for pre-processor handling. e.g. <style lang="scss">
should be processed by the corresponding webpack loader.
In some cases, transformers of each block in an SFC do not share the same execution context. For example, when used with thread-loader
or other parallelized configurations, the template sub-loader in vue-loader
may not have access to the full SFC and its descriptor.
The general idea is to generate a facade module that imports the individual blocks of the component. The trick is the module imports itself with different query strings so that the build system can handle each request as "virtual" modules:
+--------------------+
| |
| script transform |
+----->+ |
| +--------------------+
|
+--------------------+ | +--------------------+
| | | | |
| facade transform +----------->+ template transform |
| | | | |
+--------------------+ | +--------------------+
|
| +--------------------+
+----->+ |
| style transform |
| |
+--------------------+
Where the facade module looks like this:
1// main script 2import script from '/project/foo.vue?vue&type=script' 3// template compiled to render function 4import { render } from '/project/foo.vue?vue&type=template&id=xxxxxx' 5// css 6import '/project/foo.vue?vue&type=style&index=0&id=xxxxxx' 7 8// attach render function to script 9script.render = render 10 11// attach additional metadata 12// some of these should be dev only 13script.__file = 'example.vue' 14script.__scopeId = 'xxxxxx' 15 16// additional tooling-specific HMR handling code 17// using __VUE_HMR_API__ global 18 19export default script
In facade transform, parse the source into descriptor with the parse
API and generate the above facade module code based on the descriptor;
In script transform, use compileScript
to process the script. This handles features like <script setup>
and CSS variable injection. Alternatively, this can be done directly in the facade module (with the code inlined instead of imported), but it will require rewriting export default
to a temp variable (a rewriteDefault
convenience API is provided for this purpose) so additional options can be attached to the exported object.
In template transform, use compileTemplate
to compile the raw template into render function code.
In style transform, use compileStyle
to compile raw CSS to handle <style scoped>
, <style module>
and CSS variable injection.
Options needed for these APIs can be passed via the query string.
For detailed API references and options, check out the source type definitions. For actual usage of these APIs, check out @vitejs/plugin-vue or vue-loader.
No vulnerabilities found.
Reason
30 commit(s) and 14 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
packaging workflow detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-04-28
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
51.4%
1,486,808
Compared to previous day
Last Week
3.6%
7,928,072
Compared to previous week
Last Month
-7.3%
34,749,824
Compared to previous month
Last Year
47.8%
363,080,440
Compared to previous year