pkgbld 1.19.0 → 1.20.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/dist/index.js CHANGED
@@ -30,7 +30,19 @@ async function createSubpackages(inputs, config) {
30
30
  }
31
31
  }
32
32
 
33
- const defaults = {
33
+ function CommaSeparatedString(value) {
34
+ return value.split(',').map((arg) => arg.trim());
35
+ }
36
+ function CommaSeparatedStringOrBoolean(value) {
37
+ if (typeof value === 'boolean') {
38
+ return value;
39
+ }
40
+ if (Array.isArray(value) && value.length === 0) {
41
+ return true;
42
+ }
43
+ return CommaSeparatedString(value);
44
+ }
45
+ const cliFlagsDefaults = {
34
46
  formats: ['es', 'cjs'],
35
47
  umdInputs: [],
36
48
  compressFormats: ['umd'],
@@ -46,98 +58,91 @@ const defaults = {
46
58
  esPattern: '[name].mjs',
47
59
  umdPattern: '[name].umd.js'
48
60
  };
49
- function CommaSeparatedString(value) {
50
- return value.split(',').map((arg) => arg.trim());
51
- }
52
- function CommaSeparatedStringOrBoolean(value) {
53
- if (typeof value === 'boolean') {
54
- return value;
55
- }
56
- if (Array.isArray(value) && value.length === 0) {
57
- return true;
61
+ const cliFlags = {
62
+ umd: {
63
+ type: CommaSeparatedString,
64
+ description: 'Package subpath exports in UMD format',
65
+ default: cliFlagsDefaults.umdInputs
66
+ },
67
+ compress: {
68
+ type: CommaSeparatedString,
69
+ description: 'Compress formats using terser',
70
+ default: cliFlagsDefaults.compressFormats
71
+ },
72
+ sourcemaps: {
73
+ type: CommaSeparatedString,
74
+ description: 'Emit sourcemaps for the specified formats',
75
+ default: cliFlagsDefaults.sourcemapFormats
76
+ },
77
+ formats: {
78
+ type: CommaSeparatedString,
79
+ description: 'Formats to emit',
80
+ default: cliFlagsDefaults.formats
81
+ },
82
+ preprocess: {
83
+ type: CommaSeparatedString,
84
+ description: 'Preprocess entry points / subpath exports',
85
+ default: cliFlagsDefaults.preprocess
86
+ },
87
+ dir: {
88
+ type: String,
89
+ description: 'Output directory',
90
+ default: cliFlagsDefaults.dir
91
+ },
92
+ sourceDir: {
93
+ type: String,
94
+ description: 'Source directory',
95
+ default: cliFlagsDefaults.sourceDir
96
+ },
97
+ bin: {
98
+ type: CommaSeparatedString,
99
+ description: 'Executable files'
100
+ },
101
+ includeExternals: {
102
+ type: CommaSeparatedStringOrBoolean,
103
+ description: 'Include all/specified externals into result bundle(s)',
104
+ default: cliFlagsDefaults.includeExternals
105
+ },
106
+ eject: {
107
+ type: Boolean,
108
+ description: 'Eject config',
109
+ default: cliFlagsDefaults.eject
110
+ },
111
+ noTsConfig: {
112
+ type: Boolean,
113
+ description: 'Do not create / update tsconfig.json',
114
+ default: cliFlagsDefaults.noTsConfig
115
+ },
116
+ noUpdatePackageJson: {
117
+ type: Boolean,
118
+ description: 'Do not create / update package.json',
119
+ default: cliFlagsDefaults.noUpdatePackageJson
120
+ },
121
+ commonjsPattern: {
122
+ type: String,
123
+ description: 'CommonJS output file name pattern',
124
+ default: cliFlagsDefaults.commonjsPattern
125
+ },
126
+ esmPattern: {
127
+ type: String,
128
+ description: 'ES output file name pattern',
129
+ default: cliFlagsDefaults.esPattern
130
+ },
131
+ umdPattern: {
132
+ type: String,
133
+ description: 'UMD output file name pattern',
134
+ default: cliFlagsDefaults.umdPattern
58
135
  }
59
- return CommaSeparatedString(value);
136
+ };
137
+ function toFormattedJson(json) {
138
+ return JSON.stringify(json, null, 2) + '\n';
60
139
  }
140
+
61
141
  function getCliOptions(plugins, pkg) {
62
142
  const cliOptions = cleye.cli({
63
143
  name: 'pkgbld',
64
144
  version: pkg.version ?? '<unknown>',
65
- flags: {
66
- umd: {
67
- type: CommaSeparatedString,
68
- description: 'Package subpath exports in UMD format',
69
- default: defaults.umdInputs
70
- },
71
- compress: {
72
- type: CommaSeparatedString,
73
- description: 'Compress formats using terser',
74
- default: defaults.compressFormats
75
- },
76
- sourcemaps: {
77
- type: CommaSeparatedString,
78
- description: 'Emit sourcemaps for the specified formats',
79
- default: defaults.sourcemapFormats
80
- },
81
- formats: {
82
- type: CommaSeparatedString,
83
- description: 'Formats to emit',
84
- default: defaults.formats
85
- },
86
- preprocess: {
87
- type: CommaSeparatedString,
88
- description: 'Preprocess entry points / subpath exports',
89
- default: defaults.preprocess
90
- },
91
- dir: {
92
- type: String,
93
- description: 'Output directory',
94
- default: defaults.dir
95
- },
96
- sourceDir: {
97
- type: String,
98
- description: 'Source directory',
99
- default: defaults.sourceDir
100
- },
101
- bin: {
102
- type: CommaSeparatedString,
103
- description: 'Executable files'
104
- },
105
- includeExternals: {
106
- type: CommaSeparatedStringOrBoolean,
107
- description: 'Include all/specified externals into result bundle(s)',
108
- default: defaults.includeExternals
109
- },
110
- eject: {
111
- type: Boolean,
112
- description: 'Eject config',
113
- default: defaults.eject
114
- },
115
- noTsConfig: {
116
- type: Boolean,
117
- description: 'Do not create / update tsconfig.json',
118
- default: defaults.noTsConfig
119
- },
120
- noUpdatePackageJson: {
121
- type: Boolean,
122
- description: 'Do not create / update package.json',
123
- default: defaults.noUpdatePackageJson
124
- },
125
- commonjsPattern: {
126
- type: String,
127
- description: 'CommonJS output file name pattern',
128
- default: defaults.commonjsPattern
129
- },
130
- esmPattern: {
131
- type: String,
132
- description: 'ES output file name pattern',
133
- default: defaults.esPattern
134
- },
135
- umdPattern: {
136
- type: String,
137
- description: 'UMD output file name pattern',
138
- default: defaults.umdPattern
139
- }
140
- }
145
+ flags: cliFlags
141
146
  });
142
147
  const flags = cliOptions.flags;
143
148
  const options = {
@@ -145,7 +150,7 @@ function getCliOptions(plugins, pkg) {
145
150
  compressFormats: flags.compress,
146
151
  sourcemapFormats: flags.sourcemaps,
147
152
  formats: flags.formats,
148
- formatsOverridden: flags.formats !== defaults.formats,
153
+ formatsOverridden: flags.formats !== cliFlagsDefaults.formats,
149
154
  preprocess: flags.preprocess,
150
155
  dir: flags.dir,
151
156
  sourceDir: flags.sourceDir,
@@ -224,7 +229,7 @@ function includeExternals(importer, external, id, config) {
224
229
  if (!external)
225
230
  return false;
226
231
  if (path.isAbsolute(id)) {
227
- id = './' + path.relative(process.cwd(), id);
232
+ id = path.relative(path.join(process.cwd(), '..'), id);
228
233
  }
229
234
  const internals = config.includeExternals;
230
235
  if (internals.includes(id) || internals.some(internal => id.startsWith(internal))) {
@@ -669,10 +674,10 @@ function patternToName(pattern, input) {
669
674
  }
670
675
 
671
676
  async function writeJson(path, json) {
672
- await fs.writeFile(path, JSON.stringify(json, null, 2) + '\n');
677
+ await fs.writeFile(path, toFormattedJson(json));
673
678
  }
674
679
 
675
- var version = "1.19.0";
680
+ var version = "1.20.0";
676
681
  var name = "pkgbld";
677
682
  var license = "MIT";
678
683
  var author = "Konstantin Shutkin";
@@ -708,7 +713,7 @@ var dependencies = {
708
713
  "@niceties/draftlog-appender": "^1.3.0",
709
714
  lodash: "^4.17.21",
710
715
  rollup: "^3.20.2",
711
- "rollup-plugin-typescript2": "^0.35.0",
716
+ "rollup-plugin-typescript2": "^0.36.0",
712
717
  "rollup-plugin-preprocess": "^0.0.4",
713
718
  "@rollup/plugin-commonjs": "^25.0.0",
714
719
  "@rollup/plugin-terser": "^0.4.0",
@@ -726,7 +731,8 @@ var dependencies = {
726
731
  };
727
732
  var devDependencies = {
728
733
  "@types/lodash": "^4.14.192",
729
- "@total-typescript/ts-reset": "^0.5.1"
734
+ "@total-typescript/ts-reset": "^0.5.1",
735
+ options: "workspace:*"
730
736
  };
731
737
  var peerDependencies = {
732
738
  typescript: "^5.2.2"
@@ -21,7 +21,7 @@ export declare function getRollupConfigs([provider, plugins]: [Provider, PkgbldR
21
21
  externalLiveBindings?: boolean | undefined;
22
22
  file?: string | undefined;
23
23
  footer?: string | import("rollup").AddonFunction | undefined;
24
- format: "umd" | "es" | "cjs" | "amd" | "iife" | "system" | "commonjs" | "esm" | "module" | "systemjs";
24
+ format: "umd" | "amd" | "cjs" | "es" | "iife" | "system" | "commonjs" | "esm" | "module" | "systemjs";
25
25
  freeze?: boolean | undefined;
26
26
  generatedCode?: import("rollup").GeneratedCodePreset | import("rollup").GeneratedCodeOptions | undefined;
27
27
  globals?: import("rollup").GlobalsOption | undefined;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.0",
2
+ "version": "1.20.0",
3
3
  "name": "pkgbld",
4
4
  "license": "MIT",
5
5
  "author": "Konstantin Shutkin",
@@ -31,7 +31,7 @@
31
31
  "@niceties/draftlog-appender": "^1.3.0",
32
32
  "lodash": "^4.17.21",
33
33
  "rollup": "^3.20.2",
34
- "rollup-plugin-typescript2": "^0.35.0",
34
+ "rollup-plugin-typescript2": "^0.36.0",
35
35
  "rollup-plugin-preprocess": "^0.0.4",
36
36
  "@rollup/plugin-commonjs": "^25.0.0",
37
37
  "@rollup/plugin-terser": "^0.4.0",
@@ -49,7 +49,8 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/lodash": "^4.14.192",
52
- "@total-typescript/ts-reset": "^0.5.1"
52
+ "@total-typescript/ts-reset": "^0.5.1",
53
+ "options": "0.0.0"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "typescript": "^5.2.2"