vue-sfc-transformer provides low-level utilities for transpiling Vue Single File Components (SFCs), specifically focusing on TypeScript syntax within `<script setup>` blocks and template expressions. It aims for minimal transformation, leveraging `esbuild` for the actual code transpilation. The current stable version is `0.1.17`, indicating a pre-1.0 status where API changes might occur in minor releases. This package is actively maintained, receiving frequent bug fixes and minor feature additions as evidenced by its release history, with its last publish being 4 months ago. It is part of the `nuxt-contrib` organization, suggesting its role in the Nuxt ecosystem for build tooling. Its key differentiators include its granular control over SFC block transformation, reliance on `esbuild` for performance, and specific support for handling TypeScript within Vue templates and `script setup` blocks, making it suitable for bundler integrations and custom build pipelines.
npm install vue-sfc-transformerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `vue-sfc-transformer` to pre-transpile `<script setup lang="ts">` and transform a template block using `esbuild` for a Vue SFC.
Run `npm install vue @vue/compiler-core esbuild` or `pnpm install vue @vue/compiler-core esbuild` in your project.
Always review the release notes when upgrading to new minor versions of `vue-sfc-transformer` and thoroughly test your build pipeline.
Ensure your Node.js environment is updated to version 18.0.0 or later.
Install `esbuild` and ensure you pass a configured `esbuild.transform` function to the `transpileVueTemplate` utility, or manage `esbuild` output for `preTranspileScriptSetup`.
Install all necessary peer dependencies: `npm install vue @vue/compiler-core esbuild`.
Ensure your project is configured for ES Modules (e.g., add `"type": "module"` to your `package.json` or use `.mjs` file extension) and use `import` statements.
Ensure `@vue/compiler-sfc` is installed (`npm install @vue/compiler-sfc`) and correctly imported, e.g., `import { parse as parseSFC } from '@vue/compiler-sfc'`.Upgrade your Node.js installation to version 18.0.0 or higher.