pluribuild 0.1.1 → 0.1.2

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
@@ -6,6 +6,8 @@ Run `npx pluribuild` to build:
6
6
  - `entries/<name>/src/index.ts(x)` into `dist/<name>/index.js`;
7
7
  - `entries/<name>/x.ts(x)` into `dist/<name>/x.js` (`index` as `x` is fine, too).
8
8
 
9
+ Subdirectories of `entries` and entry point files whose names start with an underscore are ignored. Add `--ignore <subdir1> [<subdir2> ...]` to the command to additionally ignore the specified subdirectories of `entries`.
10
+
9
11
  Run `npx pluribuild <dir>` to point to a parent directory other than `entries`.
10
12
 
11
13
  Add `--dev` to the command to enable rebuilds on code changes. Add `--minify=off` to turn off minification.
package/dist/index.cjs CHANGED
@@ -38,16 +38,16 @@ function toEntryPoint(toName) {
38
38
  };
39
39
  }
40
40
 
41
- function getDefaultEntryPoints(dir = "entries") {
42
- let entryPoints = new Map([...(0, node_fs.globSync)(`${dir}/[!_]*/src/index.{ts,tsx}`).map(toEntryPoint((path) => {
41
+ function getDefaultEntryPoints(dir, ignore) {
42
+ let entryPoints = new Map([...(0, node_fs.globSync)(`${dir}/[!_]*/src/index.{ts,tsx}`, { exclude: ignore?.map((subdir) => `${dir}/${subdir}/src/index.{ts,tsx}`) }).map(toEntryPoint((path) => {
43
43
  let p = path.split(node_path.sep);
44
44
  return `${p.at(-3)}/${p.at(-1)}`;
45
- })), ...(0, node_fs.globSync)(`${dir}/[!_]*/[!_]*.{ts,tsx}`).map(toEntryPoint((path) => path.split(node_path.sep).slice(-2).join("/")))]);
45
+ })), ...(0, node_fs.globSync)(`${dir}/[!_]*/[!_]*.{ts,tsx}`, { exclude: ignore?.map((subdir) => `${dir}/${subdir}/[!_]*.{ts,tsx}`) }).map(toEntryPoint((path) => path.split(node_path.sep).slice(-2).join("/")))]);
46
46
  return Array.from(entryPoints.values());
47
47
  }
48
48
 
49
- async function build({ entryPoints, dev, dir, ...options } = {}) {
50
- let e = entryPoints ?? getDefaultEntryPoints(dir);
49
+ async function build({ entryPoints, dev, dir = "entries", ignore, ...options } = {}) {
50
+ let e = entryPoints ?? getDefaultEntryPoints(dir, ignore);
51
51
  if (Object.keys(e).length === 0) {
52
52
  console.warn("No entry points");
53
53
  return;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import { BuildOptions as BuildOptions$1 } from "esbuild";
2
2
 
3
3
  type BuildOptions = BuildOptions$1 & {
4
- /** Directory containing entry points. */dir?: string; /** Development mode. Enables rebuilds on code changes. */
4
+ /**
5
+ * Directory containing entry points.
6
+ * @default "entries"
7
+ */
8
+ dir?: string; /** List of ignored subdirectories of `dir`. */
9
+ ignore?: string[]; /** Development mode. Enables rebuilds on code changes. */
5
10
  dev?: boolean;
6
11
  };
7
12
 
@@ -9,6 +14,7 @@ declare function build({
9
14
  entryPoints,
10
15
  dev,
11
16
  dir,
17
+ ignore,
12
18
  ...options
13
19
  }?: BuildOptions): Promise<void>;
14
20
 
@@ -17,7 +23,7 @@ type EntryPoint = {
17
23
  out: string;
18
24
  };
19
25
 
20
- declare function getDefaultEntryPoints(dir?: string): EntryPoint[];
26
+ declare function getDefaultEntryPoints(dir: string, ignore?: string[]): EntryPoint[];
21
27
 
22
28
  declare function toEntryPoint(toName: (path: string) => string | undefined): (path: string) => [string, EntryPoint];
23
29
 
package/dist/index.mjs CHANGED
@@ -14,16 +14,16 @@ function toEntryPoint(toName) {
14
14
  };
15
15
  }
16
16
 
17
- function getDefaultEntryPoints(dir = "entries") {
18
- let entryPoints = new Map([...globSync(`${dir}/[!_]*/src/index.{ts,tsx}`).map(toEntryPoint((path) => {
17
+ function getDefaultEntryPoints(dir, ignore) {
18
+ let entryPoints = new Map([...globSync(`${dir}/[!_]*/src/index.{ts,tsx}`, { exclude: ignore?.map((subdir) => `${dir}/${subdir}/src/index.{ts,tsx}`) }).map(toEntryPoint((path) => {
19
19
  let p = path.split(sep);
20
20
  return `${p.at(-3)}/${p.at(-1)}`;
21
- })), ...globSync(`${dir}/[!_]*/[!_]*.{ts,tsx}`).map(toEntryPoint((path) => path.split(sep).slice(-2).join("/")))]);
21
+ })), ...globSync(`${dir}/[!_]*/[!_]*.{ts,tsx}`, { exclude: ignore?.map((subdir) => `${dir}/${subdir}/[!_]*.{ts,tsx}`) }).map(toEntryPoint((path) => path.split(sep).slice(-2).join("/")))]);
22
22
  return Array.from(entryPoints.values());
23
23
  }
24
24
 
25
- async function build({ entryPoints, dev, dir, ...options } = {}) {
26
- let e = entryPoints ?? getDefaultEntryPoints(dir);
25
+ async function build({ entryPoints, dev, dir = "entries", ignore, ...options } = {}) {
26
+ let e = entryPoints ?? getDefaultEntryPoints(dir, ignore);
27
27
  if (Object.keys(e).length === 0) {
28
28
  console.warn("No entry points");
29
29
  return;
package/dist/run.mjs CHANGED
@@ -248,10 +248,12 @@ function toEntryPoint(toName) {
248
248
  }
249
249
 
250
250
  // src/getDefaultEntryPoints.ts
251
- function getDefaultEntryPoints(dir = "entries") {
251
+ function getDefaultEntryPoints(dir, ignore) {
252
252
  let entryPoints = new Map([
253
253
  // entries/x/src/index.ts -> dist/x/index.js
254
- ...globSync(`${dir}/[!_]*/src/index.{ts,tsx}`).map(
254
+ ...globSync(`${dir}/[!_]*/src/index.{ts,tsx}`, {
255
+ exclude: ignore?.map((subdir) => `${dir}/${subdir}/src/index.{ts,tsx}`)
256
+ }).map(
255
257
  toEntryPoint((path) => {
256
258
  let p = path.split(sep);
257
259
  return `${p.at(-3)}/${p.at(-1)}`;
@@ -259,9 +261,9 @@ function getDefaultEntryPoints(dir = "entries") {
259
261
  ),
260
262
  // entries/x/index.ts -> dist/x/index.js (overrides entries/x/src/index.ts, if present)
261
263
  // entries/x/y.ts -> dist/x/y.js
262
- ...globSync(`${dir}/[!_]*/[!_]*.{ts,tsx}`).map(
263
- toEntryPoint((path) => path.split(sep).slice(-2).join("/"))
264
- )
264
+ ...globSync(`${dir}/[!_]*/[!_]*.{ts,tsx}`, {
265
+ exclude: ignore?.map((subdir) => `${dir}/${subdir}/[!_]*.{ts,tsx}`)
266
+ }).map(toEntryPoint((path) => path.split(sep).slice(-2).join("/")))
265
267
  ]);
266
268
  return Array.from(entryPoints.values());
267
269
  }
@@ -270,10 +272,11 @@ function getDefaultEntryPoints(dir = "entries") {
270
272
  async function build({
271
273
  entryPoints,
272
274
  dev: dev2,
273
- dir,
275
+ dir = "entries",
276
+ ignore,
274
277
  ...options2
275
278
  } = {}) {
276
- let e = entryPoints ?? getDefaultEntryPoints(dir);
279
+ let e = entryPoints ?? getDefaultEntryPoints(dir, ignore);
277
280
  if (Object.keys(e).length === 0) {
278
281
  console.warn("No entry points");
279
282
  return;
@@ -305,7 +308,8 @@ var args = new import_args_json.Args();
305
308
  var dev = args.hasKey("--dev");
306
309
  var options = {
307
310
  dev,
308
- minify: !args.isExplicitlyOff("--minify")
311
+ minify: !args.isExplicitlyOff("--minify"),
312
+ ignore: args.getValues("--ignore")
309
313
  };
310
314
  var rawArgs = process.argv.slice(2);
311
315
  if (rawArgs.length !== 0 && !(0, import_args_json.isKey)(rawArgs[0])) options.dir = rawArgs[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pluribuild",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Build multiple entry points into multiple output files with a single command",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -1,8 +1,13 @@
1
1
  import type { BuildOptions as EsbuildOptions } from "esbuild";
2
2
 
3
3
  export type BuildOptions = EsbuildOptions & {
4
- /** Directory containing entry points. */
4
+ /**
5
+ * Directory containing entry points.
6
+ * @default "entries"
7
+ */
5
8
  dir?: string;
9
+ /** List of ignored subdirectories of `dir`. */
10
+ ignore?: string[];
6
11
  /** Development mode. Enables rebuilds on code changes. */
7
12
  dev?: boolean;
8
13
  };
package/src/build.ts CHANGED
@@ -5,10 +5,11 @@ import { getDefaultEntryPoints } from "./getDefaultEntryPoints.ts";
5
5
  export async function build({
6
6
  entryPoints,
7
7
  dev,
8
- dir,
8
+ dir = "entries",
9
+ ignore,
9
10
  ...options
10
11
  }: BuildOptions = {}) {
11
- let e = entryPoints ?? getDefaultEntryPoints(dir);
12
+ let e = entryPoints ?? getDefaultEntryPoints(dir, ignore);
12
13
 
13
14
  if (Object.keys(e).length === 0) {
14
15
  console.warn("No entry points");
@@ -2,10 +2,12 @@ import { globSync } from "node:fs";
2
2
  import { sep } from "node:path";
3
3
  import { toEntryPoint } from "./toEntryPoint.ts";
4
4
 
5
- export function getDefaultEntryPoints(dir = "entries") {
5
+ export function getDefaultEntryPoints(dir: string, ignore?: string[]) {
6
6
  let entryPoints = new Map([
7
7
  // entries/x/src/index.ts -> dist/x/index.js
8
- ...globSync(`${dir}/[!_]*/src/index.{ts,tsx}`).map(
8
+ ...globSync(`${dir}/[!_]*/src/index.{ts,tsx}`, {
9
+ exclude: ignore?.map((subdir) => `${dir}/${subdir}/src/index.{ts,tsx}`),
10
+ }).map(
9
11
  toEntryPoint((path) => {
10
12
  let p = path.split(sep);
11
13
  return `${p.at(-3)}/${p.at(-1)}`;
@@ -13,9 +15,9 @@ export function getDefaultEntryPoints(dir = "entries") {
13
15
  ),
14
16
  // entries/x/index.ts -> dist/x/index.js (overrides entries/x/src/index.ts, if present)
15
17
  // entries/x/y.ts -> dist/x/y.js
16
- ...globSync(`${dir}/[!_]*/[!_]*.{ts,tsx}`).map(
17
- toEntryPoint((path) => path.split(sep).slice(-2).join("/")),
18
- ),
18
+ ...globSync(`${dir}/[!_]*/[!_]*.{ts,tsx}`, {
19
+ exclude: ignore?.map((subdir) => `${dir}/${subdir}/[!_]*.{ts,tsx}`),
20
+ }).map(toEntryPoint((path) => path.split(sep).slice(-2).join("/"))),
19
21
  ]);
20
22
 
21
23
  return Array.from(entryPoints.values());
package/src/run.ts CHANGED
@@ -9,6 +9,7 @@ let dev = args.hasKey("--dev");
9
9
  let options: BuildOptions = {
10
10
  dev,
11
11
  minify: !args.isExplicitlyOff("--minify"),
12
+ ignore: args.getValues("--ignore"),
12
13
  };
13
14
 
14
15
  let rawArgs = process.argv.slice(2);