@bemedev/dev-utils 1.0.0 → 1.0.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 +34 -14
- package/lib/build-tests/addTarball.d.ts +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +3 -3
- package/lib/build-tests/cleanup.d.ts +1 -1
- package/lib/build-tests/cli/cli.d.ts +51 -1
- package/lib/build-tests/cli/index.d.ts +1 -0
- package/lib/build-tests/cli/post.d.ts +5 -1
- package/lib/build-tests/cli/pre.d.ts +5 -1
- package/lib/build-tests/cli/test.d.ts +15 -1
- package/lib/build-tests/constants.d.ts +1 -1
- package/lib/build-tests/getRelativePath.d.ts +1 -1
- package/lib/build-tests/getTypescriptOutdir.d.ts +1 -1
- package/lib/build-tests/import.d.ts +2 -2
- package/lib/build-tests/imports/create.d.ts +3 -3
- package/lib/build-tests/imports/helper.d.ts +7 -3
- package/lib/build-tests/imports/index.d.ts +1 -1
- package/lib/build-tests/index.d.ts +5 -5
- package/lib/build-tests/pack.d.ts +1 -1
- package/lib/rolldown-config/config.d.ts +1 -1
- package/lib/rolldown-config/constants.d.ts +5 -5
- package/lib/rolldown-config/helpers.d.ts +2 -2
- package/lib/rolldown-config/index.d.ts +3 -3
- package/lib/rolldown-config/input.d.ts +1 -1
- package/lib/rolldown-config/output.d.ts +15 -1
- package/lib/rolldown-config/plugins/circulars.d.ts +9 -9
- package/lib/rolldown-config/plugins/clean.cjs +3 -1
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +13 -4
- package/lib/rolldown-config/plugins/clean.js +4 -2
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.d.ts +7 -7
- package/lib/rolldown-config/plugins/index.d.ts +23 -2
- package/lib/rolldown-config/plugins/typescript.cjs +29 -41
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs +46 -39
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.d.ts +2 -4
- package/lib/rolldown-config/plugins/typescript.config.js +47 -41
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +6 -6
- package/lib/rolldown-config/plugins/typescript.js +29 -43
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/types.d.ts +13 -13
- package/lib/utils/array.d.ts +1 -1
- package/lib/utils/identity.d.ts +1 -1
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/sleep.d.ts +1 -1
- package/lib/utils/types.d.ts +1 -4
- package/lib/vitest-exclude/index.d.ts +1 -1
- package/lib/vitest-exclude/types.d.ts +11 -8
- package/lib/vitest-exclude/vitest.cjs +0 -2
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +27 -15
- package/lib/vitest-exclude/vitest.js +0 -2
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +2 -2
- package/lib/vitest-extended/acceptation.d.ts +3 -2
- package/lib/vitest-extended/bemedev/globals/types.d.ts +1 -4
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.d.ts +10 -10
- package/lib/vitest-extended/createTests.d.ts +55 -34
- package/lib/vitest-extended/createTests.types.d.ts +6 -10
- package/lib/vitest-extended/done.d.ts +14 -8
- package/lib/vitest-extended/each/error.d.ts +1 -1
- package/lib/vitest-extended/each/error.types.d.ts +4 -10
- package/lib/vitest-extended/each/index.d.ts +2 -2
- package/lib/vitest-extended/each/pass.d.ts +26 -26
- package/lib/vitest-extended/each/pass.types.d.ts +6 -18
- package/lib/vitest-extended/fakeWaiter.d.ts +3 -3
- package/lib/vitest-extended/identity.d.ts +2 -2
- package/lib/vitest-extended/index.cjs +2 -0
- package/lib/vitest-extended/index.d.ts +7 -6
- package/lib/vitest-extended/index.js +2 -1
- package/lib/vitest-extended/isDefined.d.ts +1 -1
- package/lib/vitest-extended/isFunction.d.ts +1 -1
- package/lib/vitest-extended/project.cjs +23 -0
- package/lib/vitest-extended/project.cjs.map +1 -0
- package/lib/vitest-extended/project.d.ts +2 -0
- package/lib/vitest-extended/project.js +22 -0
- package/lib/vitest-extended/project.js.map +1 -0
- package/lib/vitest-extended/toArray.d.ts +1 -1
- package/lib/vitest-extended/toStringFlat.d.ts +1 -1
- package/lib/vitest-extended/types.d.ts +38 -40
- package/package.json +3 -7
package/README.md
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
A collection of utilities for Node.js development, including build tools,
|
|
4
4
|
testing utilities, and configuration management.
|
|
5
5
|
|
|
6
|
+
## HOTFIX fix for version 1.0.*
|
|
7
|
+
|
|
8
|
+
> It doesn't type declarations well, if you're not put directly the output
|
|
9
|
+
> type
|
|
10
|
+
|
|
6
11
|
## Modules
|
|
7
12
|
|
|
8
13
|
| Module | Description |
|
|
@@ -365,6 +370,29 @@ vitestExtended.useTFA(myFunction, 'myFunction');
|
|
|
365
370
|
|
|
366
371
|
---
|
|
367
372
|
|
|
373
|
+
### `defineProject(config)`
|
|
374
|
+
|
|
375
|
+
A wrapper around Vitest's `defineProject` / `defineConfig` that injects
|
|
376
|
+
default configurations.
|
|
377
|
+
|
|
378
|
+
> [!IMPORTANT] **HOT FIX**: Use this instead of standard `defineProject`
|
|
379
|
+
> from `vitest/config` to automatically resolve path aliases (via
|
|
380
|
+
> `tsconfigPaths: true`), set `globals: true`, configure
|
|
381
|
+
> `logHeapUsage: false`, and set the `NODE_ENV` environment variable to
|
|
382
|
+
> `'test'` by default.
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
import { defineProject } from '@bemedev/dev-utils/vitest-extended';
|
|
386
|
+
|
|
387
|
+
export default defineProject({
|
|
388
|
+
test: {
|
|
389
|
+
// your config here
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
368
396
|
### Utility helpers
|
|
369
397
|
|
|
370
398
|
| Export | Signature | Description |
|
|
@@ -379,8 +407,7 @@ vitestExtended.useTFA(myFunction, 'myFunction');
|
|
|
379
407
|
## `rolldownConfig`
|
|
380
408
|
|
|
381
409
|
Rolldown bundler configuration factory with built-in plugins for TypeScript
|
|
382
|
-
declarations,
|
|
383
|
-
tree-shaking externals.
|
|
410
|
+
declarations, circular dependency detection, and tree-shaking externals.
|
|
384
411
|
|
|
385
412
|
### `defineConfig(additionals?)`
|
|
386
413
|
|
|
@@ -390,16 +417,13 @@ Shorthand for `defineConfig.default`.
|
|
|
390
417
|
|
|
391
418
|
Produces a full Rolldown config with the default plugin pipeline:
|
|
392
419
|
|
|
393
|
-
1. **
|
|
394
|
-
2. **tsPaths** — resolves tsconfig path imports at bundle time
|
|
395
|
-
(`rollup-plugin-tsconfig-paths`)
|
|
396
|
-
3. **circulars** — warns on circular dependencies
|
|
420
|
+
1. **circulars** — warns on circular dependencies
|
|
397
421
|
(`rollup-plugin-circular-dependency`)
|
|
398
|
-
|
|
422
|
+
2. **externals** — marks `dependencies` and `peerDependencies` as external
|
|
399
423
|
(`rollup-plugin-node-externals`)
|
|
400
|
-
|
|
424
|
+
3. **typescript** — emits `.d.ts` declarations via the TypeScript compiler
|
|
401
425
|
API
|
|
402
|
-
|
|
426
|
+
4. **clean** — removes JS outputs for files that produce empty chunks
|
|
403
427
|
|
|
404
428
|
```typescript
|
|
405
429
|
// rolldown.config.ts
|
|
@@ -464,8 +488,6 @@ Individual plugin factories are available for custom pipeline assembly:
|
|
|
464
488
|
|
|
465
489
|
| Key | Function | Wraps |
|
|
466
490
|
| ------------ | ---------------------- | ------------------------------------- |
|
|
467
|
-
| `alias` | `alias(options?)` | `rollup-plugin-tsc-alias` |
|
|
468
|
-
| `tsPaths` | `tsPaths(options?)` | `rollup-plugin-tsconfig-paths` |
|
|
469
491
|
| `circulars` | `circulars(options?)` | `rollup-plugin-circular-dependency` |
|
|
470
492
|
| `externals` | `externals(options?)` | `rollup-plugin-node-externals` |
|
|
471
493
|
| `typescript` | `typescript(options?)` | TypeScript compiler API + `tsc-alias` |
|
|
@@ -475,9 +497,7 @@ Pass plugin keys as strings in the `plugins` array to reorder or subset
|
|
|
475
497
|
them:
|
|
476
498
|
|
|
477
499
|
```typescript
|
|
478
|
-
defineConfig.default({
|
|
479
|
-
plugins: ['alias', 'tsPaths', 'externals', 'typescript'],
|
|
480
|
-
});
|
|
500
|
+
defineConfig.default({ plugins: ['externals', 'typescript'] });
|
|
481
501
|
```
|
|
482
502
|
|
|
483
503
|
---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const addTarball:
|
|
1
|
+
export declare const addTarball: () => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Fn } from
|
|
1
|
+
import type { Fn } from '../utils/index.js';
|
|
2
2
|
type BuldPackageJson_F = Fn<[], {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
packageJson: object;
|
|
4
|
+
outDir: string;
|
|
5
5
|
}>;
|
|
6
6
|
export declare const buildPackageJson: BuldPackageJson_F;
|
|
7
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const cleanup:
|
|
1
|
+
export declare const cleanup: () => void;
|
|
@@ -1,2 +1,52 @@
|
|
|
1
1
|
export declare const BIN = "build-tests";
|
|
2
|
-
export declare const cli:
|
|
2
|
+
export declare const cli: Partial<import("cmd-ts/dist/cjs/argparser").Register> & {
|
|
3
|
+
parse(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{
|
|
4
|
+
command: "posttest";
|
|
5
|
+
args: {};
|
|
6
|
+
} | {
|
|
7
|
+
command: "pretest";
|
|
8
|
+
args: {};
|
|
9
|
+
} | {
|
|
10
|
+
command: "test";
|
|
11
|
+
args: {
|
|
12
|
+
pretest: boolean;
|
|
13
|
+
posttest: boolean;
|
|
14
|
+
pre: boolean;
|
|
15
|
+
post: boolean;
|
|
16
|
+
};
|
|
17
|
+
}>>;
|
|
18
|
+
} & import("cmd-ts/dist/cjs/helpdoc").Named & Partial<import("cmd-ts/dist/cjs/helpdoc").Descriptive & import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/helpdoc").PrintHelp & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/argparser").Register & import("cmd-ts/dist/cjs/runner").Handling<{
|
|
19
|
+
command: "posttest";
|
|
20
|
+
args: {};
|
|
21
|
+
} | {
|
|
22
|
+
command: "pretest";
|
|
23
|
+
args: {};
|
|
24
|
+
} | {
|
|
25
|
+
command: "test";
|
|
26
|
+
args: {
|
|
27
|
+
pretest: boolean;
|
|
28
|
+
posttest: boolean;
|
|
29
|
+
pre: boolean;
|
|
30
|
+
post: boolean;
|
|
31
|
+
};
|
|
32
|
+
}, {
|
|
33
|
+
command: "posttest";
|
|
34
|
+
value: void;
|
|
35
|
+
} | {
|
|
36
|
+
command: "pretest";
|
|
37
|
+
value: Promise<void>;
|
|
38
|
+
} | {
|
|
39
|
+
command: "test";
|
|
40
|
+
value: Promise<void>;
|
|
41
|
+
}> & {
|
|
42
|
+
run(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{
|
|
43
|
+
command: "posttest";
|
|
44
|
+
value: void;
|
|
45
|
+
} | {
|
|
46
|
+
command: "pretest";
|
|
47
|
+
value: Promise<void>;
|
|
48
|
+
} | {
|
|
49
|
+
command: "test";
|
|
50
|
+
value: Promise<void>;
|
|
51
|
+
}>>;
|
|
52
|
+
};
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export declare const posttest:
|
|
1
|
+
export declare const posttest: Partial<import("cmd-ts/dist/cjs/argparser").Register> & {
|
|
2
|
+
parse(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{}>>;
|
|
3
|
+
} & import("cmd-ts/dist/cjs/helpdoc").PrintHelp & import("cmd-ts/dist/cjs/helpdoc").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc").Named & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/argparser").Register & import("cmd-ts/dist/cjs/runner").Handling<{}, void> & {
|
|
4
|
+
run(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<void>>;
|
|
5
|
+
} & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned & import("cmd-ts/dist/cjs/helpdoc").Descriptive & import("cmd-ts/dist/cjs/helpdoc").Aliased>;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export declare const pretest:
|
|
1
|
+
export declare const pretest: Partial<import("cmd-ts/dist/cjs/argparser").Register> & {
|
|
2
|
+
parse(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{}>>;
|
|
3
|
+
} & import("cmd-ts/dist/cjs/helpdoc").PrintHelp & import("cmd-ts/dist/cjs/helpdoc").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc").Named & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/argparser").Register & import("cmd-ts/dist/cjs/runner").Handling<{}, Promise<void>> & {
|
|
4
|
+
run(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<Promise<void>>>;
|
|
5
|
+
} & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned & import("cmd-ts/dist/cjs/helpdoc").Descriptive & import("cmd-ts/dist/cjs/helpdoc").Aliased>;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
export declare const test:
|
|
1
|
+
export declare const test: Partial<import("cmd-ts/dist/cjs/argparser").Register> & {
|
|
2
|
+
parse(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<{
|
|
3
|
+
pretest: boolean;
|
|
4
|
+
posttest: boolean;
|
|
5
|
+
pre: boolean;
|
|
6
|
+
post: boolean;
|
|
7
|
+
}>>;
|
|
8
|
+
} & import("cmd-ts/dist/cjs/helpdoc").PrintHelp & import("cmd-ts/dist/cjs/helpdoc").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc").Named & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned> & import("cmd-ts/dist/cjs/argparser").Register & import("cmd-ts/dist/cjs/runner").Handling<{
|
|
9
|
+
pretest: boolean;
|
|
10
|
+
posttest: boolean;
|
|
11
|
+
pre: boolean;
|
|
12
|
+
post: boolean;
|
|
13
|
+
}, Promise<void>> & {
|
|
14
|
+
run(context: import("cmd-ts/dist/cjs/argparser").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser").ParsingResult<Promise<void>>>;
|
|
15
|
+
} & Partial<import("cmd-ts/dist/cjs/helpdoc").Versioned & import("cmd-ts/dist/cjs/helpdoc").Descriptive & import("cmd-ts/dist/cjs/helpdoc").Aliased>;
|
|
@@ -10,5 +10,5 @@ export declare const TS_PATH = "./tsconfig.json";
|
|
|
10
10
|
export declare const PACKAGE_PATH = "./package.json";
|
|
11
11
|
export declare const TARBALL_FOLDER = ".pack";
|
|
12
12
|
export declare const TARBALL_EXTENSION = ".tgz";
|
|
13
|
-
export declare const TEARDOWN_COMMAND
|
|
13
|
+
export declare const TEARDOWN_COMMAND = "pnpm remove this-gen-1";
|
|
14
14
|
export declare const DEFAULT_OUT_DIR = "./lib";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type ImportArgs = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
path?: string;
|
|
3
|
+
FAILS?: string[];
|
|
4
|
+
SUCCESS: string[];
|
|
5
5
|
};
|
|
6
6
|
export type CreateImportTest_F = (args: ImportArgs) => readonly [string, () => void];
|
|
7
7
|
export declare const createImportFnTests: CreateImportTest_F;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { Fn } from '../../vitest-extended/bemedev/globals/types';
|
|
1
2
|
export type Helper_F = (args: {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
path?: string;
|
|
4
|
+
fn: string;
|
|
5
|
+
}) => Promise<void>;
|
|
6
|
+
export declare const helperFn: <T extends Fn = Fn>({ path, fn, }: {
|
|
7
|
+
path?: string;
|
|
8
|
+
fn: string;
|
|
4
9
|
}) => Promise<void>;
|
|
5
|
-
export declare const helperFn: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './create';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export { THIS1 } from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './addTarball';
|
|
2
|
+
export * from './cleanup';
|
|
3
|
+
export { THIS1 } from './constants';
|
|
4
|
+
export * from './import';
|
|
5
|
+
export * from './imports';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Config_F } from
|
|
1
|
+
import type { Config_F } from './types';
|
|
2
2
|
export declare const defineConfig: Config_F;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const DEFAULT_EXCLUDE:
|
|
2
|
-
export declare const DEFAULT_CIRCULAR_DEPS:
|
|
3
|
-
export declare const IGNORE:
|
|
1
|
+
export declare const DEFAULT_EXCLUDE: string[];
|
|
2
|
+
export declare const DEFAULT_CIRCULAR_DEPS: string[];
|
|
3
|
+
export declare const IGNORE: string[];
|
|
4
4
|
export declare const DEFAULT_DIR = "lib";
|
|
5
5
|
export declare const WARNING_CODES: {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
EMPTY_BUNDLE: string;
|
|
7
|
+
CIRCULAR_DEPENDENCY: string;
|
|
8
8
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const withoutExtension:
|
|
2
|
-
export declare const cleanupJS:
|
|
1
|
+
export declare const withoutExtension: (file: string) => string;
|
|
2
|
+
export declare const cleanupJS: (files: Set<string>, dir: string, sourcemap: boolean) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './config';
|
|
2
|
+
export * from './plugins';
|
|
3
|
+
export * from './types';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BuildInput_F } from
|
|
1
|
+
import type { BuildInput_F } from './types';
|
|
2
2
|
export declare const buildInput: BuildInput_F;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
export declare const buildOutput:
|
|
1
|
+
export declare const buildOutput: (dir: string | undefined, sourcemap: boolean) => [{
|
|
2
|
+
readonly format: "es";
|
|
3
|
+
readonly sourcemap: boolean;
|
|
4
|
+
readonly preserveModulesRoot: "src";
|
|
5
|
+
readonly dir: string;
|
|
6
|
+
readonly preserveModules: true;
|
|
7
|
+
readonly entryFileNames: "[name].js";
|
|
8
|
+
}, {
|
|
9
|
+
readonly format: "cjs";
|
|
10
|
+
readonly sourcemap: boolean;
|
|
11
|
+
readonly preserveModulesRoot: "src";
|
|
12
|
+
readonly dir: string;
|
|
13
|
+
readonly preserveModules: true;
|
|
14
|
+
readonly entryFileNames: "[name].cjs";
|
|
15
|
+
}];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { RolldownPluginOption } from
|
|
2
|
-
import { circularDependencies } from
|
|
1
|
+
import type { RolldownPluginOption } from 'rolldown';
|
|
2
|
+
import { circularDependencies } from 'rollup-plugin-circular-dependencies';
|
|
3
3
|
export type CircularDependenciesOptions = Parameters<typeof circularDependencies>[0] & {
|
|
4
|
-
|
|
4
|
+
exclude?: string | string[];
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
|
-
* Creates a configured circular dependencies plugin instance
|
|
8
|
-
*
|
|
9
|
-
* @param options - Configuration options for circular dependencies
|
|
10
|
-
* detection
|
|
11
|
-
* @returns Rolldown plugin
|
|
12
|
-
*/
|
|
7
|
+
* Creates a configured circular dependencies plugin instance
|
|
8
|
+
*
|
|
9
|
+
* @param options - Configuration options for circular dependencies
|
|
10
|
+
* detection
|
|
11
|
+
* @returns Rolldown plugin
|
|
12
|
+
*/
|
|
13
13
|
export declare function circulars(options?: CircularDependenciesOptions): RolldownPluginOption;
|
|
@@ -3,8 +3,10 @@ const require_utils_array = require("../../utils/array.cjs");
|
|
|
3
3
|
const require_rolldown_config_constants = require("../constants.cjs");
|
|
4
4
|
const require_rolldown_config_helpers = require("../helpers.cjs");
|
|
5
5
|
const require_rolldown_config_plugins_typescript_config = require("./typescript.config.cjs");
|
|
6
|
+
let fs = require("fs");
|
|
6
7
|
let path = require("path");
|
|
7
8
|
let glob = require("glob");
|
|
9
|
+
let _typescript_typescript6 = require("@typescript/typescript6");
|
|
8
10
|
//#region src/rolldown-config/plugins/clean.ts
|
|
9
11
|
const clean = (options) => {
|
|
10
12
|
const { ignoresJS, sourcemap = false, dir } = options;
|
|
@@ -25,7 +27,7 @@ const clean = (options) => {
|
|
|
25
27
|
closeBundle: {
|
|
26
28
|
order: "post",
|
|
27
29
|
handler: () => {
|
|
28
|
-
const outDir = require_rolldown_config_plugins_typescript_config.readTsConfig(
|
|
30
|
+
const outDir = require_rolldown_config_plugins_typescript_config.readTsConfig((0, _typescript_typescript6.findConfigFile)(process.cwd(), fs.existsSync, "tsconfig.json")).options.outDir ?? dir ?? "lib";
|
|
29
31
|
if (_ignoresJS.length > 0) try {
|
|
30
32
|
const files = /* @__PURE__ */ new Set();
|
|
31
33
|
_ignoresJS.forEach((pat) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.cjs","names":["toArray","withoutExtension","WARNING_CODES","readTsConfig","
|
|
1
|
+
{"version":3,"file":"clean.cjs","names":["toArray","withoutExtension","WARNING_CODES","readTsConfig","existsSync"],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n const _outDir = readTsConfig(tsconfigPath).options.outDir;\n const outDir = _outDir ?? dir ?? DEFAULT_DIR;\n if (_ignoresJS.length > 0) {\n try {\n const files = new Set<string>();\n _ignoresJS.forEach(pat => {\n const globs = globSync(pat, { nodir: true });\n globs.forEach(file => files.add(file));\n });\n cleanupJS(files, outDir, sourcemap);\n console.log('Build finished');\n /* v8 ignore next 3 */\n } catch (err) {\n console.error('[end-bemedev] cleanup failed:', err);\n }\n }\n },\n },\n } satisfies RolldownPluginOption;\n\n return out;\n};\n"],"mappings":";;;;;;;;;;AAmBA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAaA,oBAAAA,QAAQ,SAAS;CA4DpC,OAAO;EAzDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,OAAA,GAAA,KAAA,SAAA,CAAc,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAIC,gCAAAA,gBAAgB,CAAC,CACrB,KAAI,UAAA,GAAA,KAAA,SAAA,CAAiB,OAAO,IAAI,CAAC;GAMpC,IAHE,SAASC,kCAAAA,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,IAAI,CAAC,GAEvC;IACT,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,kDAAkD;IAC9D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,OAAO;GACT;EAGF,EACF;EAEA,aAAa;GACX,OAAO;GACP,eAAe;IASb,MAAM,SADUC,kDAAAA,cAAAA,GAAAA,wBAAAA,eAAAA,CAPJ,QAAQ,IAGhB,GACFC,GAAAA,YACA,eAEsC,CAAC,CAAC,CAAC,QAAQ,UACzB,OAAA;IAC1B,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,IAAY;KAC9B,WAAW,SAAQ,QAAO;MAExB,CAAA,GAAA,KAAA,SAAA,CADuB,KAAK,EAAE,OAAO,KAAK,CACtC,CAAC,CAAC,SAAQ,SAAQ,MAAM,IAAI,IAAI,CAAC;KACvC,CAAC;KACD,gCAAA,UAAU,OAAO,QAAQ,SAAS;KAClC,QAAQ,IAAI,gBAAgB;IAE9B,SAAS,KAAK;KACZ,QAAQ,MAAM,iCAAiC,GAAG;IACpD;GAEJ;EACF;CAGO;AACX"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
export type EndPluginOptions = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
ignoresJS?: string | string[];
|
|
3
|
+
sourcemap?: boolean;
|
|
4
|
+
dir?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const clean: (options: EndPluginOptions) => {
|
|
7
|
+
name: string;
|
|
8
|
+
onLog: {
|
|
9
|
+
handler: (this: import("rolldown").MinimalPluginContext, _: import("rolldown").LogLevel, { code, names }: import("rolldown").RolldownLog) => false | undefined;
|
|
10
|
+
};
|
|
11
|
+
closeBundle: {
|
|
12
|
+
order: "post";
|
|
13
|
+
handler: () => void;
|
|
14
|
+
};
|
|
5
15
|
};
|
|
6
|
-
export declare const clean: unknown;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { toArray } from "../../utils/array.js";
|
|
2
2
|
import { WARNING_CODES } from "../constants.js";
|
|
3
3
|
import { cleanupJS, withoutExtension } from "../helpers.js";
|
|
4
|
-
import {
|
|
4
|
+
import { readTsConfig } from "./typescript.config.js";
|
|
5
|
+
import { existsSync } from "fs";
|
|
5
6
|
import { relative } from "path";
|
|
6
7
|
import { globSync } from "glob";
|
|
8
|
+
import { findConfigFile } from "@typescript/typescript6";
|
|
7
9
|
//#region src/rolldown-config/plugins/clean.ts
|
|
8
10
|
const clean = (options) => {
|
|
9
11
|
const { ignoresJS, sourcemap = false, dir } = options;
|
|
@@ -24,7 +26,7 @@ const clean = (options) => {
|
|
|
24
26
|
closeBundle: {
|
|
25
27
|
order: "post",
|
|
26
28
|
handler: () => {
|
|
27
|
-
const outDir = readTsConfig(findConfigFile(process.cwd(), "tsconfig.json")).
|
|
29
|
+
const outDir = readTsConfig(findConfigFile(process.cwd(), existsSync, "tsconfig.json")).options.outDir ?? dir ?? "lib";
|
|
28
30
|
if (_ignoresJS.length > 0) try {
|
|
29
31
|
const files = /* @__PURE__ */ new Set();
|
|
30
32
|
_ignoresJS.forEach((pat) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.js","names":[],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { relative } from 'node:path';\n\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport {
|
|
1
|
+
{"version":3,"file":"clean.js","names":[],"sources":["../../../src/rolldown-config/plugins/clean.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { relative } from 'node:path';\n\nimport { findConfigFile } from '@typescript/typescript6';\nimport { globSync } from 'glob';\nimport type { RolldownPluginOption } from 'rolldown';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR, WARNING_CODES } from '../constants';\nimport { cleanupJS, withoutExtension } from '../helpers';\nimport { readTsConfig } from './typescript.config';\n\nexport type EndPluginOptions = {\n ignoresJS?: string | string[];\n sourcemap?: boolean;\n dir?: string;\n};\n\nexport const clean = (options: EndPluginOptions) => {\n const { ignoresJS, sourcemap = false, dir } = options;\n\n const _ignoresJS = toArray(ignoresJS);\n\n const out = {\n name: 'end-bemedev',\n\n onLog: {\n handler: (_, { code, names }) => {\n const EMPTY_CHUNKS = _ignoresJS\n .map(f => globSync(f, { nodir: true }))\n .flat()\n .map(withoutExtension)\n .map(file => relative('src', file));\n\n const check =\n code === WARNING_CODES.EMPTY_BUNDLE &&\n names?.every(name => EMPTY_CHUNKS.includes(name));\n\n if (check) {\n const STARS = '*'.repeat(20);\n console.log(STARS);\n console.log('[end-bemedev] Skipping empty chunk warnings for:');\n names?.forEach(name => console.log(` -> 📄 ${name}`));\n console.log(STARS);\n return false;\n }\n\n return;\n },\n },\n\n closeBundle: {\n order: 'post',\n handler: () => {\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n const _outDir = readTsConfig(tsconfigPath).options.outDir;\n const outDir = _outDir ?? dir ?? DEFAULT_DIR;\n if (_ignoresJS.length > 0) {\n try {\n const files = new Set<string>();\n _ignoresJS.forEach(pat => {\n const globs = globSync(pat, { nodir: true });\n globs.forEach(file => files.add(file));\n });\n cleanupJS(files, outDir, sourcemap);\n console.log('Build finished');\n /* v8 ignore next 3 */\n } catch (err) {\n console.error('[end-bemedev] cleanup failed:', err);\n }\n }\n },\n },\n } satisfies RolldownPluginOption;\n\n return out;\n};\n"],"mappings":";;;;;;;;;AAmBA,MAAa,SAAS,YAA8B;CAClD,MAAM,EAAE,WAAW,YAAY,OAAO,QAAQ;CAE9C,MAAM,aAAa,QAAQ,SAAS;CA4DpC,OAAO;EAzDL,MAAM;EAEN,OAAO,EACL,UAAU,GAAG,EAAE,MAAM,YAAY;GAC/B,MAAM,eAAe,WAClB,KAAI,MAAK,SAAS,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CACtC,KAAK,CAAC,CACN,IAAI,gBAAgB,CAAC,CACrB,KAAI,SAAQ,SAAS,OAAO,IAAI,CAAC;GAMpC,IAHE,SAAS,cAAc,gBACvB,OAAO,OAAM,SAAQ,aAAa,SAAS,IAAI,CAAC,GAEvC;IACT,MAAM,QAAQ,IAAI,OAAO,EAAE;IAC3B,QAAQ,IAAI,KAAK;IACjB,QAAQ,IAAI,kDAAkD;IAC9D,OAAO,SAAQ,SAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;IACrD,QAAQ,IAAI,KAAK;IACjB,OAAO;GACT;EAGF,EACF;EAEA,aAAa;GACX,OAAO;GACP,eAAe;IASb,MAAM,SADU,aALK,eAFT,QAAQ,IAGhB,GACF,YACA,eAEsC,CAAC,CAAC,CAAC,QAAQ,UACzB,OAAA;IAC1B,IAAI,WAAW,SAAS,GACtB,IAAI;KACF,MAAM,wBAAQ,IAAI,IAAY;KAC9B,WAAW,SAAQ,QAAO;MAExB,SADuB,KAAK,EAAE,OAAO,KAAK,CACtC,CAAC,CAAC,SAAQ,SAAQ,MAAM,IAAI,IAAI,CAAC;KACvC,CAAC;KACD,UAAU,OAAO,QAAQ,SAAS;KAClC,QAAQ,IAAI,gBAAgB;IAE9B,SAAS,KAAK;KACZ,QAAQ,MAAM,iCAAiC,GAAG;IACpD;GAEJ;EACF;CAGO;AACX"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { RolldownPluginOption } from
|
|
2
|
-
import { nodeExternals } from
|
|
1
|
+
import type { RolldownPluginOption } from 'rolldown';
|
|
2
|
+
import { nodeExternals } from 'rollup-plugin-node-externals';
|
|
3
3
|
export type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];
|
|
4
4
|
/**
|
|
5
|
-
* Creates a configured node externals plugin instance
|
|
6
|
-
*
|
|
7
|
-
* @param options - Configuration options for node externals
|
|
8
|
-
* @returns Rolldown plugin
|
|
9
|
-
*/
|
|
5
|
+
* Creates a configured node externals plugin instance
|
|
6
|
+
*
|
|
7
|
+
* @param options - Configuration options for node externals
|
|
8
|
+
* @returns Rolldown plugin
|
|
9
|
+
*/
|
|
10
10
|
export declare function externals(options?: NodeExternalsOptions): RolldownPluginOption;
|
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { circulars } from './circulars';
|
|
2
|
+
import { externals } from './externals';
|
|
3
|
+
export declare const PLUGIN_BUILDERS: {
|
|
4
|
+
typescript: ({ exclude, include, declarationMap, dir, }?: {
|
|
5
|
+
exclude?: string | string[];
|
|
6
|
+
include?: Record<string, string>;
|
|
7
|
+
declarationMap?: boolean;
|
|
8
|
+
dir?: string;
|
|
9
|
+
}) => import("rolldown").RolldownPluginOption;
|
|
10
|
+
circulars: typeof circulars;
|
|
11
|
+
externals: typeof externals;
|
|
12
|
+
clean: (options: import("./clean").EndPluginOptions) => {
|
|
13
|
+
name: string;
|
|
14
|
+
onLog: {
|
|
15
|
+
handler: (this: import("rolldown").MinimalPluginContext, _: import("rolldown").LogLevel, { code, names }: import("rolldown").RolldownLog) => false | undefined;
|
|
16
|
+
};
|
|
17
|
+
closeBundle: {
|
|
18
|
+
order: "post";
|
|
19
|
+
handler: () => void;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const DEFAULT_PLUGINS_ORDER: string[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
3
|
const require_utils_array = require("../../utils/array.cjs");
|
|
3
4
|
require("../constants.cjs");
|
|
4
5
|
const require_rolldown_config_plugins_typescript_config = require("./typescript.config.cjs");
|
|
5
6
|
let fs = require("fs");
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
let oxc_transform = require("oxc-transform");
|
|
7
|
+
let _typescript_typescript6 = require("@typescript/typescript6");
|
|
8
|
+
_typescript_typescript6 = require_runtime.__toESM(_typescript_typescript6, 1);
|
|
9
9
|
let tsc_alias = require("tsc-alias");
|
|
10
10
|
//#region src/rolldown-config/plugins/typescript.ts
|
|
11
11
|
const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
@@ -21,46 +21,34 @@ const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
|
21
21
|
async handler() {
|
|
22
22
|
if (done) return;
|
|
23
23
|
const cwd = process.cwd();
|
|
24
|
-
const tsconfigPath =
|
|
24
|
+
const tsconfigPath = _typescript_typescript6.default.findConfigFile(cwd, fs.existsSync, "tsconfig.json");
|
|
25
25
|
const configFile = require_rolldown_config_plugins_typescript_config.readTsConfig(tsconfigPath);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const relativePath = (0, path.relative)(rootDir, file);
|
|
40
|
-
let dtsName = relativePath;
|
|
41
|
-
if (relativePath.endsWith(".tsx")) dtsName = relativePath.slice(0, -4) + ".d.ts";
|
|
42
|
-
else if (relativePath.endsWith(".ts")) dtsName = relativePath.slice(0, -3) + ".d.ts";
|
|
43
|
-
else if (relativePath.endsWith(".cts")) dtsName = relativePath.slice(0, -4) + ".d.cts";
|
|
44
|
-
else if (relativePath.endsWith(".mts")) dtsName = relativePath.slice(0, -4) + ".d.mts";
|
|
45
|
-
const outPath = (0, path.join)(outDir, dtsName);
|
|
46
|
-
const outMapPath = outPath + ".map";
|
|
47
|
-
(0, fs.mkdirSync)((0, path.dirname)(outPath), { recursive: true });
|
|
48
|
-
let dtsCode = result.declaration ?? "";
|
|
49
|
-
if (declarationMap && result.declarationMap) {
|
|
50
|
-
dtsCode += `\n//# sourceMappingURL=${(0, path.basename)(dtsName)}.map\n`;
|
|
51
|
-
(0, fs.writeFileSync)(outMapPath, JSON.stringify(result.declarationMap), "utf-8");
|
|
26
|
+
const host = _typescript_typescript6.default.createCompilerHost(configFile.options);
|
|
27
|
+
const outDir = configFile.options.outDir ?? dir ?? "lib";
|
|
28
|
+
const parsed = _typescript_typescript6.default.parseJsonConfigFileContent({
|
|
29
|
+
...configFile,
|
|
30
|
+
include,
|
|
31
|
+
exclude: [...require_utils_array.toArray(exclude), "*.ts"],
|
|
32
|
+
compilerOptions: {
|
|
33
|
+
...configFile.options,
|
|
34
|
+
outDir,
|
|
35
|
+
noEmit: false,
|
|
36
|
+
emitDeclarationOnly: true,
|
|
37
|
+
declaration: true,
|
|
38
|
+
declarationMap
|
|
52
39
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
40
|
+
}, _typescript_typescript6.default.sys, cwd);
|
|
41
|
+
const program = _typescript_typescript6.default.createProgram(parsed.fileNames, {
|
|
42
|
+
...configFile.options,
|
|
43
|
+
outDir,
|
|
44
|
+
noEmit: false,
|
|
45
|
+
emitDeclarationOnly: true,
|
|
46
|
+
declaration: true,
|
|
47
|
+
declarationMap
|
|
48
|
+
}, host);
|
|
49
|
+
const emitResult = program.emit();
|
|
50
|
+
const errors = _typescript_typescript6.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics).filter((d) => d.category === _typescript_typescript6.default.DiagnosticCategory.Error);
|
|
51
|
+
if (errors.length > 0) console.error(_typescript_typescript6.default.formatDiagnosticsWithColorAndContext(errors, host));
|
|
64
52
|
await (0, tsc_alias.replaceTscAliasPaths)({
|
|
65
53
|
configFile: tsconfigPath,
|
|
66
54
|
outDir
|