resolve jit modules together

master
Brad Cornes 2021-05-06 18:01:54 +01:00
parent d7d0406794
commit 2f2d66124a
2 changed files with 12 additions and 14 deletions

View File

@ -76,7 +76,7 @@ export interface State {
postcss?: { version: string; module: Postcss } postcss?: { version: string; module: Postcss }
postcssSelectorParser?: { module: any } postcssSelectorParser?: { module: any }
resolveConfig?: { module: any } resolveConfig?: { module: any }
jit?: { generateRules: { module: any } } jit?: { generateRules: { module: any }; setupContext: { module: any } }
} }
browserslist?: string[] browserslist?: string[]
featureFlags?: FeatureFlags featureFlags?: FeatureFlags

View File

@ -438,6 +438,11 @@ async function createProjectService(
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/generateRules') resolveFrom(configDir, 'tailwindcss/lib/jit/lib/generateRules')
).generateRules, ).generateRules,
}, },
setupContext: {
module: __non_webpack_require__(
resolveFrom(configDir, 'tailwindcss/lib/jit/lib/setupContext')
).default,
},
} }
} catch (_) { } catch (_) {
try { try {
@ -447,6 +452,11 @@ async function createProjectService(
resolveFrom(configDir, 'tailwindcss/jit/lib/generateRules') resolveFrom(configDir, 'tailwindcss/jit/lib/generateRules')
).generateRules, ).generateRules,
}, },
setupContext: {
module: __non_webpack_require__(
resolveFrom(configDir, 'tailwindcss/jit/lib/setupContext')
),
},
} }
} catch (_) {} } catch (_) {}
} }
@ -676,19 +686,7 @@ 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 state.jitContext = state.modules.jit.setupContext.module(state.configPath)(
try {
setupContext = __non_webpack_require__(
resolveFrom(path.dirname(state.configPath), 'tailwindcss/lib/jit/lib/setupContext')
).default
} catch (_) {
setupContext = __non_webpack_require__(
resolveFrom(path.dirname(state.configPath), 'tailwindcss/jit/lib/setupContext')
)
}
state.jitContext = setupContext(state.configPath)(
{ opts: {}, messages: [] }, { opts: {}, messages: [] },
state.modules.postcss.module.root() state.modules.postcss.module.root()
) )