rolldown-require 1.0.6 → 2.0.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/dist/index.d.cts DELETED
@@ -1,116 +0,0 @@
1
- import { InputOptions, OutputOptions, ExternalOption } from 'rolldown';
2
-
3
- type RequireFunction = (outfile: string, ctx: {
4
- format: 'cjs' | 'esm';
5
- }) => any;
6
- interface CacheEvent {
7
- type: 'hit' | 'miss' | 'store' | 'skip-invalid';
8
- key: string;
9
- reason?: string;
10
- }
11
- interface CacheOptions {
12
- /**
13
- * Enable persistent cache. Pass an object to configure.
14
- */
15
- enabled?: boolean;
16
- /**
17
- * Optional cache directory. Defaults to nearest `node_modules/.rolldown-require-cache`
18
- * or `os.tmpdir()/rolldown-require-cache`.
19
- */
20
- dir?: string;
21
- /**
22
- * Clear any existing cache entry before writing a new one.
23
- */
24
- reset?: boolean;
25
- /**
26
- * Also keep a process-local in-memory cache to skip filesystem hits.
27
- * Defaults to true when persistent cache is enabled.
28
- */
29
- memory?: boolean;
30
- /**
31
- * Receive cache events for debugging/metrics.
32
- */
33
- onEvent?: (event: CacheEvent) => void;
34
- }
35
- type GetOutputFile = (filepath: string, format: 'esm' | 'cjs') => string;
36
- interface Options {
37
- cwd?: string;
38
- /**
39
- * The filepath to bundle and require
40
- */
41
- filepath: string;
42
- /**
43
- * The `require` function that is used to load the output file
44
- * Default to the global `require` function
45
- * This function can be asynchronous, i.e. returns a Promise
46
- */
47
- require?: RequireFunction;
48
- /**
49
- * esbuild options
50
- *
51
- */
52
- rolldownOptions?: {
53
- input?: InputOptions;
54
- output?: OutputOptions;
55
- };
56
- /**
57
- * Get the path to the output file
58
- * By default we simply replace the extension with `.bundled_{randomId}.js`
59
- */
60
- getOutputFile?: GetOutputFile;
61
- /**
62
- * Enable watching and call the callback after each rebuild
63
- */
64
- /** External packages */
65
- external?: ExternalOption;
66
- /** Not external packages */
67
- /**
68
- * Automatically mark node_modules as external
69
- * @default true - `false` when `filepath` is in node_modules
70
- */
71
- /**
72
- * A custom tsconfig path to read `paths` option
73
- *
74
- * Set to `false` to disable tsconfig
75
- */
76
- tsconfig?: string | false;
77
- /**
78
- * Preserve compiled temporary file for debugging
79
- * Default to `process.env.BUNDLE_REQUIRE_PRESERVE`
80
- */
81
- preserveTemporaryFile?: boolean;
82
- /**
83
- * Provide bundle format explicitly
84
- * to skip the default format inference
85
- */
86
- format?: 'cjs' | 'esm';
87
- /**
88
- * Persistent cache for bundled output to speed up repeated loads.
89
- */
90
- cache?: boolean | CacheOptions;
91
- }
92
- interface InternalOptions extends Omit<Options, 'cwd' | 'filepath'> {
93
- isESM: boolean;
94
- format: 'cjs' | 'esm';
95
- tsconfig?: string;
96
- }
97
-
98
- declare const configDefaults: Readonly<{
99
- resolve: {
100
- extensions: string[];
101
- };
102
- }>;
103
-
104
- declare function bundleFile(fileName: string, options: InternalOptions): Promise<{
105
- code: string;
106
- dependencies: string[];
107
- }>;
108
-
109
- declare function loadFromBundledFile(fileName: string, bundledCode: string, options: InternalOptions, dependencies?: string[]): Promise<any>;
110
-
111
- declare function bundleRequire<T = any>(options: Options): Promise<{
112
- mod: T;
113
- dependencies: string[];
114
- }>;
115
-
116
- export { bundleFile, bundleRequire, configDefaults, loadFromBundledFile };