### Installation Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Install unplugin-quansync as a development dependency. ```bash npm i -D unplugin-quansync ``` -------------------------------- ### Quansync Transformation Example Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Illustrates how unplugin-quansync transforms async functions with 'await' into generator functions with 'yield'. ```typescript import fs from 'node:fs' import { quansync } from 'quansync/macro' // No transformations needed for objects const readFile = quansync({ sync: (path: string) => fs.readFileSync(path), async: (path: string) => fs.promises.readFile(path), }) // `async function` is transformed into a generator function const myFunction = quansync(function* (filename) { // `await` is transformed into `yield ...` const code = yield readFile(filename, 'utf8') return `// some custom prefix\n${code}` }) ``` -------------------------------- ### Quansync Usage Example Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Demonstrates how to create and use quansync functions, providing both sync and async implementations, and calling them. ```typescript import fs from 'node:fs' import { quansync } from 'quansync/macro' // Create a quansync function by providing `sync` and `async` implementations const readFile = quansync({ sync: (path: string) => fs.readFileSync(path), async: (path: string) => fs.promises.readFile(path), }) // Create a quansync function by providing an **async** function const myFunction = quansync(async (filename) => { // Use `await` to call another quansync function const code = await readFile(filename, 'utf8') return `// some custom prefix\n${code}` }) // Use it as a sync function const result = myFunction.sync('./some-file.js') // Use it as an async function const asyncResult = await myFunction.async('./some-file.js') ``` -------------------------------- ### esbuild Configuration Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Integrate unplugin-quansync into your esbuild build process by importing and adding it to the plugins array during the build configuration. ```typescript import { build } from 'esbuild' import Quansync from 'unplugin-quansync/esbuild' build({ plugins: [Quansync()], }) ``` -------------------------------- ### Rolldown Configuration Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Integrate unplugin-quansync into your Rolldown build process by importing and adding it to the plugins array in rolldown.config.js. ```typescript import Quansync from 'unplugin-quansync/rolldown' export default { plugins: [Quansync()], } ``` -------------------------------- ### Vite Configuration Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Integrate unplugin-quansync into your Vite build process by importing and adding it to the plugins array in vite.config.ts. ```typescript import Quansync from 'unplugin-quansync/vite' export default defineConfig({ plugins: [Quansync()], }) ``` -------------------------------- ### Rollup Configuration Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Integrate unplugin-quansync into your Rollup build process by importing and adding it to the plugins array in rollup.config.js. ```javascript import Quansync from 'unplugin-quansync/rollup' export default { plugins: [Quansync()], } ``` -------------------------------- ### Rspack Configuration Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Integrate unplugin-quansync into your Rspack build process by importing and adding it to the plugins array in rspack.config.js. ```typescript // rspack.config.js import Quansync from 'unplugin-quansync/rspack' export default { /* ... */ plugins: [Quansync()], } ``` -------------------------------- ### Webpack Configuration Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Integrate unplugin-quansync into your Webpack build process by importing and adding it to the plugins array in webpack.config.js. ```javascript // webpack.config.js import Quansync from 'unplugin-quansync/webpack' export default { /* ... */ plugins: [Quansync()], } ``` -------------------------------- ### Arrow Function Transformation Source: https://github.com/quansync-dev/unplugin-quansync/blob/main/README.md Shows how arrow functions are transformed into generator functions while preserving 'this' binding. ```typescript const fn = quansync(() => this) // Transforms to: const fn = quansync((v) => { return function* () { return this }.call(this) }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.