From 0c5aa76cb0e30a66ce7c7972f484c003a5b7b8c1 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Wed, 1 Feb 2023 09:50:29 +0100 Subject: [PATCH] Add warning not to add assets directly to the bundle (#4831) --- docs/plugin-development/index.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/plugin-development/index.md b/docs/plugin-development/index.md index 1846c498bfa..a892ecb0c3e 100644 --- a/docs/plugin-development/index.md +++ b/docs/plugin-development/index.md @@ -712,6 +712,14 @@ type ChunkInfo = { You can prevent files from being emitted by deleting them from the bundle object in this hook. To emit additional files, use the [`this.emitFile`](#this-emitfile) plugin context function. +::: danger + +Do not directly add assets to the bundle. This circumvents internal mechanisms that Rollup has for tracking assets. It can also cause your asset to miss vital properties that Rollup relies on internally and your plugin can break with minor Rollup releases. + +Instead, always use [`this.emitFile`](#this-emitfile). + +::: + ### `intro` **Type:** `string | ((chunk: ChunkInfo) => string)`
**Kind:** `async, sequential`
**Previous Hook:** [`resolveFileUrl`](#resolvefileurl) for each use of `import.meta.ROLLUP_FILE_URL_referenceId` and [`resolveImportMeta`](#resolveimportmeta) for all other accesses to `import.meta` in the current chunk.
**Next Hook:** [`renderDynamicImport`](#renderdynamicimport) for each dynamic import expression in the next chunk if there is another one, otherwise [`renderChunk`](#renderchunk) for the first chunk.