@pdfme/common 5.5.10-dev.11 → 5.5.10-dev.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/package.json +30 -55
  2. package/set-version.js +9 -4
  3. package/src/dynamicTemplate.ts +3 -1
  4. package/src/expression.ts +14 -5
  5. package/src/helper.ts +9 -3
  6. package/src/types.ts +20 -15
  7. package/tsconfig.build.json +14 -0
  8. package/tsconfig.json +14 -4
  9. package/vite.config.mts +33 -0
  10. package/dist/cjs/__tests__/dynamicTemplate.test.js +0 -337
  11. package/dist/cjs/__tests__/dynamicTemplate.test.js.map +0 -1
  12. package/dist/cjs/__tests__/expression.test.js +0 -474
  13. package/dist/cjs/__tests__/expression.test.js.map +0 -1
  14. package/dist/cjs/__tests__/helper.test.js +0 -647
  15. package/dist/cjs/__tests__/helper.test.js.map +0 -1
  16. package/dist/cjs/__tests__/pluginRegistry.test.js +0 -83
  17. package/dist/cjs/__tests__/pluginRegistry.test.js.map +0 -1
  18. package/dist/cjs/src/constants.js +0 -27
  19. package/dist/cjs/src/constants.js.map +0 -1
  20. package/dist/cjs/src/dynamicTemplate.js +0 -228
  21. package/dist/cjs/src/dynamicTemplate.js.map +0 -1
  22. package/dist/cjs/src/expression.js +0 -463
  23. package/dist/cjs/src/expression.js.map +0 -1
  24. package/dist/cjs/src/helper.js +0 -277
  25. package/dist/cjs/src/helper.js.map +0 -1
  26. package/dist/cjs/src/index.js +0 -43
  27. package/dist/cjs/src/index.js.map +0 -1
  28. package/dist/cjs/src/pluginRegistry.js +0 -33
  29. package/dist/cjs/src/pluginRegistry.js.map +0 -1
  30. package/dist/cjs/src/schema.js +0 -190
  31. package/dist/cjs/src/schema.js.map +0 -1
  32. package/dist/cjs/src/types.js +0 -3
  33. package/dist/cjs/src/types.js.map +0 -1
  34. package/dist/cjs/src/version.js +0 -5
  35. package/dist/cjs/src/version.js.map +0 -1
  36. package/dist/esm/__tests__/dynamicTemplate.test.js +0 -302
  37. package/dist/esm/__tests__/dynamicTemplate.test.js.map +0 -1
  38. package/dist/esm/__tests__/expression.test.js +0 -472
  39. package/dist/esm/__tests__/expression.test.js.map +0 -1
  40. package/dist/esm/__tests__/helper.test.js +0 -612
  41. package/dist/esm/__tests__/helper.test.js.map +0 -1
  42. package/dist/esm/__tests__/pluginRegistry.test.js +0 -81
  43. package/dist/esm/__tests__/pluginRegistry.test.js.map +0 -1
  44. package/dist/esm/src/constants.js +0 -24
  45. package/dist/esm/src/constants.js.map +0 -1
  46. package/dist/esm/src/dynamicTemplate.js +0 -224
  47. package/dist/esm/src/dynamicTemplate.js.map +0 -1
  48. package/dist/esm/src/expression.js +0 -426
  49. package/dist/esm/src/expression.js.map +0 -1
  50. package/dist/esm/src/helper.js +0 -252
  51. package/dist/esm/src/helper.js.map +0 -1
  52. package/dist/esm/src/index.js +0 -8
  53. package/dist/esm/src/index.js.map +0 -1
  54. package/dist/esm/src/pluginRegistry.js +0 -29
  55. package/dist/esm/src/pluginRegistry.js.map +0 -1
  56. package/dist/esm/src/schema.js +0 -187
  57. package/dist/esm/src/schema.js.map +0 -1
  58. package/dist/esm/src/types.js +0 -2
  59. package/dist/esm/src/types.js.map +0 -1
  60. package/dist/esm/src/version.js +0 -2
  61. package/dist/esm/src/version.js.map +0 -1
  62. package/dist/node/__tests__/dynamicTemplate.test.js +0 -337
  63. package/dist/node/__tests__/dynamicTemplate.test.js.map +0 -1
  64. package/dist/node/__tests__/expression.test.js +0 -474
  65. package/dist/node/__tests__/expression.test.js.map +0 -1
  66. package/dist/node/__tests__/helper.test.js +0 -647
  67. package/dist/node/__tests__/helper.test.js.map +0 -1
  68. package/dist/node/__tests__/pluginRegistry.test.js +0 -83
  69. package/dist/node/__tests__/pluginRegistry.test.js.map +0 -1
  70. package/dist/node/src/constants.js +0 -27
  71. package/dist/node/src/constants.js.map +0 -1
  72. package/dist/node/src/dynamicTemplate.js +0 -228
  73. package/dist/node/src/dynamicTemplate.js.map +0 -1
  74. package/dist/node/src/expression.js +0 -463
  75. package/dist/node/src/expression.js.map +0 -1
  76. package/dist/node/src/helper.js +0 -277
  77. package/dist/node/src/helper.js.map +0 -1
  78. package/dist/node/src/index.js +0 -43
  79. package/dist/node/src/index.js.map +0 -1
  80. package/dist/node/src/pluginRegistry.js +0 -33
  81. package/dist/node/src/pluginRegistry.js.map +0 -1
  82. package/dist/node/src/schema.js +0 -190
  83. package/dist/node/src/schema.js.map +0 -1
  84. package/dist/node/src/types.js +0 -3
  85. package/dist/node/src/types.js.map +0 -1
  86. package/dist/node/src/version.js +0 -5
  87. package/dist/node/src/version.js.map +0 -1
  88. package/dist/types/__tests__/dynamicTemplate.test.d.ts +0 -1
  89. package/dist/types/__tests__/expression.test.d.ts +0 -1
  90. package/dist/types/__tests__/helper.test.d.ts +0 -1
  91. package/dist/types/__tests__/pluginRegistry.test.d.ts +0 -1
  92. package/dist/types/src/constants.d.ts +0 -20
  93. package/dist/types/src/dynamicTemplate.d.ts +0 -27
  94. package/dist/types/src/expression.d.ts +0 -6
  95. package/dist/types/src/helper.d.ts +0 -36
  96. package/dist/types/src/index.d.ts +0 -9
  97. package/dist/types/src/pluginRegistry.d.ts +0 -5
  98. package/dist/types/src/schema.d.ts +0 -820
  99. package/dist/types/src/types.d.ts +0 -181
  100. package/dist/types/src/version.d.ts +0 -1
  101. package/eslint.config.mjs +0 -22
  102. package/tsconfig.cjs.json +0 -10
  103. package/tsconfig.esm.json +0 -11
  104. package/tsconfig.node.json +0 -11
