Skip to content

Commit 5c542f5

Browse files
committed
fix: move type definitions into new index files
1 parent 700298c commit 5c542f5

File tree

6 files changed

+28
-77
lines changed

6 files changed

+28
-77
lines changed

scripts/copy-release-files.ts

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import {
2-
copyFileSync,
3-
existsSync,
4-
mkdirSync,
5-
readdirSync,
6-
readFileSync,
7-
rmSync,
8-
writeFileSync,
9-
} from 'node:fs'
1+
import { copyFileSync, readFileSync, writeFileSync } from 'node:fs'
102
import { join } from 'node:path'
113
import { fileURLToPath } from 'node:url'
124

@@ -37,58 +29,3 @@ docFiles.forEach((docFile) => {
3729
const docPackageURL = fileURLToPath(new URL(docPackagePath, import.meta.url))
3830
copyFileSync(docURL, docPackageURL)
3931
})
40-
41-
// Copy any type declarations that are needed in the distribution
42-
const typeGroups = [
43-
{ dir: 'common', files: ['index.d.ts'] },
44-
{ dir: 'css-animations', files: ['index.d.ts'] },
45-
{ dir: 'css-utilities', files: ['index.d.ts'] },
46-
]
47-
typeGroups.forEach((typeGroup) => {
48-
const typeGroupPath = join('..', '..', 'src', typeGroup.dir)
49-
const typeGroupPackagePath = join('..', '..', 'dist', 'types', typeGroup.dir)
50-
const typeGroupPackageURL = fileURLToPath(
51-
new URL(typeGroupPackagePath, import.meta.url)
52-
)
53-
54-
if (!existsSync(typeGroupPackageURL)) {
55-
mkdirSync(typeGroupPackageURL, { recursive: true })
56-
}
57-
58-
typeGroup.files.forEach((typeFile) => {
59-
const typePath = join(typeGroupPath, typeFile)
60-
const typeURL = fileURLToPath(new URL(typePath, import.meta.url))
61-
const typePackagePath = join(typeGroupPackagePath, typeFile)
62-
const typePackageURL = fileURLToPath(
63-
new URL(typePackagePath, import.meta.url)
64-
)
65-
copyFileSync(typeURL, typePackageURL)
66-
})
67-
})
68-
69-
// Remove empty javascript files generated from the type declaration files
70-
typeGroups.forEach((typeGroup) => {
71-
const typeGroupPackagePath = join('..', '..', 'dist', typeGroup.dir)
72-
typeGroup.files.forEach((typeFile) => {
73-
const typePackagePath = join(
74-
typeGroupPackagePath,
75-
typeFile.replace(/\.d\.ts$/, '.d.js')
76-
)
77-
const typePackageURL = fileURLToPath(
78-
new URL(typePackagePath, import.meta.url)
79-
)
80-
if (existsSync(typePackageURL)) {
81-
rmSync(typePackageURL)
82-
}
83-
})
84-
const typeGroupPackageURL = fileURLToPath(
85-
new URL(typeGroupPackagePath, import.meta.url)
86-
)
87-
if (!existsSync(typeGroupPackageURL)) {
88-
return
89-
}
90-
const typeGroupDir = readdirSync(typeGroupPackageURL)
91-
if (typeGroupDir.length < 1) {
92-
rmSync(typeGroupPackageURL, { recursive: true })
93-
}
94-
})
File renamed without changes.

src/css-animations/index.d.ts renamed to src/css-animations/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ declare module '@/css-animations' {
1010
animation: (pluginUtilities: PluginUtils) => void
1111
}
1212
}
13+
14+
export * from './bounce'
15+
export * from './bounce-and-spin'
16+
export * from './spin'

src/css-utilities/__tests__/perspective/normalise-function-values.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Perspective } from '../../perspective'
1+
import { Perspective } from '../..'
22

33
describe('css-utilities', () => {
44
describe('Perspective', () => {

src/css-utilities/index.d.ts renamed to src/css-utilities/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ declare module '@/css-utilities' {
1111
normaliseFunctionValues?: (values: Record<string, any>) => string
1212
}
1313
}
14+
15+
export * from './backface'
16+
export * from './perspective'
17+
export * from './perspective-origin'
18+
export * from './scale'
19+
export * from './transform'
20+
export * from './transform-box'
21+
export * from './transform-core'
22+
export * from './transform-style'
23+
export * from './translate'

src/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import plugin from 'tailwindcss/plugin'
22

33
import { type LocalPluginAPI } from '@/common'
4-
import { Bounce } from '@/css-animations/bounce'
5-
import { BounceAndSpin } from '@/css-animations/bounce-and-spin'
6-
import { Spin } from '@/css-animations/spin'
7-
import { Backface } from '@/css-utilities/backface'
8-
import { Perspective } from '@/css-utilities/perspective'
9-
import { PerspectiveOrigin } from '@/css-utilities/perspective-origin'
10-
import { Scale } from '@/css-utilities/scale'
11-
import { Transform } from '@/css-utilities/transform'
12-
import { TransformBox } from '@/css-utilities/transform-box'
13-
import { TransformCore } from '@/css-utilities/transform-core'
14-
import { TransformStyle } from '@/css-utilities/transform-style'
15-
import { Translate } from '@/css-utilities/translate'
4+
import { Bounce, BounceAndSpin, Spin } from '@/css-animations'
5+
import {
6+
Backface,
7+
Perspective,
8+
PerspectiveOrigin,
9+
Scale,
10+
Transform,
11+
TransformBox,
12+
TransformCore,
13+
TransformStyle,
14+
Translate,
15+
} from '@/css-utilities'
1616
import { ensureBoolean } from '@/utils/ensure'
1717

1818
// Default CSS variables, modelled from core

0 commit comments

Comments
 (0)