Skip to content

Commit ee28790

Browse files
committed
fix: export everything to npm
1 parent 42fb2ea commit ee28790

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

.npm/compile.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { mkdirSync, rmSync, writeFileSync } from 'node:fs'
77
import { glob } from 'node:fs/promises'
88
import path, { dirname } from 'node:path'
99
import { fileURLToPath } from 'node:url'
10-
import tsconfig from './tsconfig.npm.json' with { type: 'json' }
1110
import { updateImports } from './updateImports.ts'
1211

1312
const __dirname = dirname(fileURLToPath(import.meta.url))
@@ -20,9 +19,9 @@ try {
2019
// pass
2120
}
2221

23-
for await (const file of glob(
24-
`./.npm/{${tsconfig.include.join(',')}}/**/*.ts`,
25-
)) {
22+
const srcDir = path.join(__dirname, `../src/`)
23+
24+
for await (const file of glob(path.join(srcDir, `**/*.ts`))) {
2625
if (file.endsWith('.spec.ts')) continue
2726
let compiled = (
2827
await swc.transformFile(file, {
@@ -40,7 +39,10 @@ for await (const file of glob(
4039

4140
compiled = updateImports(compiled)
4241

43-
const targetFile = path.join(outDir, file.replace(/\.ts$/, '.js'))
42+
const targetFile = path.join(
43+
outDir,
44+
file.replace(srcDir, '').replace(/\.ts$/, '.js'),
45+
)
4446

4547
mkdirSync(dirname(targetFile), { recursive: true })
4648

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
"exports": {
66
"./*": {
77
"import": {
8-
"types": "./npm/src/*.d.ts",
9-
"default": "./npm/src/*.js"
8+
"types": "./npm/*.d.ts",
9+
"default": "./npm/*.js"
1010
}
1111
}
1212
},
1313
"type": "module",
1414
"scripts": {
1515
"test": "tsx --no-warnings --test ./src/*.spec.ts",
1616
"prepare": "husky",
17-
"prepublishOnly": "node --experimental-strip-types ./.npm/compile.ts && npx tsc -P ./.npm/tsconfig.npm.json --outDir ./npm"
17+
"prepublishOnly": "node --experimental-strip-types ./.npm/compile.ts && npx tsc -P ./.npm/tsconfig.npm.json --outDir ./npm && mv ./npm/src/* ./npm"
1818
},
1919
"repository": {
2020
"type": "git",

0 commit comments

Comments
 (0)