atlassian-webresource-webpack-plugin
Version:
Auto-generates web-resource definitions from your webpacked code, for usage in an Atlassian product or plugin.
60 lines (59 loc) • 2.75 kB
TypeScript
import type { Chunk, Compilation, Compiler } from 'webpack';
import type { Entrypoint } from './types/extracted-webpack-types';
import type { AssetNames, ChunkResourceDescriptor, ConsolidatedOptions } from './types/types';
declare type SplitChunkDependenciesKeyMap = Map<Chunk, {
key: string;
dependency: string;
}>;
export declare type AppResourceParams = {
assetsUUID: string;
assetNames: AssetNames;
options: ConsolidatedOptions;
compiler: Compiler;
compilation: Compilation;
};
export default class AppResources {
private readonly assetsUUID;
private readonly compiler;
private readonly compilation;
private assetNames;
private options;
/**
* @param assetsUUID unique hash to identify the assets web-resource
* @param assetNames full module filepaths -> relative filepath
* @param options WrmPlugin configuration
* @param compiler Webpack compiler
* @param compilation Webpack compilation
*/
constructor({ assetsUUID, assetNames, options, compiler, compilation }: AppResourceParams);
getSingleRuntimeFiles(): string[];
getAssetResourceDescriptor(): ChunkResourceDescriptor;
getDependencyResourcesFromChunk(chunk: Chunk): 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 {};