Skip to content

Commit

Permalink
build: fix build script + package entries
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 25, 2020
1 parent 634e5d1 commit d44cf64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
"bin": {
"vite": "bin/vite.js"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/node/index.js",
"types": "dist/node/index.d.ts",
"files": [
"bin",
"dist/**/*.js",
"dist/**/*.d.ts",
"importMeta.d.ts"
"dist/**/*.d.ts"
],
"engines": {
"node": ">=10.16.0"
Expand Down
10 changes: 9 additions & 1 deletion scripts/patchTypes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
const fs = require('fs')
const path = require('path')

const indexPath = path.resolve(__dirname, '../dist/index.d.ts')
// copy file
const metaPath = path.resolve(__dirname, '../importMeta.d.ts')
fs.writeFileSync(
path.resolve(__dirname, '../dist/importMeta.d.ts'),
fs.readFileSync(metaPath)
)

// inject import
const indexPath = path.resolve(__dirname, '../dist/node/index.d.ts')
const content = fs.readFileSync(indexPath, 'utf-8')
fs.writeFileSync(indexPath, content + `\nimport '../importMeta'`)

0 comments on commit d44cf64

Please sign in to comment.