@rsaf/bundler 0.0.5 → 0.0.6
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/bundler/config.d.ts +3 -3
- package/dist/bundler/create-plugin.d.ts +8 -8
- package/dist/bundler/create-plugin.js +7 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/config.d.ts +4 -0
- package/dist/types/esbuild.d.ts +1 -0
- package/dist/types/esbuild.js +1 -0
- package/package.json +1 -1
package/dist/bundler/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ESBuildClientDevConfig, ESBuildClientProdConfig, ESBuildServerDevConfig, ESBuildServerProdConfig } from '../types/config.js';
|
|
1
|
+
import type { BuildEnv, ESBuildClientDevConfig, ESBuildClientProdConfig, ESBuildServerDevConfig, ESBuildServerProdConfig } from '../types/config.js';
|
|
2
2
|
/**
|
|
3
3
|
* Generates an esbuild configuration specifically for the Client (browser) environment.
|
|
4
4
|
* * @remarks
|
|
@@ -13,7 +13,7 @@ import type { ESBuildClientDevConfig, ESBuildClientProdConfig, ESBuildServerDevC
|
|
|
13
13
|
* @param options.entryPoints - File paths or a mapping for the entry points to be bundled.
|
|
14
14
|
* * @returns A configuration object typed for either {@link ESBuildClientDevConfig} or {@link ESBuildClientProdConfig}.
|
|
15
15
|
*/
|
|
16
|
-
export declare function createClientConfig(env:
|
|
16
|
+
export declare function createClientConfig(env: BuildEnv, options: {
|
|
17
17
|
absWorkingDir: string;
|
|
18
18
|
entryPoints: string[] | Record<string, string>;
|
|
19
19
|
}): ESBuildClientDevConfig | ESBuildClientProdConfig;
|
|
@@ -32,7 +32,7 @@ export declare function createClientConfig(env: 'dev' | 'prod', options: {
|
|
|
32
32
|
* @param options.entryPoints - File paths or a mapping for the entry points (e.g., the SSR entry).
|
|
33
33
|
* * @returns A configuration object typed for either {@link ESBuildServerDevConfig} or {@link ESBuildServerProdConfig}.
|
|
34
34
|
*/
|
|
35
|
-
export declare function createServerConfig(env:
|
|
35
|
+
export declare function createServerConfig(env: BuildEnv, options: {
|
|
36
36
|
absWorkingDir: string;
|
|
37
37
|
entryPoints: string[] | Record<string, string>;
|
|
38
38
|
}): ESBuildServerDevConfig | ESBuildServerProdConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuildResult, OnLoadArgs, OnLoadOptions, OnResolveArgs, OnResolveOptions, Plugin, OnLoadResult, OnResolveResult
|
|
1
|
+
import type { BuildResult, OnLoadArgs, OnLoadOptions, OnResolveArgs, OnResolveOptions, Plugin, OnLoadResult, OnResolveResult } from 'esbuild';
|
|
2
2
|
/**
|
|
3
3
|
* Defines the execution logic for various stages of the esbuild bundling process.
|
|
4
4
|
* * This interface provides a structured, declarative way to tap into the
|
|
@@ -11,22 +11,22 @@ interface PluginLifecycleHooks {
|
|
|
11
11
|
* Use this for setup logic, initializing build-specific state, or clear/prepare output directories.
|
|
12
12
|
* If this function returns a `Promise`, esbuild will wait for it to resolve before starting the build.
|
|
13
13
|
*/
|
|
14
|
-
onStart?: (
|
|
14
|
+
onStart?: () => void | Promise<void>;
|
|
15
15
|
/**
|
|
16
16
|
* Invoked at the end of every build or rebuild.
|
|
17
|
-
*
|
|
17
|
+
* @param result - The outcome of the build, including errors, warnings, and the metafile (if enabled).
|
|
18
18
|
* @remarks
|
|
19
19
|
* Ideal for post-processing tasks, such as generating manifest files,
|
|
20
20
|
* triggering notifications, or cleaning up temporary files.
|
|
21
21
|
*/
|
|
22
|
-
onEnd?: (
|
|
22
|
+
onEnd?: (result: BuildResult) => void | Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* Invoked when the plugin is disposed of, usually when the {@link Bundler.dispose} is called.
|
|
25
|
-
*
|
|
25
|
+
* @remarks
|
|
26
26
|
* Use this to close file watchers, database connections, or long-lived child processes
|
|
27
27
|
* created within the plugin.
|
|
28
28
|
*/
|
|
29
|
-
onDispose?: (
|
|
29
|
+
onDispose?: () => void;
|
|
30
30
|
/**
|
|
31
31
|
* Intercepts the loading of files that match specific criteria.
|
|
32
32
|
*/
|
|
@@ -76,10 +76,10 @@ interface PluginLifecycleHooks {
|
|
|
76
76
|
* }
|
|
77
77
|
* });
|
|
78
78
|
* ```
|
|
79
|
-
*
|
|
79
|
+
* @param pluginName - A unique name for the plugin (used for error reporting and debugging).
|
|
80
80
|
* @param lifecycleHooks - An object containing the hooks to be registered.
|
|
81
81
|
* @returns A standard esbuild {@link Plugin} object.
|
|
82
|
-
*
|
|
82
|
+
* @throws {TypeError} If `pluginName` is empty or not a string.
|
|
83
83
|
*/
|
|
84
84
|
export declare function createDeclarativePlugin(pluginName: string, lifecycleHooks: PluginLifecycleHooks): Plugin;
|
|
85
85
|
export {};
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
* }
|
|
25
25
|
* });
|
|
26
26
|
* ```
|
|
27
|
-
*
|
|
27
|
+
* @param pluginName - A unique name for the plugin (used for error reporting and debugging).
|
|
28
28
|
* @param lifecycleHooks - An object containing the hooks to be registered.
|
|
29
29
|
* @returns A standard esbuild {@link Plugin} object.
|
|
30
|
-
*
|
|
30
|
+
* @throws {TypeError} If `pluginName` is empty or not a string.
|
|
31
31
|
*/
|
|
32
32
|
export function createDeclarativePlugin(pluginName, lifecycleHooks) {
|
|
33
33
|
if (typeof pluginName !== 'string' || pluginName.trim().length === 0) {
|
|
@@ -37,21 +37,19 @@ export function createDeclarativePlugin(pluginName, lifecycleHooks) {
|
|
|
37
37
|
name: pluginName,
|
|
38
38
|
setup(build) {
|
|
39
39
|
if (lifecycleHooks.onStart) {
|
|
40
|
-
build.onStart(lifecycleHooks.onStart
|
|
40
|
+
build.onStart(lifecycleHooks.onStart);
|
|
41
41
|
}
|
|
42
42
|
if (lifecycleHooks.onEnd) {
|
|
43
|
-
build.onEnd(lifecycleHooks.onEnd
|
|
43
|
+
build.onEnd(lifecycleHooks.onEnd);
|
|
44
44
|
}
|
|
45
45
|
if (lifecycleHooks.onDispose) {
|
|
46
|
-
build.onDispose(lifecycleHooks.onDispose
|
|
46
|
+
build.onDispose(lifecycleHooks.onDispose);
|
|
47
47
|
}
|
|
48
48
|
if (lifecycleHooks.onLoad) {
|
|
49
|
-
|
|
50
|
-
build.onLoad(options, callback);
|
|
49
|
+
build.onLoad(lifecycleHooks.onLoad.options, lifecycleHooks.onLoad.callback);
|
|
51
50
|
}
|
|
52
51
|
if (lifecycleHooks.onResolve) {
|
|
53
|
-
|
|
54
|
-
build.onResolve(options, callback);
|
|
52
|
+
build.onResolve(lifecycleHooks.onResolve.options, lifecycleHooks.onResolve.callback);
|
|
55
53
|
}
|
|
56
54
|
},
|
|
57
55
|
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/types/config.d.ts
CHANGED
|
@@ -118,3 +118,7 @@ export type ESBuildConfig = ESBuildClientDevConfig | ESBuildClientProdConfig | E
|
|
|
118
118
|
* Type alias for a map of file extensions to esbuild Loaders.
|
|
119
119
|
*/
|
|
120
120
|
export type Loaders = Record<string, Loader>;
|
|
121
|
+
/**
|
|
122
|
+
* Build Enviroment
|
|
123
|
+
*/
|
|
124
|
+
export type BuildEnv = 'dev' | 'prod';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type Metafile, type OutputFile, type Plugin, type PluginBuild, type BuildResult, type Loader, } from 'esbuild';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {} from 'esbuild';
|