MCPcopy
hub / github.com/tailwindlabs/tailwindcss / createCompiler

Function createCompiler

packages/@tailwindcss-webpack/src/index.ts:97–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95 let isInitialBuild = context.compiler === null
96
97 async function createCompiler() {
98 DEBUG && I.start('Setup compiler')
99 if (context.fullRebuildPaths.length > 0 && !isInitialBuild) {
100 clearRequireCache(context.fullRebuildPaths)
101 }
102
103 context.fullRebuildPaths = []
104
105 DEBUG && I.start('Create compiler')
106 let compiler = await compile(source, {
107 from: inputFile,
108 base: inputBasePath,
109 shouldRewriteUrls: true,
110 onDependency: (depPath) => context.fullRebuildPaths.push(depPath),
111 // In CSS Module files, we have to disable the `@property` polyfill since these will
112 // emit global `*` rules which are considered to be non-pure and will cause builds
113 // to fail.
114 polyfills: isCSSModuleFile ? Polyfills.All ^ Polyfills.AtProperty : Polyfills.All,
115 })
116 DEBUG && I.end('Create compiler')
117
118 DEBUG && I.end('Setup compiler')
119 return compiler
120 }
121
122 // Setup the compiler if it doesn't exist yet
123 context.compiler ??= await createCompiler()

Callers 1

tailwindLoaderFunction · 0.70

Calls 4

clearRequireCacheFunction · 0.90
compileFunction · 0.90
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected