load jit modules with try/catch instead of by version number
parent
6bef5de588
commit
2b8a88b267
|
@ -435,16 +435,21 @@ async function createProjectService(
|
||||||
jitModules = {
|
jitModules = {
|
||||||
generateRules: {
|
generateRules: {
|
||||||
module: __non_webpack_require__(
|
module: __non_webpack_require__(
|
||||||
resolveFrom(
|
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/generateRules')
|
||||||
configDir,
|
|
||||||
semver.gte(tailwindcssVersion, '2.1.3')
|
|
||||||
? 'tailwindcss/lib/jit/lib/generateRules'
|
|
||||||
: 'tailwindcss/jit/lib/generateRules'
|
|
||||||
)
|
|
||||||
).generateRules,
|
).generateRules,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {
|
||||||
|
try {
|
||||||
|
jitModules = {
|
||||||
|
generateRules: {
|
||||||
|
module: __non_webpack_require__(
|
||||||
|
resolveFrom(configDir, 'tailwindcss/jit/lib/generateRules')
|
||||||
|
).generateRules,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new SilentError(error.message)
|
throw new SilentError(error.message)
|
||||||
// TODO: force mode
|
// TODO: force mode
|
||||||
|
@ -670,13 +675,17 @@ async function createProjectService(
|
||||||
state.classNames = (await extractClassNames(postcssResult.root)) as ClassNames
|
state.classNames = (await extractClassNames(postcssResult.root)) as ClassNames
|
||||||
|
|
||||||
if (state.jit) {
|
if (state.jit) {
|
||||||
let setupContext = semver.gte(tailwindcss.version, '2.1.3')
|
let setupContext
|
||||||
? __non_webpack_require__(
|
|
||||||
resolveFrom(path.dirname(state.configPath), 'tailwindcss/lib/jit/lib/setupContext')
|
try {
|
||||||
).default
|
setupContext = __non_webpack_require__(
|
||||||
: __non_webpack_require__(
|
resolveFrom(path.dirname(state.configPath), 'tailwindcss/lib/jit/lib/setupContext')
|
||||||
resolveFrom(path.dirname(state.configPath), 'tailwindcss/jit/lib/setupContext')
|
).default
|
||||||
)
|
} catch (_) {
|
||||||
|
setupContext = __non_webpack_require__(
|
||||||
|
resolveFrom(path.dirname(state.configPath), 'tailwindcss/jit/lib/setupContext')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
state.jitContext = setupContext(state.configPath)(
|
state.jitContext = setupContext(state.configPath)(
|
||||||
{ opts: {}, messages: [] },
|
{ opts: {}, messages: [] },
|
||||||
|
|
Loading…
Reference in New Issue