Skip to content

Commit

Permalink
chore: fix NODE_VERSION deploy error
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Feb 12, 2025
1 parent 5c847a3 commit 406a9a6
Show file tree
Hide file tree
Showing 9 changed files with 502 additions and 454 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-panthers-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tailwindcss-config": major
---

feat!: change default return result
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ publish = "dist"
command = "pnpm run build"

[build.environment]
NODE_VERSION = "20"
NODE_VERSION = "22"

[[redirects]]
from = "/*"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"@commitlint/types": "^19.5.0",
"@eslint/config-inspector": "^1.0.0",
"@icebreakers/eslint-config": "^1.0.0",
"@icebreakers/monorepo": "^0.7.2",
"@icebreakers/monorepo": "^0.7.4",
"@icebreakers/stylelint-config": "^1.0.0",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^28.0.2",
Expand Down Expand Up @@ -179,7 +179,7 @@
"dlv": "^1.1.3",
"domhandler": "^5.0.3",
"es-toolkit": "^1.32.0",
"eslint": "^9.20.0",
"eslint": "^9.20.1",
"execa": "^9.5.2",
"express": "^4.21.2",
"fast-glob": "^3.3.3",
Expand All @@ -202,7 +202,7 @@
"normalize-newline": "^4.1.0",
"npm-registry-fetch": "^18.0.2",
"only-allow": "^1.2.1",
"pathe": "^2.0.2",
"pathe": "^2.0.3",
"pkg-types": "^1.3.1",
"postcss": "^8.5.2",
"postcss-js": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/init/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"@weapp-tailwindcss/shared": "workspace:*",
"fs-extra": "^11.3.0",
"npm-registry-fetch": "^18.0.2",
"pathe": "^2.0.2"
"pathe": "^2.0.3"
}
}
25 changes: 16 additions & 9 deletions packages/tailwindcss-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,23 @@ const jiti = createJiti(import.meta.url)
export interface LoadConfigOptions {
cwd: string
config: string
moduleName: string
}

const moduleName = 'tailwind'
export type LoadConfigResult = null | {
filepath: string
config: Config
isEmpty?: boolean
}

