Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vue/component-compiler-utils

Package Overview
Dependencies
Maintainers
9
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vue/component-compiler-utils

Lower level utilities for compiling Vue single file components

  • 2.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
621K
decreased by-54.45%
Maintainers
9
Weekly downloads
 
Created

What is @vue/component-compiler-utils?

The @vue/component-compiler-utils package is a lower-level utility for compiling Vue single-file components (SFCs). It is used by higher-level tools like vue-loader to process the various parts of a Vue component, such as the template, script, and styles. It provides functions to parse SFCs, compile their templates to render functions, and scope their styles.

What are @vue/component-compiler-utils's main functionalities?

Parsing Single-File Components

This feature allows you to parse .vue files into an object descriptor that contains separate objects for template, script, styles, and custom blocks.

const { parse } = require('@vue/component-compiler-utils');
const { readFileSync } = require('fs');

const source = readFileSync('MyComponent.vue', 'utf-8');
const descriptor = parse({
  source,
  filename: 'MyComponent.vue',
  compiler: require('vue-template-compiler')
});

Compiling Template

This feature compiles the template part of a Vue component into a JavaScript render function.

const { compileTemplate } = require('@vue/component-compiler-utils');
const { descriptor } = require('./parsed-component');

const compiled = compileTemplate({
  source: descriptor.template.content,
  filename: 'MyComponent.vue',
  compiler: require('vue-template-compiler')
});

Scoping Styles

This feature processes the styles of a Vue component, adding scope IDs to make them unique to the component, which helps in preventing style leakage.

const { compileStyle, compileStyleAsync } = require('@vue/component-compiler-utils');
const { descriptor } = require('./parsed-component');

const compiledStyle = compileStyle({
  source: descriptor.styles[0].content,
  filename: 'MyComponent.vue',
  id: 'data-v-12345678',
  scoped: true
});

Other packages similar to @vue/component-compiler-utils

Keywords

FAQs

Package last updated on 09 Aug 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc