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