@bemedev/dev-utils 0.5.1 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +57 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -542,6 +542,17 @@ CLI tooling that packs your built library as a local tarball, installs it
542
542
  under the alias `this-gen-1`, runs your test suite against the real
543
543
  distributable, then tears down.
544
544
 
545
+ Available as a sub-path export:
546
+
547
+ ```typescript
548
+ import {
549
+ addTarball,
550
+ cleanup,
551
+ customImport,
552
+ THIS1,
553
+ } from '@bemedev/dev-utils/build-tests';
554
+ ```
555
+
545
556
  ### CLI usage
546
557
 
547
558
  The binary is `build-tests`. It exposes three subcommands:
@@ -602,6 +613,52 @@ cleanup();
602
613
 
603
614
  ---
604
615
 
616
+ ### `customImport(fn?)`
617
+
618
+ Dynamically imports the installed package (`this-gen-1`) and optionally
619
+ transforms its exports via a mapper function.
620
+
621
+ ```typescript
622
+ import { customImport } from '@bemedev/dev-utils/build-tests';
623
+
624
+ // Import the default export as-is
625
+ const out = await customImport();
626
+
627
+ // Import and pick a specific export
628
+ const myFn = await customImport(mod => mod.myFn);
629
+ ```
630
+
631
+ **Parameters**
632
+
633
+ | Name | Type | Default | Description |
634
+ | ---- | --------------------------- | ------------ | ------------------------------------------------------- |
635
+ | `fn` | `(out: IndexImport) => T` | `identity` | Mapper applied to the imported module; defaults to no-op |
636
+
637
+ **Returns** `Promise<T>` — the mapped module output.
638
+
639
+ ---
640
+
641
+ ### `THIS1`
642
+
643
+ Constant string `'this-gen-1'` — the package alias used by `addTarball` and
644
+ `cleanup` when installing/removing the local tarball.
645
+
646
+ ```typescript
647
+ import { THIS1 } from '@bemedev/dev-utils/build-tests';
648
+
649
+ console.log(THIS1); // 'this-gen-1'
650
+ ```
651
+
652
+ ---
653
+
654
+ ### Types
655
+
656
+ | Name | Description |
657
+ | ------------- | -------------------------------------------------------------------- |
658
+ | `IndexImport` | Type of the module returned by a dynamic `import(THIS1)` call (`any`) |
659
+
660
+ ---
661
+
605
662
  <br/>
606
663
 
607
664
  ## Licence
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/dev-utils",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "A collection of utilities for Node.js development, including build tools, testing utilities, and configuration management.",
5
5
  "author": {
6
6
  "email": "bri_lvi@icloud.com",
@@ -15,8 +15,8 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  "./build-tests": {
18
- "import": "./lib/build-tests/cli/index.js",
19
- "require": "./lib/build-tests/cli/index.cjs"
18
+ "import": "./lib/build-tests/index.js",
19
+ "require": "./lib/build-tests/index.cjs"
20
20
  },
21
21
  "./rolldown": {
22
22
  "import": "./lib/rolldown-config/index.js",