mirror of
https://github.com/zhigang1992/react-three-fiber.git
synced 2026-01-12 22:51:27 +08:00
Emit web.d.ts, svg.d.ts and native.d.ts (#270)
This commit is contained in:
committed by
Paul Henschel
parent
241f25d2bd
commit
bb1759040d
@@ -18,9 +18,9 @@
|
||||
"eslint": "eslint src/**/*.{js,ts,jsx,tsx}",
|
||||
"test": "jest",
|
||||
"typecheck": "tsc --noEmit --emitDeclarationOnly false --strict --jsx react",
|
||||
"typegen": "tsc || true && prettier types/**/** --write",
|
||||
"typegen": "tsc && mv dist/src/* dist && rm -rf dist/src || true",
|
||||
"typegen:components": "npx ts-node src/components/generateExports.ts",
|
||||
"copy": "copyfiles package.json readme.md LICENSE dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.optionalDependencies=undefined; this.scripts=undefined; this.husky=undefined; this.prettier=undefined; this.jest=undefined; this['lint-staged']=undefined;\" && mv dist/src/* dist && rm -rf dist/src && cp -r types dist",
|
||||
"copy": "copyfiles package.json readme.md LICENSE dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.optionalDependencies=undefined; this.scripts=undefined; this.husky=undefined; this.prettier=undefined; this.jest=undefined; this['lint-staged']=undefined;\"",
|
||||
"pack-dist": "cd dist && yarn pack && mv *.tgz .."
|
||||
},
|
||||
"husky": {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import path from 'path'
|
||||
import { promises as fs } from 'fs'
|
||||
import babel from 'rollup-plugin-babel'
|
||||
import resolve from 'rollup-plugin-node-resolve'
|
||||
import json from 'rollup-plugin-json'
|
||||
import compiler from '@ampproject/rollup-plugin-closure-compiler'
|
||||
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
|
||||
|
||||
const root = process.platform === 'win32' ? path.resolve('/') : '/'
|
||||
@@ -25,6 +25,16 @@ const getBabelOptions = ({ useESModules }, targets) => ({
|
||||
],
|
||||
})
|
||||
|
||||
function targetTypings(entry, out) {
|
||||
return {
|
||||
writeBundle() {
|
||||
return fs.lstat(`dist/${out}`).catch(() => {
|
||||
return fs.writeFile(`dist/${out}.d.ts`, `export * from "./${entry}"`)
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function createConfig(entry, out) {
|
||||
return [
|
||||
{
|
||||
@@ -36,6 +46,7 @@ function createConfig(entry, out) {
|
||||
babel(getBabelOptions({ useESModules: true }, '>1%, not dead, not ie 11, not op_mini all')),
|
||||
sizeSnapshot(),
|
||||
resolve({ extensions }),
|
||||
targetTypings(entry, out),
|
||||
//compiler(),
|
||||
],
|
||||
},
|
||||
@@ -43,7 +54,13 @@ function createConfig(entry, out) {
|
||||
input: `./src/${entry}`,
|
||||
output: { file: `dist/${out}.cjs.js`, format: 'cjs' },
|
||||
external,
|
||||
plugins: [json(), babel(getBabelOptions({ useESModules: false })), sizeSnapshot(), resolve({ extensions })],
|
||||
plugins: [
|
||||
json(),
|
||||
babel(getBabelOptions({ useESModules: false })),
|
||||
sizeSnapshot(),
|
||||
resolve({ extensions }),
|
||||
targetTypings(entry, out),
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user