pkgbld 1.5.5 → 1.6.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
@@ -73,6 +73,14 @@ pkgbld --dir=dist
73
73
 
74
74
  Directory to put output files.
75
75
 
76
+ ### sourcedir
77
+
78
+ ```
79
+ pkgbld --sourcedir=src
80
+ ```
81
+
82
+ Directory to search for input files.
83
+
76
84
  # License
77
85
 
78
86
  [MIT](./LICENSE)
@@ -5,4 +5,5 @@ export declare function getCliOptions(): {
5
5
  formats: string[];
6
6
  preprocess: string[];
7
7
  dir: string;
8
+ sourceDir: string;
8
9
  };
package/dist/helpers.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare function getHelpers(pkg: any): {
6
6
  };
7
7
  export declare function umdFilter(config: ReturnType<typeof getCliOptions>, filename: string): boolean;
8
8
  export declare function toArray<T>(object: T): (T & any[]) | T[];
9
- export declare function isExternalInput(id: string, inputs: string | string[], currentInput: string): boolean;
9
+ export declare function isExternalInput(id: string, inputs: string | string[], currentInput: string, config: ReturnType<typeof getCliOptions>): boolean;
10
10
  export declare function formatInput(input: string[] | string | undefined): string | undefined;
11
11
  export declare function formatOutput(output: any, field: string): string | undefined;
12
12
  export declare function getTimeDiff(starting: number): string;
package/dist/index.js CHANGED
@@ -47,10 +47,11 @@ const defaults = {
47
47
  compressTargets: ['umd'],
48
48
  sourcemapTargets: ['umd'],
49
49
  preprocess: [],
50
- dir: 'dist'
50
+ dir: 'dist',
51
+ sourceDir: 'src'
51
52
  };
52
53
  function getCliOptions() {
53
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
54
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
54
55
  const parsedArgs = minimist__default["default"](process.argv.slice(2));
55
56
  const umdTargets = (_b = (_a = parsedArgs.umd) === null || _a === void 0 ? void 0 : _a.split(',').map((arg) => arg.trim())) !== null && _b !== void 0 ? _b : defaults.umdTargets;
56
57
  const compressTargets = (_d = (_c = parsedArgs.compress) === null || _c === void 0 ? void 0 : _c.split(',').map((arg) => arg.trim())) !== null && _d !== void 0 ? _d : defaults.compressTargets;
@@ -58,13 +59,15 @@ function getCliOptions() {
58
59
  const formats = (_h = (_g = parsedArgs.formats) === null || _g === void 0 ? void 0 : _g.split(',').map((arg) => arg.trim())) !== null && _h !== void 0 ? _h : defaults.formats;
59
60
  const preprocess = (_k = (_j = parsedArgs.preprocess) === null || _j === void 0 ? void 0 : _j.split(',').map((arg) => arg.trim())) !== null && _k !== void 0 ? _k : defaults.preprocess;
60
61
  const dir = (_l = parsedArgs.dir) !== null && _l !== void 0 ? _l : defaults.dir;
62
+ const sourceDir = (_m = parsedArgs.sourceDir) !== null && _m !== void 0 ? _m : defaults.sourceDir;
61
63
  return {
62
64
  umdTargets,
63
65
  compressTargets,
64
66
  sourcemapTargets,
65
67
  formats,
66
68
  preprocess,
67
- dir
69
+ dir,
70
+ sourceDir
68
71
  };
69
72
  }
70
73
 
@@ -101,13 +104,13 @@ function toArray(object) {
101
104
  }
102
105
  return [object];
103
106
  }
104
- function isExternalInput(id, inputs, currentInput) {
107
+ function isExternalInput(id, inputs, currentInput, config) {
105
108
  let normalizedPath;
106
109
  if (path__default["default"].isAbsolute(id)) {
107
110
  normalizedPath = './' + path__default["default"].relative(process.cwd(), id);
108
111
  }
109
112
  else {
110
- normalizedPath = './' + path__default["default"].join('src', id + '.ts');
113
+ normalizedPath = './' + path__default["default"].join(config.sourceDir, id + '.ts');
111
114
  }
112
115
  return normalizedPath !== currentInput && inputs.includes(normalizedPath);
113
116
  }
@@ -132,14 +135,14 @@ function getBuildPlugins(format, config, inputs, currentInput) {
132
135
  clean,
133
136
  externals__default["default"]({
134
137
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
135
- external: (id, external) => external || (format === 'umd' ? isExternalInput(id, inputs, currentInput) : false)
138
+ external: (id, external) => external || (format === 'umd' ? isExternalInput(id, inputs, currentInput, config) : false)
136
139
  }),
137
140
  resolve__default["default"](),
138
141
  commonjs__default["default"](),
139
142
  typescript__default["default"]()
140
143
  ];
141
144
  if (config.preprocess.length) {
142
- result.unshift(preprocess__default["default"]({ include: config.preprocess.map(name => `src/${name}.ts`), context: getPreprocessContext(format) }));
145
+ result.unshift(preprocess__default["default"]({ include: config.preprocess.map(name => `${config.sourceDir}/${name}.ts`), context: getPreprocessContext(format) }));
143
146
  }
144
147
  return result;
145
148
  }
@@ -268,7 +271,7 @@ function processPackage(pkg, config) {
268
271
  pkg.files.push(basename);
269
272
  }
270
273
  }
271
- input.push(`./src/${basename}.ts`);
274
+ input.push(`./${config.sourceDir}/${basename}.ts`);
272
275
  }
273
276
  return input;
274
277
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.5",
2
+ "version": "1.6.0",
3
3
  "license": "MIT",
4
4
  "name": "pkgbld",
5
5
  "author": {
package/dist/types.d.ts DELETED
File without changes