Skip to content

Commit

Permalink
feat: add esbuild export (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Jul 4, 2022
1 parent 0f3042c commit 72fd07c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,3 @@ dist

# IDE
.idea
/*.d.ts
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"types": "index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
Expand Down Expand Up @@ -50,9 +50,16 @@
"./*": "./*"
},
"files": [
"dist",
"*.d.ts"
"dist"
],
"typesVersions": {
"*": {
"*": [
"./dist/*",
"./*"
]
}
},
"scripts": {
"build": "tsup",
"dev": "tsup --watch src",
Expand Down
3 changes: 0 additions & 3 deletions scripts/postbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ async function run() {
let code = await fs.readFile(file, 'utf8')
code += 'if (module.exports.default) module.exports = module.exports.default;'
await fs.writeFile(file, code)
// generate submodule .d.ts redirecting
const name = basename(file, '.js')
await fs.writeFile(`${name}.d.ts`, `export { default } from './dist/${name}'\n`)
}
}

Expand Down

0 comments on commit 72fd07c

Please sign in to comment.