avoid re-loading modules when not necessary

master
Brad Cornes 2021-05-09 19:42:03 +01:00
parent 734fb4da1b
commit 7cbfd2a166
1 changed files with 10 additions and 9 deletions

View File

@ -317,8 +317,6 @@ async function createProjectService(
throw new SilentError('No config file found.') throw new SilentError('No config file found.')
} }
console.log(`Found Tailwind CSS config file: ${configPath}`)
const pnpPath = findUp.sync( const pnpPath = findUp.sync(
(dir) => { (dir) => {
let pnpFile = path.join(dir, '.pnp.js') let pnpFile = path.join(dir, '.pnp.js')
@ -359,7 +357,6 @@ async function createProjectService(
try { try {
const tailwindcssPath = resolveFrom(configDir, 'tailwindcss') const tailwindcssPath = resolveFrom(configDir, 'tailwindcss')
const tailwindcssPkgPath = resolveFrom(configDir, 'tailwindcss/package.json') const tailwindcssPkgPath = resolveFrom(configDir, 'tailwindcss/package.json')
const tailwindcssPkg = __non_webpack_require__(tailwindcssPkgPath)
const tailwindDir = path.dirname(tailwindcssPkgPath) const tailwindDir = path.dirname(tailwindcssPkgPath)
const postcssPath = resolveFrom(tailwindDir, 'postcss') const postcssPath = resolveFrom(tailwindDir, 'postcss')
@ -367,13 +364,8 @@ async function createProjectService(
const postcssDir = path.dirname(postcssPkgPath) const postcssDir = path.dirname(postcssPkgPath)
const postcssSelectorParserPath = resolveFrom(tailwindDir, 'postcss-selector-parser') const postcssSelectorParserPath = resolveFrom(tailwindDir, 'postcss-selector-parser')
postcss = __non_webpack_require__(postcssPath)
postcssVersion = __non_webpack_require__(postcssPkgPath).version postcssVersion = __non_webpack_require__(postcssPkgPath).version
postcssSelectorParser = __non_webpack_require__(postcssSelectorParserPath) tailwindcssVersion = __non_webpack_require__(tailwindcssPkgPath).version
console.log(`Loaded postcss v${postcssVersion}: ${postcssDir}`)
tailwindcss = __non_webpack_require__(tailwindcssPath)
tailwindcssVersion = tailwindcssPkg.version
console.log(`Loaded tailwindcss v${tailwindcssVersion}: ${tailwindDir}`)
if ( if (
state.enabled && state.enabled &&
@ -385,6 +377,15 @@ async function createProjectService(
return return
} }
console.log(`Found Tailwind CSS config file: ${configPath}`)
postcss = __non_webpack_require__(postcssPath)
postcssSelectorParser = __non_webpack_require__(postcssSelectorParserPath)
console.log(`Loaded postcss v${postcssVersion}: ${postcssDir}`)
tailwindcss = __non_webpack_require__(tailwindcssPath)
console.log(`Loaded tailwindcss v${tailwindcssVersion}: ${tailwindDir}`)
try { try {
resolveConfigFn = __non_webpack_require__(resolveFrom(tailwindDir, './resolveConfig.js')) resolveConfigFn = __non_webpack_require__(resolveFrom(tailwindDir, './resolveConfig.js'))
} catch (_) { } catch (_) {