package/package.json CHANGED
@@ -1,51 +1,47 @@
1
1
  {
2
2
  "name": "@pdfme/common",
3
- "version": "5.5.10-dev.11",
4
- "sideEffects": false,
5
- "author": "hand-dot",
6
- "license": "MIT",
3
+ "version": "5.5.10-dev.127",
4
+ "description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
7
5
  "keywords": [
8
6
  "pdf",
9
- "pdf-generation",
10
7
  "pdf-designer",
8
+ "pdf-generation",
11
9
  "pdf-viewer",
12
- "typescript",
13
- "react"
10
+ "react",
11
+ "typescript"
14
12
  ],
15
- "description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
16
13
  "homepage": "https://pdfme.com",
14
+ "bugs": {
15
+ "url": "https://github.com/pdfme/pdfme/issues"
16
+ },
17
+ "license": "MIT",
18
+ "author": "hand-dot",
17
19
  "repository": {
18
20
  "type": "git",
19
21
  "url": "git@github.com:pdfme/pdfme.git"
20
22
  },
21
- "bugs": {
22
- "url": "https://github.com/pdfme/pdfme/issues"
23
- },
24
- "main": "dist/cjs/src/index.js",
25
- "module": "dist/esm/src/index.js",
26
- "types": "dist/types/src/index.d.ts",
23
+ "type": "module",
24
+ "sideEffects": false,
25
+ "main": "./dist/index.js",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
27
28
  "exports": {
28
29
  ".": {
29
- "import": {
30
- "node": "./dist/node/src/index.js",
31
- "default": "./dist/esm/src/index.js"
32
- },
33
- "require": "./dist/cjs/src/index.js",
34
- "types": "./dist/types/src/index.d.ts"
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js",
32
+ "default": "./dist/index.js"
35
33
  }
36
34
  },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
37
38
  "scripts": {
38
- "dev": "node set-version.js && tsc -p tsconfig.esm.json -w",
39
- "prebuild": "node set-version.js",
40
- "build": "run-p build:cjs build:esm build:node",
41
- "build:cjs": "tsc -p tsconfig.cjs.json",
42
- "build:esm": "tsc -p tsconfig.esm.json",
43
- "build:node": "tsc -p tsconfig.node.json",
39
+ "dev": "node set-version.js && vite build --watch",
40
+ "build": "node set-version.js && vite build && tsc -p tsconfig.build.json",
44
41
  "clean": "rimraf dist",
45
- "lint": "eslint --ext .ts src --config eslint.config.mjs",
46
- "test": "jest",
47
- "prune": "ts-prune src",
48
- "prettier": "prettier --write 'src/**/*.ts'"
42
+ "lint": "vp lint -c ../../.oxlintrc.json src",
43
+ "fmt": "vp fmt -c ../../.oxfmtrc.json src --write",
44
+ "test": "vitest run --config ../../vitest.config.ts"
49
45
  },
50
46
  "dependencies": {
51
47
  "@pdfme/pdf-lib": "*",
@@ -53,32 +49,11 @@
53
49
  "buffer": "^6.0.3",
54
50
  "zod": "^4.3.6"
55
51
  },
56
- "peerDependencies": {
57
- "antd": "^5.11.2",
58
- "form-render": "^2.2.20"
59
- },
60
- "jest": {
61
- "resolver": "ts-jest-resolver",
62
- "moduleFileExtensions": [
63
- "js",
64
- "ts"
65
- ],
66
- "transform": {
67
- "^.+\\.ts?$": [
68
- "ts-jest",
69
- {
70
- "tsconfig": "tsconfig.esm.json"
71
- }
72
- ]
73
- },
74
- "testMatch": [
75
- "**/*.test.ts"
76
- ]
77
- },
78
- "publishConfig": {
79
- "access": "public"
80
- },
81
52
  "devDependencies": {
82
53
  "@types/estree": "^1.0.6"
54
+ },
55
+ "peerDependencies": {
56
+ "antd": "^5.11.2 || ^6.0.0",
57
+ "form-render": "^2.2.20"
83
58
  }
84
59
  }
