rolldown-require 1.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/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/chunk-Q6XJHTDB.cjs +15 -0
- package/dist/chunk-WUKYLWAZ.mjs +0 -0
- package/dist/false-G5OFYI37.mjs +7 -0
- package/dist/false-SI6OY5LO.cjs +9 -0
- package/dist/index.cjs +1151 -0
- package/dist/index.d.cts +77 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.mjs +1148 -0
- package/misc/false.d.ts +2 -0
- package/misc/false.js +1 -0
- package/misc/true.d.ts +2 -0
- package/misc/true.js +1 -0
- package/package.json +63 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { InputOptions, ExternalOption } from 'rolldown';
|
|
2
|
+
|
|
3
|
+
type RequireFunction = (outfile: string, ctx: {
|
|
4
|
+
format: 'cjs' | 'esm';
|
|
5
|
+
}) => any;
|
|
6
|
+
type GetOutputFile = (filepath: string, format: 'esm' | 'cjs') => string;
|
|
7
|
+
interface Options {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The filepath to bundle and require
|
|
11
|
+
*/
|
|
12
|
+
filepath: string;
|
|
13
|
+
/**
|
|
14
|
+
* The `require` function that is used to load the output file
|
|
15
|
+
* Default to the global `require` function
|
|
16
|
+
* This function can be asynchronous, i.e. returns a Promise
|
|
17
|
+
*/
|
|
18
|
+
require?: RequireFunction;
|
|
19
|
+
/**
|
|
20
|
+
* esbuild options
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
rolldownOptions?: InputOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Get the path to the output file
|
|
26
|
+
* By default we simply replace the extension with `.bundled_{randomId}.js`
|
|
27
|
+
*/
|
|
28
|
+
getOutputFile?: GetOutputFile;
|
|
29
|
+
/**
|
|
30
|
+
* Enable watching and call the callback after each rebuild
|
|
31
|
+
*/
|
|
32
|
+
/** External packages */
|
|
33
|
+
external?: ExternalOption;
|
|
34
|
+
/** Not external packages */
|
|
35
|
+
/**
|
|
36
|
+
* Automatically mark node_modules as external
|
|
37
|
+
* @default true - `false` when `filepath` is in node_modules
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* A custom tsconfig path to read `paths` option
|
|
41
|
+
*
|
|
42
|
+
* Set to `false` to disable tsconfig
|
|
43
|
+
*/
|
|
44
|
+
tsconfig?: string | false;
|
|
45
|
+
/**
|
|
46
|
+
* Preserve compiled temporary file for debugging
|
|
47
|
+
* Default to `process.env.BUNDLE_REQUIRE_PRESERVE`
|
|
48
|
+
*/
|
|
49
|
+
preserveTemporaryFile?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Provide bundle format explicitly
|
|
52
|
+
* to skip the default format inference
|
|
53
|
+
*/
|
|
54
|
+
format?: 'cjs' | 'esm';
|
|
55
|
+
}
|
|
56
|
+
interface InternalOptions extends Omit<Options, 'cwd' | 'filepath'> {
|
|
57
|
+
isESM: boolean;
|
|
58
|
+
format: 'cjs' | 'esm';
|
|
59
|
+
tsconfig?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare const configDefaults: Readonly<{
|
|
63
|
+
resolve: {
|
|
64
|
+
extensions: string[];
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
declare function bundleFile(fileName: string, options: InternalOptions): Promise<{
|
|
68
|
+
code: string;
|
|
69
|
+
dependencies: string[];
|
|
70
|
+
}>;
|
|
71
|
+
declare function loadFromBundledFile(fileName: string, bundledCode: string, options: InternalOptions): Promise<any>;
|
|
72
|
+
declare function bundleRequire<T = any>(options: Options): Promise<{
|
|
73
|
+
mod: T;
|
|
74
|
+
dependencies: string[];
|
|
75
|
+
}>;
|
|
76
|
+
|
|
77
|
+
export { bundleFile, bundleRequire, configDefaults, loadFromBundledFile };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { InputOptions, ExternalOption } from 'rolldown';
|
|
2
|
+
|
|
3
|
+
type RequireFunction = (outfile: string, ctx: {
|
|
4
|
+
format: 'cjs' | 'esm';
|
|
5
|
+
}) => any;
|
|
6
|
+
type GetOutputFile = (filepath: string, format: 'esm' | 'cjs') => string;
|
|
7
|
+
interface Options {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The filepath to bundle and require
|
|
11
|
+
*/
|
|
12
|
+
filepath: string;
|
|
13
|
+
/**
|
|
14
|
+
* The `require` function that is used to load the output file
|
|
15
|
+
* Default to the global `require` function
|
|
16
|
+
* This function can be asynchronous, i.e. returns a Promise
|
|
17
|
+
*/
|
|
18
|
+
require?: RequireFunction;
|
|
19
|
+
/**
|
|
20
|
+
* esbuild options
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
rolldownOptions?: InputOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Get the path to the output file
|
|
26
|
+
* By default we simply replace the extension with `.bundled_{randomId}.js`
|
|
27
|
+
*/
|
|
28
|
+
getOutputFile?: GetOutputFile;
|
|
29
|
+
/**
|
|
30
|
+
* Enable watching and call the callback after each rebuild
|
|
31
|
+
*/
|
|
32
|
+
/** External packages */
|
|
33
|
+
external?: ExternalOption;
|
|
34
|
+
/** Not external packages */
|
|
35
|
+
/**
|
|
36
|
+
* Automatically mark node_modules as external
|
|
37
|
+
* @default true - `false` when `filepath` is in node_modules
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* A custom tsconfig path to read `paths` option
|
|
41
|
+
*
|
|
42
|
+
* Set to `false` to disable tsconfig
|
|
43
|
+
*/
|
|
44
|
+
tsconfig?: string | false;
|
|
45
|
+
/**
|
|
46
|
+
* Preserve compiled temporary file for debugging
|
|
47
|
+
* Default to `process.env.BUNDLE_REQUIRE_PRESERVE`
|
|
48
|
+
*/
|
|
49
|
+
preserveTemporaryFile?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Provide bundle format explicitly
|
|
52
|
+
* to skip the default format inference
|
|
53
|
+
*/
|
|
54
|
+
format?: 'cjs' | 'esm';
|
|
55
|
+
}
|
|
56
|
+
interface InternalOptions extends Omit<Options, 'cwd' | 'filepath'> {
|
|
57
|
+
isESM: boolean;
|
|
58
|
+
format: 'cjs' | 'esm';
|
|
59
|
+
tsconfig?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare const configDefaults: Readonly<{
|
|
63
|
+
resolve: {
|
|
64
|
+
extensions: string[];
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
declare function bundleFile(fileName: string, options: InternalOptions): Promise<{
|
|
68
|
+
code: string;
|
|
69
|
+
dependencies: string[];
|
|
70
|
+
}>;
|
|
71
|
+
declare function loadFromBundledFile(fileName: string, bundledCode: string, options: InternalOptions): Promise<any>;
|
|
72
|
+
declare function bundleRequire<T = any>(options: Options): Promise<{
|
|
73
|
+
mod: T;
|
|
74
|
+
dependencies: string[];
|
|
75
|
+
}>;
|
|
76
|
+
|
|
77
|
+
export { bundleFile, bundleRequire, configDefaults, loadFromBundledFile };
|