Skip to content

Commit 09f3f0b

Browse files
committed
fix(esbuild): normalize dts
1 parent 00bc6cc commit 09f3f0b

12 files changed

Lines changed: 57 additions & 316 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"patch": "generi log patch",
1414
"minor": "generi log minor",
1515
"major": "generi log major",
16-
"prepublishOnly": "pnpm run build:prod"
16+
"prepublishOnly": "pnpm run build:prod && pnpm run node:script"
1717
},
1818
"devDependencies": {
1919
"generi": "^1.2.1",
3.63 KB
Binary file not shown.

packages/pdfeasy/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
"types": "./dist/index.d.ts",
3737
"scripts": {
3838
"format": "prettier src/**/*.ts scripts/**/*.js --write",
39-
"build": "rimraf dist && cross-env NODE_ENV=development node scripts/build.js",
40-
"build:prod": "rimraf dist && cross-env NODE_ENV=production node scripts/build.js",
39+
"build": "rimraf dist && cross-env NODE_ENV=development node scripts/build.js && pnpm run normalizeDts",
40+
"build:prod": "rimraf dist && cross-env NODE_ENV=production node scripts/build.js && pnpm run normalizeDts",
41+
"normalizeDts": "tsup ./src/index.ts --dts && rimraf dist/index.js",
4142
"test": "pnpm build:prod && vitest run --coverage",
4243
"node:script": "node -r esm ./scripts/generate/run-node.js",
4344
"demo": "vite --port 3000"
@@ -68,14 +69,14 @@
6869
"esbuild": "0.17.18",
6970
"esbuild-plugin-alias": "0.2.1",
7071
"esbuild-plugin-fileloc": "0.0.6",
71-
"esbuild-plugin-d.ts": "1.1.0",
7272
"esbuild-plugin-replace": "1.3.0",
7373
"esbuild-plugin-resolve": "1.0.3",
7474
"esm": "3.2.25",
7575
"node-stdlib-browser": "1.2.0",
7676
"prettier": "2.8.8",
7777
"rimraf": "5.0.0",
7878
"typescript": "5.0.4",
79+
"tsup": "6.7.0",
7980
"vite": "4.3.5",
8081
"vitest": "0.31.0"
8182
}

packages/pdfeasy/scripts/build.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const { build } = require('esbuild')
22
const alias = require('esbuild-plugin-alias')
33
const replace = require('esbuild-plugin-resolve')
4-
const { dtsPlugin } = require("esbuild-plugin-d.ts");
54

65
const browserPlugin = require('node-stdlib-browser/helpers/esbuild/plugin')
76
const stdlib = require('node-stdlib-browser')
@@ -31,7 +30,6 @@ const client = () => {
3130
Buffer: 'Buffer',
3231
},
3332
plugins: [
34-
dtsPlugin(),
3533
alias({
3634
pdfkit: require.resolve('pdfkit/js/pdfkit.standalone.js'),
3735
fontkit: require.resolve('fontkit-next'),
@@ -67,7 +65,6 @@ const node = () => {
6765
sourcemap: process.env.NODE_ENV === 'production',
6866
minify: process.env.NODE_ENV === 'production',
6967
plugins: [
70-
dtsPlugin(),
7168
replace({
7269
// See https://github.com/Pzixel/PDFKit-example/pull/1/files
7370
"var fs = _interopDefault(require('fs'));": "var fs = require('fs');",

packages/pdfeasy/scripts/generate/simple-pdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pdfeasy.add([{ raw: 'A simple pdf!', text: {} }])
1313
pdfeasy
1414
.run({
1515
type: 'server',
16-
serverPath: path.resolve(process.cwd() + '../examples'),
16+
serverPath: path.resolve(process.cwd() + '/examples'),
1717
})
1818
.then(() => {
1919
console.log('simple-pdf.js ready!')

packages/pdfeasy/src/content/image.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const SvgToPNG = (raw: string): Promise<{ raw: string }> => {
4242
}
4343

4444
export const getImageRaw = (raw: string): Promise<ImageRaw> => {
45-
return new Promise(async (res, rej) => {
45+
return new Promise(async (res) => {
4646
if (regex().base64(raw)) {
4747
res({
4848
raw,

packages/pdfeasy/src/env.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/pdfeasy/src/pipe/factory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const resolveContent = async (
6969

7070
if (!content.raw) return
7171

72-
const data = embed ? ` ${raw ?? content.raw}` : raw ?? content.raw
72+
const data = embed ? ` ${raw || content.raw}` : raw || content.raw
7373

7474
await app
7575
.font(getCorrectFontFamily(style?.font || defaults.text.font, style))
@@ -152,14 +152,14 @@ export const resolveContent = async (
152152

153153
const addCheckbox = async () => {
154154
const backgroundColor = resolveColor(
155-
content.checkbox?.backgroundColor ?? defaults.checkbox.backgroundColor,
155+
content.checkbox?.backgroundColor || defaults.checkbox.backgroundColor,
156156
run
157157
)
158158
const borderColor = resolveColor(
159-
content.checkbox?.borderColor ?? defaults.checkbox.borderColor,
159+
content.checkbox?.borderColor || defaults.checkbox.borderColor,
160160
run
161161
)
162-
const size = content.checkbox?.size ?? defaults.checkbox.size
162+
const size = content.checkbox?.size || defaults.checkbox.size
163163

164164
app.initForm()
165165

packages/pdfeasy/src/plugins/page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const generate = (instance: pdfeasy): PluginGenerate => {
7878
const Image = async (
7979
str: string,
8080
style: ContentImage,
81-
options: PluginPageImageOptions
81+
_: PluginPageImageOptions
8282
): Promise<void> => {
8383
if (!str) return
8484

0 commit comments

Comments
 (0)