update browserslist usage (#159)

fixes "extends" in browserslist config
master
Brad Cornes 2020-12-02 13:57:17 +00:00
parent 534eb253ac
commit f62a5e9092
4 changed files with 21 additions and 12 deletions

4
package-lock.json generated
View File

@ -12132,7 +12132,7 @@
}, },
"packages/tailwindcss-intellisense": { "packages/tailwindcss-intellisense": {
"name": "vscode-tailwindcss", "name": "vscode-tailwindcss",
"version": "0.5.2", "version": "0.5.3",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/debounce": "^1.2.0", "@types/debounce": "^1.2.0",
@ -12147,6 +12147,7 @@
"dlv": "^1.1.3", "dlv": "^1.1.3",
"dset": "^2.0.1", "dset": "^2.0.1",
"esm": "^3.2.25", "esm": "^3.2.25",
"execa": "^3.4.0",
"fast-glob": "^3.2.4", "fast-glob": "^3.2.4",
"glob-exec": "^0.1.1", "glob-exec": "^0.1.1",
"import-from": "^3.0.0", "import-from": "^3.0.0",
@ -20171,6 +20172,7 @@
"dlv": "^1.1.3", "dlv": "^1.1.3",
"dset": "^2.0.1", "dset": "^2.0.1",
"esm": "^3.2.25", "esm": "^3.2.25",
"execa": "^3.4.0",
"fast-glob": "^3.2.4", "fast-glob": "^3.2.4",
"glob-exec": "^0.1.1", "glob-exec": "^0.1.1",
"import-from": "^3.0.0", "import-from": "^3.0.0",

View File

@ -21,6 +21,7 @@
"dlv": "^1.1.3", "dlv": "^1.1.3",
"dset": "^2.0.1", "dset": "^2.0.1",
"esm": "^3.2.25", "esm": "^3.2.25",
"execa": "^3.4.0",
"fast-glob": "^3.2.4", "fast-glob": "^3.2.4",
"glob-exec": "^0.1.1", "glob-exec": "^0.1.1",
"import-from": "^3.0.0", "import-from": "^3.0.0",

View File

@ -191,6 +191,7 @@
"dlv": "^1.1.3", "dlv": "^1.1.3",
"dset": "^2.0.1", "dset": "^2.0.1",
"esm": "^3.2.25", "esm": "^3.2.25",
"execa": "^3.4.0",
"fast-glob": "^3.2.4", "fast-glob": "^3.2.4",
"glob-exec": "^0.1.1", "glob-exec": "^0.1.1",
"import-from": "^3.0.0", "import-from": "^3.0.0",

View File

@ -15,6 +15,7 @@ import * as fs from 'fs'
import { getUtilityConfigMap } from './getUtilityConfigMap' import { getUtilityConfigMap } from './getUtilityConfigMap'
import glob from 'fast-glob' import glob from 'fast-glob'
import normalizePath from 'normalize-path' import normalizePath from 'normalize-path'
import execa from 'execa'
function arraysEqual(arr1, arr2) { function arraysEqual(arr1, arr2) {
return ( return (
@ -33,7 +34,6 @@ export default async function getClassNames(
async function run() { async function run() {
let postcss let postcss
let tailwindcss let tailwindcss
let browserslistModule
let version let version
let featureFlags = { future: [], experimental: [] } let featureFlags = { future: [], experimental: [] }
@ -62,11 +62,6 @@ export default async function getClassNames(
version = importFrom(configDir, 'tailwindcss/package.json').version version = importFrom(configDir, 'tailwindcss/package.json').version
console.log(`Found tailwindcss v${version}: ${tailwindBase}`) console.log(`Found tailwindcss v${version}: ${tailwindBase}`)
try {
// this is not required
browserslistModule = importFrom(tailwindBase, 'browserslist')
} catch (_) {}
try { try {
featureFlags = importFrom(tailwindBase, './lib/featureFlags.js').default featureFlags = importFrom(tailwindBase, './lib/featureFlags.js').default
} catch (_) {} } catch (_) {}
@ -130,11 +125,21 @@ export default async function getClassNames(
} }
const resolvedConfig = resolveConfig({ cwd: configDir, config }) const resolvedConfig = resolveConfig({ cwd: configDir, config })
const browserslist = browserslistModule
? browserslistModule(undefined, { let browserslist = []
path: configDir, try {
const { stdout, stderr } = await execa('browserslist', [], {
preferLocal: true,
localDir: configDir,
cwd: configDir,
}) })
: [] if (stderr) {
throw Error(stderr)
}
browserslist = stdout.split('\n')
} catch (error) {
console.error('Failed to load browserslist:', error)
}
return { return {
version, version,