MCPcopy Index your code
hub / github.com/tailwindlabs/prettier-plugin-tailwindcss / createPrinter

Function createPrinter

src/create-plugin.ts:108–143  ·  view source on GitHub ↗
({
  original,
  opts,
}: {
  original: Printer<any>
  opts: TransformOptions<any>
})

Source from the content-addressed store, hash-verified

106}
107
108function createPrinter({
109 original,
110 opts,
111}: {
112 original: Printer<any>
113 opts: TransformOptions<any>
114}) {
115 let printer: Printer<any> = { ...original }
116
117 let reprint = opts.reprint
118
119 // Hook into the preprocessing phase to load the config
120 if (reprint) {
121 printer.print = new Proxy(original.print, {
122 apply(target, thisArg, args) {
123 let [path, options] = args as Parameters<typeof original.print>
124 let env = options.__tailwindcss__ as TransformerEnv
125 reprint(path, { ...env, options: options })
126 return Reflect.apply(target, thisArg, args)
127 },
128 })
129
130 if (original.embed) {
131 printer.embed = new Proxy(original.embed, {
132 apply(target, thisArg, args) {
133 let [path, options] = args as Parameters<typeof original.embed>
134 let env = options.__tailwindcss__ as TransformerEnv
135 reprint(path, { ...env, options: options as any })
136 return Reflect.apply(target, thisArg, args)
137 },
138 })
139 }
140 }
141
142 return printer
143}
144
145async function loadPlugins<T>(fns: PluginLoad[]) {
146 let plugin: Plugin<T> = {

Callers 1

createPluginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…