export async function loadConfig(options?: Partial<LoadConfigOptions>) {
const { config, cwd } = defuOverrideArray<LoadConfigOptions, Partial<LoadConfigOptions>[]>(options as LoadConfigOptions, {
cwd: process.cwd(),
})
export async function loadConfig(options?: Partial<LoadConfigOptions>): Promise<LoadConfigResult> {
const { config, cwd, moduleName } = defuOverrideArray<LoadConfigOptions, Partial<LoadConfigOptions>[]>(
options as LoadConfigOptions,
{
cwd: process.cwd(),
moduleName: 'tailwind',
},
)

const searcher = lilconfig('tailwindcss', {
searchPlaces: [
Expand All @@ -40,11 +49,9 @@ export async function loadConfig(options?: Partial<LoadConfigOptions>) {

if (typeof config === 'string' && config) {
const configPath = path.isAbsolute(config) ? config : path.resolve(cwd, config)
const result = await searcher.load(configPath)
return result?.config as Config | undefined
return await searcher.load(configPath)
}
else {
const result = await searcher.search(cwd)
return result?.config as Config | undefined
return await searcher.search(cwd)
}
}
238 changes: 124 additions & 114 deletions packages/tailwindcss-config/test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,87 +2,7 @@

exports[`index > cjs 1`] = `
{
"content": [
"./src/**/*.{html,js}",
],
"theme": {
"colors": {
"blue": "#1fb6ff",
"gray": "#8492a6",
"gray-dark": "#273444",
"gray-light": "#d3dce6",
"green": "#13ce66",
"orange": "#ff7849",
"pink": "#ff49db",
"purple": "#7e5bef",
"yellow": "#ffc82c",
},
"extend": {
"borderRadius": {
"4xl": "2rem",
},
"spacing": {
"8xl": "96rem",
"9xl": "128rem",
},
},
"fontFamily": {
"sans": [
"Graphik",
"sans-serif",
],
"serif": [
"Merriweather",
"serif",
],
},
},
}
`;

exports[`index > cwd 1`] = `
{
"content": [
"./src/**/*.{html,js}",
],
"theme": {
"colors": {
"blue": "#1fb6ff",
"gray": "#8492a6",
"gray-dark": "#273444",
"gray-light": "#d3dce6",
"green": "#13ce66",
"orange": "#ff7849",
"pink": "#ff49db",
"purple": "#7e5bef",
"yellow": "#ffc82c",
},
"extend": {
"borderRadius": {
"4xl": "2rem",
},
"spacing": {
"8xl": "96rem",
"9xl": "128rem",
},
},
"fontFamily": {
"sans": [
"Graphik",
"sans-serif",
],
"serif": [
"Merriweather",
"serif",
],
},
},
}
`;

exports[`index > js 1`] = `
{
"default": {
"config": {
"content": [
"./src/**/*.{html,js}",
],
Expand Down Expand Up @@ -122,9 +42,9 @@ exports[`index > js 1`] = `
}
`;

exports[`index > mjs 1`] = `
exports[`index > cwd 1`] = `
{
"default": {
"config": {
"content": [
"./src/**/*.{html,js}",
],
Expand Down Expand Up @@ -164,42 +84,132 @@ exports[`index > mjs 1`] = `
}
`;

exports[`index > ts 1`] = `
exports[`index > js 1`] = `
{
"default": {
"content": [
"./src/**/*.{html,js}",
],
"theme": {
"colors": {
"blue": "#1fb6ff",
"gray": "#8492a6",
"gray-dark": "#273444",
"gray-light": "#d3dce6",
"green": "#13ce66",
"orange": "#ff7849",
"pink": "#ff49db",
"purple": "#7e5bef",
"yellow": "#ffc82c",
"config": {
"default": {
"content": [
"./src/**/*.{html,js}",
],
"theme": {
"colors": {
"blue": "#1fb6ff",
"gray": "#8492a6",
"gray-dark": "#273444",
"gray-light": "#d3dce6",
"green": "#13ce66",
"orange": "#ff7849",
"pink": "#ff49db",
"purple": "#7e5bef",
"yellow": "#ffc82c",
},
"extend": {
"borderRadius": {
"4xl": "2rem",
},
"spacing": {
"8xl": "96rem",
"9xl": "128rem",
},
},
"fontFamily": {
"sans": [
"Graphik",
"sans-serif",
],
"serif": [
"Merriweather",
"serif",
],
},
},
"extend": {
"borderRadius": {
"4xl": "2rem",
},
},
}
`;

exports[`index > mjs 1`] = `
{
"config": {
"default": {
"content": [
"./src/**/*.{html,js}",
],
"theme": {
"colors": {
"blue": "#1fb6ff",
"gray": "#8492a6",
"gray-dark": "#273444",
"gray-light": "#d3dce6",
"green": "#13ce66",
"orange": "#ff7849",
"pink": "#ff49db",
"purple": "#7e5bef",
"yellow": "#ffc82c",
},
"spacing": {
"8xl": "96rem",
"9xl": "128rem",
"extend": {
"borderRadius": {
"4xl": "2rem",
},
"spacing": {
"8xl": "96rem",
"9xl": "128rem",
},
},
"fontFamily": {
"sans": [
"Graphik",
"sans-serif",
],
"serif": [
"Merriweather",
"serif",
],
},
},
"fontFamily": {
"sans": [
"Graphik",
"sans-serif",
],
"serif": [
"Merriweather",
"serif",
],
},
},
}
`;

exports[`index > ts 1`] = `
{
"config": {
"default": {
"content": [
"./src/**/*.{html,js}",
],
"theme": {
"colors": {
"blue": "#1fb6ff",
"gray": "#8492a6",
"gray-dark": "#273444",
"gray-light": "#d3dce6",
"green": "#13ce66",
"orange": "#ff7849",
"pink": "#ff49db",
"purple": "#7e5bef",
"yellow": "#ffc82c",
},
"extend": {
"borderRadius": {
"4xl": "2rem",
},
"spacing": {
"8xl": "96rem",
"9xl": "128rem",
},
},
"fontFamily": {
"sans": [
"Graphik",
"sans-serif",
],
"serif": [
"Merriweather",
"serif",
],
},
},
},
},
Expand Down
18 changes: 18 additions & 0 deletions packages/tailwindcss-config/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ import path from 'pathe'

const fixturesDir = path.resolve(import.meta.dirname, './fixtures')

vi.mock(import('@/index'), async (importOriginal) => {
const { loadConfig: _loadConfig } = await importOriginal()

function loadConfig(...args: Parameters<typeof _loadConfig>) {
return _loadConfig(...args).then((x) => {
if (x && 'filepath' in x) {
// @ts-ignore
delete x.filepath
}
return x
})
}

return {
loadConfig,
}
})

describe('index', () => {
it('cwd', async () => {
expect(await loadConfig({
Expand Down
5 changes: 4 additions & 1 deletion packages/tailwindcss-injector/src/postcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ const creator: PluginCreator<Partial<Options>> = (options) => {
const cfg = typeof config === 'function' ? config(root.source?.input) : config
let tailwindcssConfig: Config | undefined
if (typeof cfg === 'string') {
tailwindcssConfig = await loadConfig({
const result = await loadConfig({
cwd,
config: cfg,
})
if (result) {
tailwindcssConfig = result.config
}
}
else {
tailwindcssConfig = (cfg ?? {
Expand Down
Loading

0 comments on commit 406a9a6

Please sign in to comment.