Skip to content

Commit 7f813bc

Browse files
committed
Tweak export script
1 parent f08be86 commit 7f813bc

File tree

5 files changed

+614
-802
lines changed

5 files changed

+614
-802
lines changed

demo/src/demoData/dataDefinitions.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line
12
// @ts-nocheck
23

34
import React from 'react'

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
"demo:package": "yarn build-package && cd demo && yarn && yarn start:package",
3030
"prebuild": "yarn lint",
3131
"build": "rollup -c && rm -R build/dts",
32+
"postbuild": "node ./scripts/cleanBuildTypes.cjs",
3233
"build-package": "yarn build && yarn pack --filename package.tgz && tar -xzf package.tgz -C demo/src && rm package.tgz",
3334
"lint": "eslint",
34-
"postbuild": "node ./scripts/cleanBuildTypes.cjs",
3535
"prepareReadme": "python3 scripts/build_npm_readme.py",
3636
"prepublishOnly": "yarn build && yarn prepareReadme && python3 scripts/use_npm_readme.py prepare",
3737
"postpublish": "python3 scripts/use_npm_readme.py restore && cd demo && yarn add json-edit-react@latest",
@@ -42,11 +42,6 @@
4242
"peerDependencies": {
4343
"react": ">=16.0.0"
4444
},
45-
"resolutions": {
46-
"strip-ansi": "6.0.1",
47-
"string-width": "4.2.2",
48-
"wrap-ansi": "7.0.0"
49-
},
5045
"dependencies": {
5146
"object-property-assigner": "^1.3.5",
5247
"object-property-extractor": "^1.0.13"

rollup.config.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ export default [
2525
del({ targets: 'build/*' }),
2626
styles({ minimize: true }),
2727
peerDepsExternal({ includeDependencies: true }),
28-
typescript({ module: 'ESNext', target: 'es6' }),
28+
typescript({
29+
module: 'ESNext',
30+
target: 'es6',
31+
declaration: true,
32+
declarationDir: 'build/dts',
33+
}),
2934
terser(),
3035
bundleSize(),
3136
sizes(),
@@ -34,7 +39,7 @@ export default [
3439
},
3540
// Types
3641
{
37-
input: './build/dts/index.d.ts',
42+
input: 'build/dts/index.d.ts',
3843
output: [{ file: 'build/index.d.ts', format: 'es' }],
3944
external: [/\.css$/],
4045
plugins: [dts()],

scripts/cleanBuildTypes.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
const fs = require('fs-extra')
2121

22-
const exportTextMatch = /^export { type .+ };$/m
22+
const exportTextMatch = /^export type { .+ };$/m
2323

2424
const cleanBuildTypes = async () => {
2525
const data = await fs.readFile('build/index.d.ts', 'utf8')
2626
const exportText = exportTextMatch.exec(data)[0]
27-
const cleanedText = exportText.replace(/ type(.+?)/gm, '$1')
27+
const cleanedText = '\n// Types\n' + exportText.replace('export type ', 'export ')
2828
const newData = data.replace(exportText, cleanedText)
2929
console.log('Cleaning up type declarations...')
3030

0 commit comments

Comments
 (0)