Skip to content

Commit

Permalink
fix(esbuild): normalize dts
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed May 13, 2023
1 parent 00bc6cc commit 09f3f0b
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 316 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"patch": "generi log patch",
"minor": "generi log minor",
"major": "generi log major",
"prepublishOnly": "pnpm run build:prod"
"prepublishOnly": "pnpm run build:prod && pnpm run node:script"
},
"devDependencies": {
"generi": "^1.2.1",
Expand Down
Binary file not shown.
Binary file not shown.
7 changes: 4 additions & 3 deletions packages/pdfeasy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
"types": "./dist/index.d.ts",
"scripts": {
"format": "prettier src/**/*.ts scripts/**/*.js --write",
"build": "rimraf dist && cross-env NODE_ENV=development node scripts/build.js",
"build:prod": "rimraf dist && cross-env NODE_ENV=production node scripts/build.js",
"build": "rimraf dist && cross-env NODE_ENV=development node scripts/build.js && pnpm run normalizeDts",
"build:prod": "rimraf dist && cross-env NODE_ENV=production node scripts/build.js && pnpm run normalizeDts",
"normalizeDts": "tsup ./src/index.ts --dts && rimraf dist/index.js",
"test": "pnpm build:prod && vitest run --coverage",
"node:script": "node -r esm ./scripts/generate/run-node.js",
"demo": "vite --port 3000"
Expand Down Expand Up @@ -68,14 +69,14 @@
"esbuild": "0.17.18",
"esbuild-plugin-alias": "0.2.1",
"esbuild-plugin-fileloc": "0.0.6",
"esbuild-plugin-d.ts": "1.1.0",
"esbuild-plugin-replace": "1.3.0",
"esbuild-plugin-resolve": "1.0.3",
"esm": "3.2.25",
"node-stdlib-browser": "1.2.0",
"prettier": "2.8.8",
"rimraf": "5.0.0",
"typescript": "5.0.4",
"tsup": "6.7.0",
"vite": "4.3.5",
"vitest": "0.31.0"
}
Expand Down
3 changes: 0 additions & 3 deletions packages/pdfeasy/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { build } = require('esbuild')
const alias = require('esbuild-plugin-alias')
const replace = require('esbuild-plugin-resolve')
const { dtsPlugin } = require("esbuild-plugin-d.ts");

const browserPlugin = require('node-stdlib-browser/helpers/esbuild/plugin')
const stdlib = require('node-stdlib-browser')
Expand Down Expand Up @@ -31,7 +30,6 @@ const client = () => {
Buffer: 'Buffer',
},
plugins: [
dtsPlugin(),
alias({
pdfkit: require.resolve('pdfkit/js/pdfkit.standalone.js'),
fontkit: require.resolve('fontkit-next'),
Expand Down Expand Up @@ -67,7 +65,6 @@ const node = () => {
sourcemap: process.env.NODE_ENV === 'production',
minify: process.env.NODE_ENV === 'production',
plugins: [
dtsPlugin(),
replace({
// See https://github.com/Pzixel/PDFKit-example/pull/1/files
"var fs = _interopDefault(require('fs'));": "var fs = require('fs');",
Expand Down
2 changes: 1 addition & 1 deletion packages/pdfeasy/scripts/generate/simple-pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pdfeasy.add([{ raw: 'A simple pdf!', text: {} }])
pdfeasy
.run({
type: 'server',
serverPath: path.resolve(process.cwd() + '../examples'),
serverPath: path.resolve(process.cwd() + '/examples'),
})
.then(() => {
console.log('simple-pdf.js ready!')
Expand Down
2 changes: 1 addition & 1 deletion packages/pdfeasy/src/content/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const SvgToPNG = (raw: string): Promise<{ raw: string }> => {
}

export const getImageRaw = (raw: string): Promise<ImageRaw> => {
return new Promise(async (res, rej) => {
return new Promise(async (res) => {
if (regex().base64(raw)) {
res({
raw,
Expand Down
1 change: 0 additions & 1 deletion packages/pdfeasy/src/env.d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/pdfeasy/src/pipe/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const resolveContent = async (

if (!content.raw) return

const data = embed ? ` ${raw ?? content.raw}` : raw ?? content.raw
const data = embed ? ` ${raw || content.raw}` : raw || content.raw

await app
.font(getCorrectFontFamily(style?.font || defaults.text.font, style))
Expand Down Expand Up @@ -152,14 +152,14 @@ export const resolveContent = async (

const addCheckbox = async () => {
const backgroundColor = resolveColor(
content.checkbox?.backgroundColor ?? defaults.checkbox.backgroundColor,
content.checkbox?.backgroundColor || defaults.checkbox.backgroundColor,
run
)
const borderColor = resolveColor(
content.checkbox?.borderColor ?? defaults.checkbox.borderColor,
content.checkbox?.borderColor || defaults.checkbox.borderColor,
run
)
const size = content.checkbox?.size ?? defaults.checkbox.size
const size = content.checkbox?.size || defaults.checkbox.size

app.initForm()

Expand Down
2 changes: 1 addition & 1 deletion packages/pdfeasy/src/plugins/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const generate = (instance: pdfeasy): PluginGenerate => {
const Image = async (
str: string,
style: ContentImage,
options: PluginPageImageOptions
_: PluginPageImageOptions
): Promise<void> => {
if (!str) return

Expand Down
57 changes: 29 additions & 28 deletions packages/pdfeasy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": ["dom", "es6", "es2017", "esnext.asynciterable"],
"skipLibCheck": true,
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
"removeComments": false,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"baseUrl": ".",
"declaration": true,
"emitDeclarationOnly": true
},
"include": ["src/**/*.ts"]
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": ["dom", "es6", "es2017", "esnext.asynciterable"],
"skipLibCheck": true,
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
"removeComments": false,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"baseUrl": ".",
"declaration": true,
"declarationMap": true,
"declarationDir": "./dist"
},
"include": ["src/**/*.ts"]
}
Loading

0 comments on commit 09f3f0b

Please sign in to comment.