fix: Add back pnpm support

master
DanSnow 2020-08-27 20:39:00 +08:00
parent e713b2bed8
commit 7ba8b4d8f8
No known key found for this signature in database
GPG Key ID: 2B25949174178EBD
3 changed files with 10 additions and 7 deletions

View File

@ -5,9 +5,10 @@ import { isObject } from './isObject'
import { withUserEnvironment } from './environment' import { withUserEnvironment } from './environment'
export async function getBuiltInPlugins({ cwd, resolvedConfig }) { export async function getBuiltInPlugins({ cwd, resolvedConfig }) {
return withUserEnvironment(cwd, ({ require }) => { return withUserEnvironment(cwd, ({ require, resolve }) => {
const tailwindBase = path.dirname(resolve('tailwindcss/package.json'))
try { try {
return require('tailwindcss/lib/corePlugins.js').default({ return require('./lib/corePlugins.js', tailwindBase).default({
corePlugins: resolvedConfig.corePlugins, corePlugins: resolvedConfig.corePlugins,
}) })
} catch (_) { } catch (_) {

View File

@ -184,7 +184,8 @@ function loadMeta(configDir) {
let featureFlags let featureFlags
try { try {
featureFlags = require('tailwindcss/lib/featureFlags.js').default const tailwindBase = path.dirname(resolve('tailwindcss/package.json'))
featureFlags = require('./lib/featureFlags.js', tailwindBase).default
} catch (_) {} } catch (_) {}
return { version, featureFlags } return { version, featureFlags }

View File

@ -12,13 +12,14 @@ export default function resolveConfig({ cwd, config }) {
} }
let resolve = (x) => x let resolve = (x) => x
withUserEnvironment(cwd, ({ require }) => { withUserEnvironment(cwd, ({ require, resolve }) => {
const tailwindBase = path.dirname(resolve('tailwindcss/package.json'))
try { try {
resolve = require('tailwindcss/resolveConfig.js') resolve = require('./resolveConfig.js', tailwindBase)
} catch (_) { } catch (_) {
try { try {
const resolveConfig = require('tailwindcss/lib/util/resolveConfig.js') const resolveConfig = require('./lib/util/resolveConfig.js', tailwindBase)
const defaultConfig = require('tailwindcss/stubs/defaultConfig.stub.js') const defaultConfig = require('./stubs/defaultConfig.stub.js', tailwindBase)
resolve = (config) => resolveConfig([config, defaultConfig]) resolve = (config) => resolveConfig([config, defaultConfig])
} catch (_) {} } catch (_) {}
} }