rspack_plugin_javascript/plugin/
drive.rs1use rspack_core::{
2 AssetInfo, BoxModule, Chunk, ChunkCodeTemplate, ChunkInitFragments, ChunkUkey, Compilation,
3 Module, ModuleIdentifier, rspack_sources::BoxSource,
4};
5use rspack_hash::RspackHasher;
6use rspack_hook::define_hook;
7#[cfg(allocative)]
8use rspack_util::allocative;
9
10define_hook!(JavascriptModulesRenderChunk: Series(compilation: &Compilation, chunk_ukey: &ChunkUkey, source: &mut RenderSource, runtime_template: &ChunkCodeTemplate));
11define_hook!(JavascriptModulesRenderChunkContent: SeriesBail(compilation: &Compilation, chunk_ukey: &ChunkUkey, asset_info: &mut AssetInfo, runtime_template: &ChunkCodeTemplate) -> RenderSource);
12define_hook!(JavascriptModulesRender: Series(compilation: &Compilation, chunk_ukey: &ChunkUkey, source: &mut RenderSource, runtime_template: &ChunkCodeTemplate));
13define_hook!(JavascriptModulesRenderStartup: Series(compilation: &Compilation, chunk_ukey: &ChunkUkey, module: &ModuleIdentifier, source: &mut RenderSource, runtime_template: &ChunkCodeTemplate));
14define_hook!(JavascriptModulesRenderModuleContent: Series(compilation: &Compilation, chunk_ukey: &ChunkUkey,module: &dyn Module, source: &mut RenderSource, init_fragments: &mut ChunkInitFragments, runtime_template: &ChunkCodeTemplate),tracing=false);
15define_hook!(JavascriptModulesRenderModuleContainer: Series(compilation: &Compilation, chunk_ukey: &ChunkUkey,module: &dyn Module, source: &mut RenderSource, init_fragments: &mut ChunkInitFragments, runtime_template: &ChunkCodeTemplate),tracing=false);
16define_hook!(JavascriptModulesRenderModulePackage: Series(compilation: &Compilation, chunk_ukey: &ChunkUkey, module: &dyn Module, source: &mut RenderSource, init_fragments: &mut ChunkInitFragments, runtime_template: &ChunkCodeTemplate),tracing=false);
17define_hook!(JavascriptModulesChunkHash: Series(compilation: &Compilation, chunk_ukey: &ChunkUkey, hasher: &mut RspackHasher));
18define_hook!(JavascriptModulesInlineInRuntimeBailout: SeriesBail(compilation: &Compilation) -> String);
19define_hook!(JavascriptModulesEmbedInRuntimeBailout: SeriesBail(compilation: &Compilation, module: &BoxModule, chunk: &Chunk) -> String);
20define_hook!(JavascriptModulesStrictRuntimeBailout: SeriesBail(compilation: &Compilation, chunk_ukey: &ChunkUkey) -> String);
21
22#[derive(Debug, Default)]
23#[cfg_attr(allocative, derive(allocative::Allocative))]
24pub struct JavascriptModulesPluginHooks {
25 #[cfg_attr(allocative, allocative(skip))]
26 pub render_chunk: JavascriptModulesRenderChunkHook,
27 #[cfg_attr(allocative, allocative(skip))]
28 pub render_chunk_content: JavascriptModulesRenderChunkContentHook,
29 #[cfg_attr(allocative, allocative(skip))]
30 pub render: JavascriptModulesRenderHook,
31 #[cfg_attr(allocative, allocative(skip))]
32 pub render_startup: JavascriptModulesRenderStartupHook,
33 #[cfg_attr(allocative, allocative(skip))]
34 pub render_module_content: JavascriptModulesRenderModuleContentHook,
35 #[cfg_attr(allocative, allocative(skip))]
36 pub render_module_container: JavascriptModulesRenderModuleContainerHook,
37 #[cfg_attr(allocative, allocative(skip))]
38 pub render_module_package: JavascriptModulesRenderModulePackageHook,
39 #[cfg_attr(allocative, allocative(skip))]
40 pub chunk_hash: JavascriptModulesChunkHashHook,
41 #[cfg_attr(allocative, allocative(skip))]
42 pub inline_in_runtime_bailout: JavascriptModulesInlineInRuntimeBailoutHook,
43 #[cfg_attr(allocative, allocative(skip))]
44 pub embed_in_runtime_bailout: JavascriptModulesEmbedInRuntimeBailoutHook,
45 #[cfg_attr(allocative, allocative(skip))]
46 pub strict_runtime_bailout: JavascriptModulesStrictRuntimeBailoutHook,
47}
48
49#[derive(Debug)]
50pub struct RenderSource {
51 pub source: BoxSource,
52}