fix for canary releases
parent
52ae09b4fa
commit
cf7bb68e35
|
@ -69,6 +69,7 @@ import { getDocumentColors } from 'tailwindcss-language-service/src/documentColo
|
||||||
import { fromRatio, names as namedColors } from '@ctrl/tinycolor'
|
import { fromRatio, names as namedColors } from '@ctrl/tinycolor'
|
||||||
import { debounce } from 'debounce'
|
import { debounce } from 'debounce'
|
||||||
import { getModuleDependencies } from './util/getModuleDependencies'
|
import { getModuleDependencies } from './util/getModuleDependencies'
|
||||||
|
import assert from 'assert'
|
||||||
// import postcssLoadConfig from 'postcss-load-config'
|
// import postcssLoadConfig from 'postcss-load-config'
|
||||||
|
|
||||||
const CONFIG_FILE_GLOB = '{tailwind,tailwind.config}.{js,cjs}'
|
const CONFIG_FILE_GLOB = '{tailwind,tailwind.config}.{js,cjs}'
|
||||||
|
@ -132,6 +133,19 @@ function getConfigId(configPath: string, configDependencies: string[]): string {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function first<T>(...options: Array<() => T>): T {
|
||||||
|
for (let i = 0; i < options.length; i++) {
|
||||||
|
let option = options[i]
|
||||||
|
if (i === options.length - 1) {
|
||||||
|
return option()
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return option()
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface ProjectService {
|
interface ProjectService {
|
||||||
state: State
|
state: State
|
||||||
tryInit: () => Promise<void>
|
tryInit: () => Promise<void>
|
||||||
|
@ -442,23 +456,38 @@ async function createProjectService(
|
||||||
let tailwindDirectives = new Set()
|
let tailwindDirectives = new Set()
|
||||||
let root = postcss.root()
|
let root = postcss.root()
|
||||||
let result = { opts: {}, messages: [] }
|
let result = { opts: {}, messages: [] }
|
||||||
|
let registerDependency = () => {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let createContext
|
let createContext = first(
|
||||||
|
() => {
|
||||||
try {
|
|
||||||
let createContextFn = __non_webpack_require__(
|
let createContextFn = __non_webpack_require__(
|
||||||
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/setupContextUtils')
|
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/setupContextUtils')
|
||||||
).createContext
|
).createContext
|
||||||
createContext = (state) => createContextFn(state.config)
|
assert.strictEqual(typeof createContextFn, 'function')
|
||||||
} catch (_) {
|
return (state) => createContextFn(state.config)
|
||||||
// TODO: only for canary releases so can probably remove
|
},
|
||||||
|
// TODO: the next two are canary releases only so can probably be removed
|
||||||
|
() => {
|
||||||
|
let setupTrackingContext = __non_webpack_require__(
|
||||||
|
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/setupTrackingContext')
|
||||||
|
).default
|
||||||
|
assert.strictEqual(typeof setupTrackingContext, 'function')
|
||||||
|
return (state) =>
|
||||||
|
setupTrackingContext(
|
||||||
|
state.configPath,
|
||||||
|
tailwindDirectives,
|
||||||
|
registerDependency
|
||||||
|
)(result, root)
|
||||||
|
},
|
||||||
|
() => {
|
||||||
let setupContext = __non_webpack_require__(
|
let setupContext = __non_webpack_require__(
|
||||||
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/setupContext')
|
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/setupContext')
|
||||||
).default
|
).default
|
||||||
createContext = (state) =>
|
assert.strictEqual(typeof setupContext, 'function')
|
||||||
setupContext(state.configPath, tailwindDirectives)(result, root)
|
return (state) => setupContext(state.configPath, tailwindDirectives)(result, root)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
jitModules = {
|
jitModules = {
|
||||||
generateRules: {
|
generateRules: {
|
||||||
|
|
Loading…
Reference in New Issue