pkgbld 1.21.1 → 1.22.1

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 (3) hide show
  1. package/README.md +5 -5
  2. package/dist/index.js +39 -32
  3. package/package.json +14 -14
package/README.md CHANGED
@@ -60,7 +60,7 @@ If `package.json` defines the `umd` field option will default to `index``.
60
60
  pkgbld --compress=es,umd
61
61
  ```
62
62
 
63
- Where `es,umd` should be replaced by formats that should be compressed using terser.
63
+ Where `es,umd` should be replaced by formats that should be compressed using terser. Default `umd`.
64
64
 
65
65
  ### sourcemaps
66
66
 
@@ -88,18 +88,18 @@ pkgbld --preprocess=index
88
88
 
89
89
  Defines what entry points/files should be preprocessed using `rollup-plugin-preprocess`. The entry point will be defined as variable es (for esm target), cjs (for commonjs) and umd (for umd) depending on the target type. Please request more variables / more granular logic if you want more.
90
90
 
91
- ### dir
91
+ ### dest
92
92
 
93
93
  ```
94
- pkgbld --dir=dist
94
+ pkgbld --dest=dist
95
95
  ```
96
96
 
97
97
  Directory to put output files.
98
98
 
99
- ### sourcedir
99
+ ### src
100
100
 
101
101
  ```
102
- pkgbld --sourcedir=src
102
+ pkgbld --src=src
103
103
  ```
104
104
 