package/set-version.js CHANGED
@@ -1,6 +1,9 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { execSync } = require('child_process');
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
4
7
 
5
8
  const updateVersion = (version) => {
6
9
  const filePath = path.join(__dirname, 'src/version.ts');
@@ -23,7 +26,9 @@ const updateVersion = (version) => {
23
26
  };
24
27
 
25
28
  try {
26
- const gitTag = execSync('git describe --tags $(git rev-list --tags --max-count=1)', { encoding: 'utf8' }).trim();
29
+ const gitTag = execSync('git describe --tags $(git rev-list --tags --max-count=1)', {
30
+ encoding: 'utf8',
31
+ }).trim();
27
32
  updateVersion(gitTag);
28
33
  } catch (error) {
29
34
  console.error('Error replacing PDFME_VERSION:', error);
@@ -47,7 +47,9 @@ function normalizePageSchemas(
47
47
  const orderMap = new Map<string, number>();
48
48
 
49
49
  pageSchemas.forEach((schema, index) => {
50
- const localY = schema.position.y - paddingTop;
50
+ // Guard against negative Y position when schema.y < paddingTop
51
+ // Prevents "Cannot read properties of undefined (reading 'push')" error
52
+ const localY = Math.max(0, schema.position.y - paddingTop);
51
53
  items.push({
52
54
  schema: cloneDeep(schema),
53
55
  baseY: localY,
package/src/expression.ts CHANGED
@@ -45,9 +45,9 @@ const safeAssign = (
45
45
  if (target == null) {
46
46
  throw new TypeError('Cannot convert undefined or null to object');
47
47
  }
48
-
48
+
49
49
  const to = { ...target };
50
-
50
+
51
51
  for (const source of sources) {
52
52
  if (source != null) {
53
53
  for (const key in source) {
@@ -62,7 +62,7 @@ const safeAssign = (
62
62
  }
63
63
  }
64
64
  }
65
-
65
+
66
66
  return to;
67
67
  };
68
68
 
@@ -134,7 +134,11 @@ const validateAST = (node: AcornNode): void => {
134
134
  throw new Error('Access to prohibited property');
135
135
  }
136
136
  // Block prototype pollution methods
137
- if (['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__'].includes(propName)) {
137
+ if (
138
+ ['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__'].includes(
139
+ propName,
140
+ )
141
+ ) {
138
142
  throw new Error(`Access to prohibited method: ${propName}`);
139
143
  }
140
144
  const prohibitedMethods = ['toLocaleString', 'valueOf'];
@@ -283,7 +287,12 @@ const evaluateAST = (node: AcornNode, context: Record<string, unknown>): unknown
283
287
  throw new Error('Access to prohibited property');
284
288
  }
285
289
  // Block prototype pollution methods
286
- if (typeof prop === 'string' && ['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__'].includes(prop)) {
290
+ if (
291
+ typeof prop === 'string' &&
292
+ ['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__'].includes(
293
+ prop,
294
+ )
295
+ ) {
287
296
  throw new Error(`Access to prohibited method: ${prop}`);
288
297
  }
289
298
  return obj[prop];
package/src/helper.ts CHANGED
@@ -35,7 +35,10 @@ const uniq = <T>(array: Array<T>) => Array.from(new Set(array));
35
35
  export const getFallbackFontName = (font: Font) => {
36
36
  const initial = '';
37
37
  const fallbackFontName = Object.entries(font).reduce((acc, cur) => {
38
- const [fontName, fontValue] = cur as [string, { data: string | ArrayBuffer | Uint8Array; fallback?: boolean; subset?: boolean }];
38
+ const [fontName, fontValue] = cur as [
39
+ string,
40
+ { data: string | ArrayBuffer | Uint8Array; fallback?: boolean; subset?: boolean },
41
+ ];
39
42
 
40
43
  return !acc && fontValue.fallback ? fontName : acc;
41
44
  }, initial);
@@ -236,7 +239,10 @@ export const checkFont = (arg: { font: Font; template: Template }) => {
236
239
  template: { schemas },
237
240
  } = arg;
238
241
  const fontValues = Object.values(font);
239
- const fallbackFontNum = fontValues.reduce((acc, cur) => (cur.fallback ? acc + 1 : acc), 0 as number);
242
+ const fallbackFontNum = fontValues.reduce(
243
+ (acc, cur) => (cur.fallback ? acc + 1 : acc),
244
+ 0 as number,
245
+ );
240
246
  if (fallbackFontNum === 0) {
241
247
  throw Error(
242
248
  `[@pdfme/common] fallback flag is not found in font. true fallback flag must be only one.
@@ -270,7 +276,7 @@ export const checkPlugins = (arg: { plugins: Plugins; template: Template }) => {
270
276
  const allSchemaTypes = uniq(schemas.map((p) => p.map((v) => v.type)).flat());
271
277
 
272
278
  const pluginsSchemaTypes = Object.values(plugins).map((p) =>
273
- p ? (p.propPanel.defaultSchema as Schema).type : undefined,
279
+ p ? p.propPanel.defaultSchema.type : undefined,
274
280
  );
275
281
 
276
282
  if (allSchemaTypes.some((s) => !pluginsSchemaTypes.includes(s))) {
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import type { PDFPage, PDFDocument } from '@pdfme/pdf-lib';
3
- import type { ThemeConfig, GlobalToken } from 'antd';
3
+ import type { ThemeConfig } from 'antd';
4
4
  import type { WidgetProps as _PropPanelWidgetProps, Schema as _PropPanelSchema } from 'form-render';
5
5
  import {
6
6
  Lang,
@@ -34,6 +34,12 @@ export type ChangeSchemaItem = {
34
34
  };
35
35
  export type ChangeSchemas = (objs: ChangeSchemaItem[]) => void;
36
36
 
37
+ export type UITheme = {
38
+ colorPrimary: string;
39
+ colorPrimaryBg: string;
40
+ colorWhite: string;
41
+ };
42
+
37
43
  /**
38
44
  * Properties used for PDF rendering.
39
45
  * @template T Type of the extended Schema object.
@@ -72,7 +78,7 @@ export interface PDFRenderProps<T extends Schema> {
72
78
  * @property {(arg: { key: string; value: unknown } | { key: string; value: unknown }[]) => void} [onChange] - Used to change the value and schema properties. Only applicable when the mode is 'form' or 'designer'.
73
79
  * @property {HTMLDivElement} rootElement - The root HTMLDivElement for the UI.
74
80
  * @property {UIOptions} options - Options object passed from the Viewer, Form, or Designer.
75
- * @property {ThemeConfig} theme - An object that merges the 'theme' passed as an options with the default theme.
81
+ * @property {UITheme} theme - A merged token object used for UI rendering.
76
82
  * @property {(key: keyof Dict | string) => string} i18n - An object merged based on the options 'lang' and 'labels'.
77
83
  * @property {number} scale - The scale of the UI.
78
84
  * @property {Map<string | number, unknown>} _cache - Cache shared only during the execution of the render function (useful for caching images, etc. if needed).
@@ -88,7 +94,7 @@ export type UIRenderProps<T extends Schema> = {
88
94
  onChange?: (arg: { key: string; value: unknown } | { key: string; value: unknown }[]) => void;
89
95
  rootElement: HTMLDivElement;
90
96
  options: UIOptions;
91
- theme: GlobalToken;
97
+ theme: UITheme;
92
98
  i18n: (key: string) => string;
93
99
  scale: number;
94
100
  _cache: Map<string | number, unknown>;
@@ -104,7 +110,7 @@ export type UIRenderProps<T extends Schema> = {
104
110
  * @property {SchemaForUI[]} schemas - Array of schemas for UI rendering.
105
111
  * @property {Size} pageSize - The size of the page being edited.
106
112
  * @property {UIOptions} options - UI options for the property panel.
107
- * @property {GlobalToken} theme - The theme configuration used in the UI.
113
+ * @property {UITheme} theme - The theme token used in the UI.
108
114
  * @property {(key: keyof Dict | string) => string} i18n - Internationalization dictionary for UI labels and texts.
109
115
  */
110
116
  type PropPanelProps = {
@@ -114,7 +120,7 @@ type PropPanelProps = {
114
120
  changeSchemas: ChangeSchemas;
115
121
  schemas: SchemaForUI[];
116
122
  options: UIOptions;
117
- theme: GlobalToken;
123
+ theme: UITheme;
118
124
  i18n: (key: string) => string;
119
125
  };
120
126
 
@@ -147,16 +153,15 @@ export interface PropPanel<T extends Schema> {
147
153
  * @property {string} [icon] Icon SVG for the plugin.
148
154
  * @property {boolean} [uninterruptedEditMode] When editing in the UI, should the field avoid re-rendering while in edit mode?
149
155
  */
150
- export type Plugin<T = Schema> = {
151
- pdf: (arg: PDFRenderProps<T & Schema>) => Promise<void> | void;
152
- ui: (arg: UIRenderProps<T & Schema>) => Promise<void> | void;
156
+ export interface Plugin<T extends Schema = Schema> {
157
+ pdf(arg: PDFRenderProps<T & Schema>): Promise<void> | void;
158
+ ui(arg: UIRenderProps<T & Schema>): Promise<void> | void;
153
159
  propPanel: PropPanel<T & Schema>;
154
160
  icon?: string;
155
161
  uninterruptedEditMode?: boolean;
156
- };
162
+ }
157
163
 
158
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
- export type Plugins = { [key: string]: Plugin<any> };
164
+ export type Plugins = { [key: string]: Plugin };
160
165
 
161
166
  export interface PluginRegistry {
162
167
  plugins: { [key: string]: Plugin };
@@ -189,10 +194,10 @@ export type CustomPdf = z.infer<typeof CustomPdf>;
189
194
  export type Template = z.infer<typeof Template>;
190
195
  export type CommonOptions = z.infer<typeof CommonOptions>;
191
196
  export type GeneratorOptions = z.infer<typeof GeneratorOptions>;
192
- export type GenerateProps = z.infer<typeof GenerateProps> & { plugins?: Plugins };
197
+ export type GenerateProps = Omit<z.infer<typeof GenerateProps>, 'plugins'> & { plugins?: Plugins };
193
198
  export type UIOptions = z.infer<typeof UIOptions> & { theme?: ThemeConfig };
194
- export type UIProps = z.infer<typeof UIProps> & { plugins?: Plugins };
195
- export type PreviewProps = z.infer<typeof PreviewProps> & { plugins?: Plugins };
196
- export type DesignerProps = z.infer<typeof DesignerProps> & { plugins?: Plugins };
199
+ export type UIProps = Omit<z.infer<typeof UIProps>, 'plugins'> & { plugins?: Plugins };
200
+ export type PreviewProps = Omit<z.infer<typeof PreviewProps>, 'plugins'> & { plugins?: Plugins };
201
+ export type DesignerProps = Omit<z.infer<typeof DesignerProps>, 'plugins'> & { plugins?: Plugins };
197
202
  export type SchemaPageArray = z.infer<typeof SchemaPageArray>;
198
203
  export type LegacySchemaPageArray = z.infer<typeof LegacySchemaPageArray>;
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../../tsconfig.build.base.json",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationDir": "./dist",
6
+ "emitDeclarationOnly": true,
7
+ "module": "ESNext",
8
+ "moduleResolution": "bundler",
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "skipLibCheck": true
12
+ },
13
+ "include": ["src/**/*.ts"]
14
+ }
package/tsconfig.json CHANGED
@@ -1,6 +1,16 @@
1
1
  {
2
- "extends": "./tsconfig.esm",
2
+ "extends": "../../tsconfig.base.json",
3
3
  "compilerOptions": {
4
- "outDir": "./dist",
5
- }
6
- }
4
+ "composite": true,
5
+ "declaration": true,
6
+ "declarationDir": "./dist/typecheck",
7
+ "emitDeclarationOnly": true,
8
+ "module": "ESNext",
9
+ "moduleResolution": "bundler",
10
+ "outDir": "./dist/typecheck",
11
+ "tsBuildInfoFile": "./dist/typecheck/tsconfig.tsbuildinfo",
12
+ "skipLibCheck": true
13
+ },
14
+ "include": ["src/**/*.ts"],
15
+ "references": [{ "path": "../pdf-lib" }]
16
+ }
@@ -0,0 +1,33 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { builtinModules } from 'node:module';
3
+ import { dirname, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { defineConfig } from 'vite';
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const packageJson = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf8')) as {
9
+ dependencies?: Record<string, string>;
10
+ peerDependencies?: Record<string, string>;
11
+ };
12
+
13
+ const external = [
14
+ ...builtinModules,
15
+ ...builtinModules.map((moduleName) => `node:${moduleName}`),
16
+ ...Object.keys(packageJson.dependencies ?? {}),
17
+ ...Object.keys(packageJson.peerDependencies ?? {}),
18
+ ];
19
+
20
+ export default defineConfig({
21
+ build: {
22
+ lib: {
23
+ entry: resolve(__dirname, 'src/index.ts'),
24
+ fileName: 'index',
25
+ formats: ['es'],
26
+ },
27
+ minify: false,
28
+ outDir: 'dist',
29
+ rollupOptions: { external },
30
+ sourcemap: true,
31
+ target: 'es2020',
32
+ },
33
+ });