diff --git a/package-lock.json b/package-lock.json index 97a5434a..9c1ff08b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,12 +57,11 @@ "eslint-plugin-unicorn": "^44.0.2", "glob-all": "^3.3.0", "husky": "4.3.8", - "import-fresh": "^3.3.0", "jest": "^29.2.2", "lint-staged": "^13.0.3", "microbundle": "^0.15.1", "nodemon": "^2.0.20", - "prettier": "^2.7.1", + "prettier": "^2.8.7", "react": "^18.2.0", "string-similarity": "^4.0.4", "styled-components": "^5.3.6", @@ -10798,9 +10797,9 @@ } }, "node_modules/prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.7", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", + "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -21033,9 +21032,9 @@ "dev": true }, "prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.7", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", + "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", "dev": true }, "prettier-linter-helpers": { diff --git a/package.json b/package.json index 66137bc1..ae82d6e5 100644 --- a/package.json +++ b/package.json @@ -118,12 +118,11 @@ "eslint-plugin-unicorn": "^44.0.2", "glob-all": "^3.3.0", "husky": "4.3.8", - "import-fresh": "^3.3.0", "jest": "^29.2.2", "lint-staged": "^13.0.3", "microbundle": "^0.15.1", "nodemon": "^2.0.20", - "prettier": "^2.7.1", + "prettier": "^2.8.7", "react": "^18.2.0", "string-similarity": "^4.0.4", "styled-components": "^5.3.6", diff --git a/src/core/lib/configHelpers.ts b/src/core/lib/configHelpers.ts index 3804d48f..635daf6f 100644 --- a/src/core/lib/configHelpers.ts +++ b/src/core/lib/configHelpers.ts @@ -1,7 +1,6 @@ import { resolve, dirname } from 'path' import { existsSync } from 'fs' import escalade from 'escalade/sync' -import requireFresh from 'import-fresh' import { configTwinValidators, configDefaultsTwin } from './twinConfig' import defaultTwinConfig from './defaultTailwindConfig' import { resolveTailwindConfig, getAllConfigs } from './util/twImports' @@ -15,6 +14,7 @@ import type { Assert, AssertContext, } from 'core/types' +import loadConfig from 'tailwindcss/loadConfig' type Validator = [(value: unknown) => boolean, string] @@ -76,7 +76,7 @@ function getTailwindConfig({ const configs = [ // User config - ...(configExists ? getAllConfigs(requireFresh(configPath as string)) : []), + ...(configExists ? getAllConfigs(loadConfig(configPath as string)) : []), // Default config ...getAllConfigs(defaultTwinConfig), ] diff --git a/tests/__fixtures__/config/tailwind.config.js b/tests/__fixtures__/config/tailwind.config.ts similarity index 94% rename from tests/__fixtures__/config/tailwind.config.js rename to tests/__fixtures__/config/tailwind.config.ts index ab5b8dd5..98c6028d 100644 --- a/tests/__fixtures__/config/tailwind.config.js +++ b/tests/__fixtures__/config/tailwind.config.ts @@ -1,4 +1,6 @@ -module.exports = { +import type { Config } from 'tailwindcss' + +export default { theme: { animation: { 'zoom-.5': 'zoom-.5 2s', @@ -50,4 +52,4 @@ module.exports = { customFontWeightAsNumber: 800, }, }, -} +} satisfies Config diff --git a/tests/plugin.test.js b/tests/plugin.test.js index 1b4acc52..8f4bc4df 100644 --- a/tests/plugin.test.js +++ b/tests/plugin.test.js @@ -30,6 +30,11 @@ pluginTester({ ) && { config: path.join(path.dirname(file), 'tailwind.config.js'), }), + ...(fs.existsSync( + path.join(path.dirname(file), 'tailwind.config.ts') + ) && { + config: path.join(path.dirname(file), 'tailwind.config.ts'), + }), ...(fs.existsSync(configFile(file)) && JSON.parse(fs.readFileSync(configFile(file), 'utf8'))), }, diff --git a/types/tests/__fixtures__/config/tailwind.config.d.ts b/types/tests/__fixtures__/config/tailwind.config.d.ts new file mode 100644 index 00000000..83fa2e41 --- /dev/null +++ b/types/tests/__fixtures__/config/tailwind.config.d.ts @@ -0,0 +1,52 @@ +declare const _default: { + theme: { + animation: { + 'zoom-.5': string + } + colors: { + number: number + purple: string + 'purple-hyphen': string + mycolors: { + DEFAULT: string + 'a-purple': string + 'a-number': number + } + 'my-blue': { + 100: string + } + 'color-opacity': ({ opacityVariable }: { opacityVariable: any }) => string + color: { + deep: { + config: { + 500: string + } + } + } + blue: { + DEFAULT: string + gray: { + 200: string + } + } + 'blue-gray': { + DEFAULT: string + 200: string + } + 'blue-gray-green': { + DEFAULT: string + 200: string + 'deep-dish': { + DEFAULT: string + 200: string + } + } + 'blue-gray-green-pink': string + } + fontWeight: { + customFontWeightAsString: string + customFontWeightAsNumber: number + } + } +} +export default _default