Skip to content

Commit 3d06117

Browse files
committed
fix(types): copy type definitions into distribution
1 parent de06a31 commit 3d06117

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

scripts/copy-release-files.ts

+64-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { join } from 'node:path'
22
import { fileURLToPath } from 'node:url'
3-
import { readFileSync, writeFileSync, copyFileSync } from 'node:fs'
3+
import {
4+
readFileSync,
5+
writeFileSync,
6+
copyFileSync,
7+
existsSync,
8+
mkdirSync,
9+
rmSync,
10+
readdirSync,
11+
} from 'node:fs'
412

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

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const DEFAULT_VARIABLE_VALUES: Record<string, string> = {
3333
'--tw-scale-z': '1',
3434
}
3535

36-
const tailwind3d = plugin(
36+
const tailwindcss3d = plugin(
3737
(api) => {
3838
const localAPI = api as LocalPluginAPI
3939

@@ -95,4 +95,4 @@ const tailwind3d = plugin(
9595
}
9696
)
9797

98-
export = tailwind3d
98+
export = tailwindcss3d

0 commit comments

Comments
 (0)