105
105
  Directory to search for input files.
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ function CommaSeparatedStringOrBoolean(value) {
37
37
  if (typeof value === 'boolean') {
38
38
  return value;
39
39
  }
40
+ // TODO check how we get array here
40
41
  if (Array.isArray(value) && value.length === 0) {
41
42
  return true;
42
43
  }
@@ -44,18 +45,19 @@ function CommaSeparatedStringOrBoolean(value) {
44
45
  }
45
46
  const cliFlagsDefaults = {
46
47
  formats: ['es', 'cjs'],
47
- umdInputs: [],
48
- compressFormats: ['umd'],
49
- sourcemapFormats: ['umd'],
48
+ umd: [],
49
+ compress: ['umd'],
50
+ sourcemaps: ['umd'],
50
51
  preprocess: [],
51
- dir: 'dist',
52
- sourceDir: 'src',
52
+ dest: 'dist',
53
+ src: 'src',
54
+ bin: undefined,
53
55
  includeExternals: false,
54
56
  eject: false,
55
57
  noTsConfig: false,
56
58
  noUpdatePackageJson: false,
57
59
  commonjsPattern: '[name].cjs',
58
- esPattern: '[name].mjs',
60
+ esmPattern: '[name].mjs',
59
61
  umdPattern: '[name].umd.js',
60
62
  formatPackageJson: false
61
63
  };
@@ -63,17 +65,17 @@ const cliFlags = {
63
65
  umd: {
64
66
  type: CommaSeparatedString,
65
67
  description: 'Package subpath exports in UMD format',
66
- default: cliFlagsDefaults.umdInputs
68
+ default: cliFlagsDefaults.umd
67
69
  },
68
70
  compress: {
69
71
  type: CommaSeparatedString,
70
72
  description: 'Compress formats using terser',
71
- default: cliFlagsDefaults.compressFormats
73
+ default: cliFlagsDefaults.compress
72
74
  },
73
75
  sourcemaps: {
74
76
  type: CommaSeparatedString,
75
77
  description: 'Emit sourcemaps for the specified formats',
76
- default: cliFlagsDefaults.sourcemapFormats
78
+ default: cliFlagsDefaults.sourcemaps
77
79
  },
78
80
  formats: {
79
81
  type: CommaSeparatedString,
@@ -85,19 +87,20 @@ const cliFlags = {
85
87
  description: 'Preprocess entry points / subpath exports',
86
88
  default: cliFlagsDefaults.preprocess
87
89
  },
88
- dir: {
90
+ dest: {
89
91
  type: String,
90
92
  description: 'Output directory',
91
- default: cliFlagsDefaults.dir
93
+ default: cliFlagsDefaults.dest
92
94
  },
93
- sourceDir: {
95
+ src: {
94
96
  type: String,
95
97
  description: 'Source directory',
96
- default: cliFlagsDefaults.sourceDir
98
+ default: cliFlagsDefaults.src
97
99
  },
98
100
  bin: {
99
101
  type: CommaSeparatedString,
100
- description: 'Executable files'
102
+ description: 'Executable files',
103
+ default: cliFlagsDefaults.bin
101
104
  },
102
105
  includeExternals: {
103
106
  type: CommaSeparatedStringOrBoolean,
@@ -127,7 +130,7 @@ const cliFlags = {
127
130
  esmPattern: {
128
131
  type: String,
129
132
  description: 'ES output file name pattern',
130
- default: cliFlagsDefaults.esPattern
133
+ default: cliFlagsDefaults.esmPattern
131
134
  },
132
135
  umdPattern: {
133
136
  type: String,
@@ -145,6 +148,7 @@ const packageJsonFieldsOrder = new Set([
145
148
  'type',
146
149
  'version',
147
150
  'name',
151
+ 'scope',
148
152
  'description',
149
153
  'license',
150
154
  'author',
@@ -217,8 +221,8 @@ function getCliOptions(plugins, pkg) {
217
221
  formats: flags.formats,
218
222
  formatsOverridden: flags.formats !== cliFlagsDefaults.formats,
219
223
  preprocess: flags.preprocess,
220
- dir: flags.dir,
221
- sourceDir: flags.sourceDir,
224
+ dir: flags.dest,
225
+ sourceDir: flags.src,
222
226
  bin: flags.bin,
223
227
  includeExternals: flags.includeExternals,
224
228
  eject: flags.eject,
@@ -266,7 +270,7 @@ async function externals (provider, config, inputs) {
266
270
  const allowGenericUmd = config.umdInputs.length === 1 && inputs.length === 1;
267
271
  if (config.formats.length > 0) {
268
272
  const format = (allowGenericUmd ? undefined : config.formats.filter(format => format !== 'umd'));
269
- provider.provide(() => pluginExternals({
273
+ provider.provide(() => pluginExternals(config.includeExternals === false ? {} : {
270
274
  external: (id, external, importer) => includeExternals(importer, external, id, config)
271
275
  }), 2000 /* Priority.externals */, { format });
272
276
  // for eject config
@@ -746,7 +750,7 @@ async function writeJson(path, json) {
746
750
  await fs.writeFile(path, toFormattedJson(json));
747
751
  }
748
752
 
749
- var version = "1.21.1";
753
+ var version = "1.22.1";
750
754
  var name = "pkgbld";
751
755
  var license = "MIT";
752
756
  var author = "Konstantin Shutkin";
@@ -778,28 +782,28 @@ var scripts = {
778
782
  lint: "eslint ./src"
779
783
  };
780
784
  var dependencies = {
781
- "@niceties/logger": "^1.1.10",
782
- "@niceties/draftlog-appender": "^1.3.0",
785
+ "@niceties/logger": "^1.1.12",
786
+ "@niceties/draftlog-appender": "^1.3.2",
783
787
  lodash: "^4.17.21",
784
788
  rollup: "^4.0.0",
785
789
  "rollup-plugin-typescript2": "^0.36.0",
786
790
  "rollup-plugin-preprocess": "^0.0.4",
787
- "@rollup/plugin-commonjs": "^25.0.0",
788
- "@rollup/plugin-terser": "^0.4.0",
789
- "@rollup/plugin-json": "^6.0.0",
790
- "@rollup/plugin-node-resolve": "^15.0.1",
791
- "@rollup-extras/plugin-clean": "^1.3.4",
792
- "@rollup-extras/plugin-binify": "^1.1.5",
793
- "@rollup-extras/plugin-externals": "^1.1.8",
794
- "@slimlib/refine-partition": "^1.0.0",
795
- "@slimlib/smart-mock": "^0.1.2",
791
+ "@rollup/plugin-commonjs": "^25.0.5",
792
+ "@rollup/plugin-terser": "^0.4.4",
793
+ "@rollup/plugin-json": "^6.0.1",
794
+ "@rollup/plugin-node-resolve": "^15.2.2",
795
+ "@rollup-extras/plugin-clean": "^1.3.8",
796
+ "@rollup-extras/plugin-binify": "^1.1.9",
797
+ "@rollup-extras/plugin-externals": "^1.1.11",
798
+ "@slimlib/refine-partition": "^1.0.2",
799
+ "@slimlib/smart-mock": "^0.1.5",
796
800
  "is-builtin-module": "^3.2.1",
797
- terser: "^5.16.8",
801
+ terser: "^5.21.0",
798
802
  kleur: "^4.1.5",
799
803
  cleye: "^1.3.2"
800
804
  };
801
805
  var devDependencies = {
802
- "@types/lodash": "^4.14.192",
806
+ "@types/lodash": "^4.14.199",
803
807
  "@total-typescript/ts-reset": "^0.5.1",
804
808
  options: "workspace:*"
805
809
  };
@@ -872,8 +876,11 @@ async function ejectConfig(config, pkgPath, options, inputs, helpers, pkg) {
872
876
  if (options.formats.includes('umd')) {
873
877
  imports.set('path', 'path');
874
878
  imports.set('lodash/camelCase.js', 'camelCase');
879
+ imports.set('url', 'url'); // for __dirname polyfill
875
880
  setup.add(`const pkgName = ${generate(pkgName)}`);
876
881
  setup.add(helpers.getGlobalName.toString());
882
+ // polyfill __dirname
883
+ setup.add('const __dirname = url.fileURLToPath(new URL(\'.\', import.meta.url));');
877
884
  }
878
885
  // imports
879
886
  const importsString = Array.from(imports)
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.21.1",
2
+ "version": "1.22.1",
3
3
  "name": "pkgbld",
4
4
  "license": "MIT",
5
5
  "author": "Konstantin Shutkin",
@@ -27,28 +27,28 @@
27
27
  "rollup"
28
28
  ],
29
29
  "dependencies": {
30
- "@niceties/logger": "^1.1.10",
31
- "@niceties/draftlog-appender": "^1.3.0",
30
+ "@niceties/logger": "^1.1.12",
31
+ "@niceties/draftlog-appender": "^1.3.2",
32
32
  "lodash": "^4.17.21",
33
33
  "rollup": "^4.0.0",
34
34
  "rollup-plugin-typescript2": "^0.36.0",
35
35
  "rollup-plugin-preprocess": "^0.0.4",
36
- "@rollup/plugin-commonjs": "^25.0.0",
37
- "@rollup/plugin-terser": "^0.4.0",
38
- "@rollup/plugin-json": "^6.0.0",
39
- "@rollup/plugin-node-resolve": "^15.0.1",
40
- "@rollup-extras/plugin-clean": "^1.3.4",
41
- "@rollup-extras/plugin-binify": "^1.1.5",
42
- "@rollup-extras/plugin-externals": "^1.1.8",
43
- "@slimlib/refine-partition": "^1.0.0",
44
- "@slimlib/smart-mock": "^0.1.2",
36
+ "@rollup/plugin-commonjs": "^25.0.5",
37
+ "@rollup/plugin-terser": "^0.4.4",
38
+ "@rollup/plugin-json": "^6.0.1",
39
+ "@rollup/plugin-node-resolve": "^15.2.2",
40
+ "@rollup-extras/plugin-clean": "^1.3.8",
41
+ "@rollup-extras/plugin-binify": "^1.1.9",
42
+ "@rollup-extras/plugin-externals": "^1.1.11",
43
+ "@slimlib/refine-partition": "^1.0.2",
44
+ "@slimlib/smart-mock": "^0.1.5",
45
45
  "is-builtin-module": "^3.2.1",
46
- "terser": "^5.16.8",
46
+ "terser": "^5.21.0",
47
47
  "kleur": "^4.1.5",
48
48
  "cleye": "^1.3.2"
49
49
  },
50
50
  "devDependencies": {
51
- "@types/lodash": "^4.14.192",
51
+ "@types/lodash": "^4.14.199",
52
52
  "@total-typescript/ts-reset": "^0.5.1",
53
53
  "options": "0.0.1"
54
54
  },