Skip to content

Commit

Permalink
fix(types): modify file suffix after build types so that it can expor…
Browse files Browse the repository at this point in the history
…t correct types (#6051)

* fix(types): modify file suffix after build types so that it can export the correct types

* fix: can't export type only

* fix: ignore type check
  • Loading branch information
dongnaebi authored May 29, 2024
1 parent 7bf3b1a commit 7827350
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
"transpile": "npm run build:version && node scripts/transpile.mjs && echo '{ \"type\": \"module\" }' > test_tmp/package.json",
"build:version": "node ./scripts/update-version-variable.mjs",
"build:esm": "npm run build:version && rimraf -rf --max-retries=3 dist/esm && cross-env NODE_ENV=es6 babel src --out-dir dist/esm --source-maps --extensions \".ts,.js\" && echo '{ \"type\": \"module\", \"sideEffects\": false }' > dist/esm/package.json",
"build:types": "npm run build:version && rimraf -rf --max-retries=3 ./dist/types && tsc --project ./config/tsconfig.types.json && cp -r ./src/types ./dist/types/types",
"build:types": "npm run build:version && rimraf -rf --max-retries=3 ./dist/types && tsc --project ./config/tsconfig.types.json && cp -r ./src/types ./dist/types/types && node ./scripts/fix-types.mjs",
"build": "npm run clear && npm run build:version && concurrently \"npm run transpile\" \"npm run build:esm\" \"npm run build:types\" \"npm run build:plugins\"",
"build:plugins": "node ./scripts/generate-plugins-package-json.mjs",
"build:webpack": "npm run build && cross-env NODE_ENV=build webpack --config ./config/webpack.config.js",
Expand Down Expand Up @@ -582,4 +582,4 @@
"webpack-cli": "5.1.4",
"webpack-dev-server": "5.0.4"
}
}
}
16 changes: 16 additions & 0 deletions scripts/fix-types.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { promises as fs } from 'node:fs'

async function main () {
const file = './dist/types/index.d.ts'
try {
let content = await fs.readFile(file, { encoding: 'utf-8' })
content = content.replaceAll('.ts', '.d.ts')
content = `// @ts-nocheck
${content}`
await fs.writeFile(file, content)
} catch (err) {
console.error(`Fix types error:${err.message}`)
process.exit(1)
}
}
main()

0 comments on commit 7827350

Please sign in to comment.