@atlassian/webresource-webpack-plugin
Version:
Auto-generates web-resource definitions from your webpacked code, for usage in an Atlassian product or plugin.
66 lines (65 loc) • 3.27 kB
TypeScript
import type { Chunk, Compilation, Compiler } from 'webpack';
import type { Entrypoint } from './types/extracted-webpack-types';
import type { ChunkResourceDescriptor, ConsolidatedOptions, DependencyMap, WrmResourceMap } from './types/types';
type SplitChunkDependenciesKeyMap = Map<Chunk, {
key: string;
dependency: string;
}>;
export type AppResourceParams = {
assetsUUID: string;
options: ConsolidatedOptions;
compiler: Compiler;
compilation: Compilation;
dependencyModuleMap: DependencyMap;
resourceModuleMap: WrmResourceMap;
resourceAssetsMap: DependencyMap;
};
export default class AppResources {
private readonly assetsUUID;
private readonly compiler;
private readonly compilation;
private readonly dependencyModuleMap;
private readonly resourceModuleMap;
private readonly resourceAssetsMap;
private options;
/**
* @param assetsUUID unique hash to identify the assets web-resource
* @param options WrmPlugin configuration
* @param compiler Webpack compiler
* @param compilation Webpack compilation
* @param dependencyModuleMap map of module identifier -> set of web-resource dependencies
* @param resourceModuleMap map of resource identifier -> set of web-resource external resources
* @param resourceAssetsMap map of resource identifier -> set of asset files referenced by that resource
*/
constructor({ assetsUUID, options, compiler, compilation, dependencyModuleMap, resourceModuleMap, resourceAssetsMap, }: AppResourceParams);
getSingleRuntimeFiles(): string[];
getAssetResourceDescriptor(): ChunkResourceDescriptor;
getWebresourceKeyForChunk(chunk: Chunk, transform: (id: string, name: string) => string): string;
/**
* Every entrypoint has an attribute called "chunks".
* This contains all chunks that are needed to successfully "load" this entrypoint.
* Usually every entrypoint only contains one chunk - the bundle that is build for that entrypoint.
* If more than one chunk is present that means they are split-chunks that contain code needed by the entrypoint to function.
* To get all split chunks we need to get all but the entrypoints "runtimeChunk" which is the chunk solely containing code for this entrypoint and its runtime.
*
* IMPORTANT-NOTE: async-chunks required by this entrypoint are not specified in these chunks but in the childGroups of the entry and/or split chunks.
*/
getSyncSplitChunks(): Chunk[];
/**
* Create a key and the fully-qualified web-resource descriptor for every split chunk.
* This is needed to point to reference these chunks as dependency in the entrypoint chunks
*
* <web-resource>
* ...
* <dependency>this-plugin-key:split_some_chunk</dependency>
* ...
* </web-resource>
*/
getSyncSplitChunkDependenciesKeyMap(syncSplitChunks: Chunk[]): SplitChunkDependenciesKeyMap;
getSyncSplitChunksResourceDescriptors(): ChunkResourceDescriptor[];
getAsyncChunksResourceDescriptors(): ChunkResourceDescriptor[];
getEntryPoints(): Entrypoint[];
getEntryPointsResourceDescriptors(): ChunkResourceDescriptor[];
getResourceDescriptors(): ChunkResourceDescriptor[];
}
export {};