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 }
postcssSelectorParser?: { module: any }
resolveConfig?: { module: any }
jit?: { generateRules: { module: any } }
jit?: { generateRules: { module: any }; setupContext: { module: any } }
}
browserslist?: string[]
featureFlags?: FeatureFlags

View File

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