pkgbld 1.35.0 → 1.36.0

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pkgbld
2
2
 
3
- *Build your libraries with ease*
3
+ _Build your libraries with ease_
4
4
 
5
5
  Rollup-based build tool for building libraries based on package.json config and simple CLI options.
6
6
 
@@ -15,6 +15,7 @@ It is created to easily build libraries that contain multiple subpath exports (e
15
15
  ## Installation
16
16
 
17
17
  Using npm:
18
+
18
19
  ```
19
20
  npm install --save-dev pkgbld
20
21
  ```
@@ -210,7 +211,7 @@ Right now it only affects how `prune` command removes entries in the `scripts` f
210
211
 
211
212
  For `library` profile it retains: 'preinstall', 'install', 'postinstall', 'prepublish', 'preprepare', 'prepare', 'postprepare'.
212
213
 
213
- For `app` profile it retains in addition: 'prestart', 'start', 'poststart', 'prerestart', 'restart', 'postrestart', 'prestop', 'stop', 'poststop', 'pretest', 'test', 'posttest'.
214
+ For `app` profile it retains in addition: 'prestart', 'start', 'poststart', 'prerestart', 'restart', 'postrestart', 'prestop', 'stop', 'poststop', 'pretest', 'test', 'posttest'.
214
215
 
215
216
  ### flatten
216
217
 
@@ -242,6 +243,18 @@ Optimizes files by removing all files that are not required for pack at the give
242
243
 
243
244
  You might want to disable this option in some edge cases.
244
245
 
246
+ ### no-subpackages
247
+
248
+ ```
249
+ pkgbld --no-subpackages
250
+ ```
251
+
252
+ Do not create subpackage directories with package.json files for non-index entry points.
253
+
254
+ By default, pkgbld creates a directory for each non-index entry point (e.g., `second/package.json` for a `./second` export) to enable simpler imports. Use this flag to disable this behavior.
255
+
256
+ Note: The `pkgbld-plugin-dts-buddy` plugin automatically sets this flag when loaded, as it provides alternative type resolution through the dts-buddy bundling approach.
257
+
245
258
  ### removeLegalComments
246
259
 
247
260
  ```
@@ -258,12 +271,26 @@ Plugins suppose to implement one or more of the following interface methods on a
258
271
 
259
272
  ```typescript
260
273
  interface PkgbldPlugin {
261
- options(parsedArgs: {[key: string]: string | number}, options: ReturnType<typeof getCliOptions>): void;
262
- processPackageJson(packageJson: PackageJson, inputs: string[], logger: Logger): void;
263
- processTsConfig(config: Json): void;
264
- providePlugins(provider: Provider, config: Record<string, string | string[] | boolean>, inputs: string[]): Promise<void>;
265
- getExtraOutputSettings(format: InternalModuleFormat, inputs: string[]): Partial<OutputOptions>;
266
- buildEnd(): Promise<void>;
274
+ options(
275
+ parsedArgs: { [key: string]: string | number },
276
+ options: ReturnType<typeof getCliOptions>
277
+ ): void;
278
+ processPackageJson(
279
+ packageJson: PackageJson,
280
+ inputs: string[],
281
+ logger: Logger
282
+ ): void;
283
+ processTsConfig(config: Json): void;
284
+ providePlugins(
285
+ provider: Provider,
286
+ config: Record<string, string | string[] | boolean>,
287
+ inputs: string[]
288
+ ): Promise<void>;
289
+ getExtraOutputSettings(
290
+ format: InternalModuleFormat,
291
+ inputs: string[]
292
+ ): Partial<OutputOptions>;
293
+ buildEnd(): Promise<void>;
267
294
  }
268
295
  ```
269
296
 
package/dist/index.d.ts CHANGED
@@ -27,6 +27,7 @@ declare function getCliOptions(plugins: Partial<PkgbldPlugin>[], pkg: PackageJso
27
27
  noClean: boolean;
28
28
  noBundle: boolean;
29
29
  removeLegalComments: boolean;
30
+ noSubpackages: boolean;
30
31
  } | {
31
32
  readonly kind: "prune";
32
33
  readonly profile: string;
package/dist/index.mjs CHANGED
@@ -55,114 +55,120 @@ const cliFlagsDefaults = {
55
55
  commonjsPattern: '[name].cjs',
56
56
  esmPattern: '[name].mjs',
57
57
  umdPattern: '[name].umd.js',
58
- formatPackageJson: false
58
+ formatPackageJson: false,
59
+ noSubpackages: false,
59
60
  };
60
61
  const cliFlags = {
61
62
  umd: {
62
63
  type: CommaSeparatedString,
63
64
  description: 'Package subpath exports in UMD format',
64
- default: cliFlagsDefaults.umd
65
+ default: cliFlagsDefaults.umd,
65
66
  },
66
67
  compress: {
67
68
  type: CommaSeparatedString,
68
69
  description: 'Compress formats using terser',
69
- default: cliFlagsDefaults.compress
70
+ default: cliFlagsDefaults.compress,
70
71
  },
71
72
  sourcemaps: {
72
73
  type: CommaSeparatedString,
73
74
  description: 'Emit sourcemaps for the specified formats',
74
- default: cliFlagsDefaults.sourcemaps
75
+ default: cliFlagsDefaults.sourcemaps,
75
76
  },
76
77
  formats: {
77
78
  type: CommaSeparatedString,
78
79
  description: 'Formats to emit',
79
- default: cliFlagsDefaults.formats
80
+ default: cliFlagsDefaults.formats,
80
81
  },
81
82
  preprocess: {
82
83
  type: CommaSeparatedString,
83
84
  description: 'Preprocess entry points / subpath exports',
84
- default: cliFlagsDefaults.preprocess
85
+ default: cliFlagsDefaults.preprocess,
85
86
  },
86
87
  dest: {
87
88
  type: String,
88
89
  description: 'Output directory',
89
- default: cliFlagsDefaults.dest
90
+ default: cliFlagsDefaults.dest,
90
91
  },
91
92
  src: {
92
93
  type: String,
93
94
  description: 'Source directory',
94
- default: cliFlagsDefaults.src
95
+ default: cliFlagsDefaults.src,
95
96
  },
96
97
  bin: {
97
98
  type: CommaSeparatedString,
98
99
  description: 'Executable files',
99
- default: cliFlagsDefaults.bin
100
+ default: cliFlagsDefaults.bin,
100
101
  },
101
102
  includeExternals: {
102
103
  type: CommaSeparatedStringOrBoolean,
103
- description: 'Include all/specified externals into result bundle(s)',
104
- default: cliFlagsDefaults.includeExternals
104
+ description: 'Include all/specified externals into the result bundle(s)',
105
+ default: cliFlagsDefaults.includeExternals,
105
106
  },
106
107
  eject: {
107
108
  type: Boolean,
108
109
  description: 'Eject config',
109
- default: cliFlagsDefaults.eject
110
+ default: cliFlagsDefaults.eject,
110
111
  },
111
112
  noTsConfig: {
112
113
  type: Boolean,
113
114
  description: 'Do not create / update tsconfig.json',
114
- default: cliFlagsDefaults.noTsConfig
115
+ default: cliFlagsDefaults.noTsConfig,
115
116
  },
116
117
  noUpdatePackageJson: {
117
118
  type: Boolean,
118
119
  description: 'Do not create / update package.json',
119
- default: cliFlagsDefaults.noUpdatePackageJson
120
+ default: cliFlagsDefaults.noUpdatePackageJson,
120
121
  },
121
122
  commonjsPattern: {
122
123
  type: String,
123
124
  description: 'CommonJS output file name pattern',
124
- default: cliFlagsDefaults.commonjsPattern
125
+ default: cliFlagsDefaults.commonjsPattern,
125
126
  },
126
127
  esmPattern: {
127
128
  type: String,
128
129
  description: 'ES output file name pattern',
129
- default: cliFlagsDefaults.esmPattern
130
+ default: cliFlagsDefaults.esmPattern,
130
131
  },
131
132
  umdPattern: {
132
133
  type: String,
133
134
  description: 'UMD output file name pattern',
134
- default: cliFlagsDefaults.umdPattern
135
+ default: cliFlagsDefaults.umdPattern,
135
136
  },
136
137
  formatPackageJson: {
137
138
  type: Boolean,
138
139
  description: 'Format package.json',
139
- default: cliFlagsDefaults.formatPackageJson
140
+ default: cliFlagsDefaults.formatPackageJson,
140
141
  },
141
142
  noPack: {
142
143
  type: Boolean,
143
144
  description: 'Do not pack',
144
- default: false
145
+ default: false,
145
146
  },
146
147
  noExports: {
147
148
  type: Boolean,
148
- description: 'Do not add exports field in package.json',
149
- default: false
149
+ description: 'Do not add exports field to package.json',
150
+ default: false,
150
151
  },
151
152
  noClean: {
152
153
  type: Boolean,
153
- description: 'Do not clean output directory',
154
- default: false
154
+ description: 'Do not clean the output directory',
155
+ default: false,
155
156
  },
156
157
  noBundle: {
157
158
  type: Boolean,
158
159
  description: 'Do not bundle',
159
- default: false
160
+ default: false,
160
161
  },
161
162
  removeLegalComments: {
162
163
  type: Boolean,
163
164
  description: 'Remove legal comments',
164
- default: false
165
- }
165
+ default: false,
166
+ },
167
+ noSubpackages: {
168
+ type: Boolean,
169
+ description: 'Do not create subpackage directories with package.json files',
170
+ default: cliFlagsDefaults.noSubpackages,
171
+ },
166
172
  };
167
173
  const packageJsonFieldsOrder = new Set([
168
174
  'private',
@@ -210,7 +216,7 @@ const packageJsonFieldsOrder = new Set([
210
216
  'optionalDependencies',
211
217
  'overrides',
212
218
  'publishConfig',
213
- 'workspaces'
219
+ 'workspaces',
214
220
  ]);
215
221
  function processPackageJson(pkg, needTreatment, treatKey) {
216
222
  const newPkg = {};
@@ -306,7 +312,8 @@ function getCliOptions(plugins, pkg) {
306
312
  noExports: flags.noExports,
307
313
  noClean: flags.noClean,
308
314
  noBundle: flags.noBundle,
309
- removeLegalComments: flags.removeLegalComments
315
+ removeLegalComments: flags.removeLegalComments,
316
+ noSubpackages: flags.noSubpackages
310
317
  };
311
318
  for (const plugin of plugins) {
312
319
  plugin.options?.(flags, options);
@@ -913,7 +920,7 @@ async function processPackage(pkg, config, plugins, tsConfig) {
913
920
  pkg.exports[id][cjsFieldName] = `./${config.dir}/${patternToName(config.commonjsPattern, basename)}`;
914
921
  }
915
922
  pkg.exports[id] = orderFields(exportsFields, pkg.exports[id]);
916
- if (basename !== indexId) {
923
+ if (basename !== indexId && !config.noSubpackages) {
917
924
  if (!pkg.files.includes(basename)) {
918
925
  pkg.files.push(basename);
919
926
  }
@@ -1588,7 +1595,9 @@ async function execute() {
1588
1595
  if (!options.noUpdatePackageJson) {
1589
1596
  await writeJson(pkgPath, pkg);
1590
1597
  }
1591
- await createSubpackages(inputs, options);
1598
+ if (!options.noSubpackages) {
1599
+ await createSubpackages(inputs, options);
1600
+ }
1592
1601
  await Promise.all(plugins
1593
1602
  .filter(plugin => plugin.buildEnd)
1594
1603
  .map(plugin => plugin.buildEnd()));
@@ -1614,3 +1623,4 @@ function preimport() {
1614
1623
  ['@rollup-extras/plugin-externals', import('@rollup-extras/plugin-externals')]
1615
1624
  ]) : new Map);
1616
1625
  }
1626
+ process.on('exit', () => { });
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.35.0",
2
+ "version": "1.36.0",
3
3
  "name": "pkgbld",
4
4
  "license": "MIT",
5
5
  "author": "Konstantin Shutkin",