feat: this.emitFile support prebuilt-chunk type#4990
feat: this.emitFile support prebuilt-chunk type#4990lukastaegert merged 10 commits intorollup:masterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #4990 +/- ##
=======================================
Coverage 98.97% 98.97%
=======================================
Files 222 222
Lines 8157 8175 +18
Branches 2243 2250 +7
=======================================
+ Hits 8073 8091 +18
Misses 30 30
Partials 54 54
|
lukastaegert
left a comment
There was a problem hiding this comment.
Looks good! However, we need some more tests, and then we need to update the documentation.
1c8bb9f to
d2d53c1
Compare
|
Thanks for your review! I'll update the documentation tomorrow. |
8d361d8 to
683803c
Compare
3c1265d to
e1803cf
Compare
|
docs has been updated. |
lukastaegert
left a comment
There was a problem hiding this comment.
Nice! I slightly changed the wording of the docs, but overall I will release this now.
|
This PR has been released as part of [email protected]. You can test it via |
Implements `emitFile({ type: 'prebuilt-chunk', ... })` for Rollup API
compatibility, allowing plugins to emit pre-built chunks directly to the
bundle output. See
https://rollupjs.org/plugin-development/#this-emitfile and
rollup/rollup#4990
### Changes
**TypeScript**
- Added `EmittedPrebuiltChunk` interface with `fileName`, `code`,
`exports?`, `map?`, `sourcemapFileName?`
- Updated `emitFile` in plugin context to handle prebuilt-chunk type
- Exported `EmittedPrebuiltChunk` from package index
**Rust**
- Added `EmittedPrebuiltChunk` struct and `prebuilt_chunks` storage in
`FileEmitter`
- Implemented `emit_prebuilt_chunk` method
- Updated `get_file_name` and `add_additional_files` to support prebuilt
chunks
**Bindings**
- Added `BindingEmittedPrebuiltChunk` NAPI struct
- Added `emit_prebuilt_chunk` to `BindingPluginContext`
### Usage
```typescript
const plugin = {
name: 'emit-prebuilt',
buildStart() {
const refId = this.emitFile({
type: 'prebuilt-chunk',
fileName: 'vendor.js',
code: 'console.log("prebuilt");',
exports: ['default'],
});
// this.getFileName(refId) => 'vendor.js'
},
};
```
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>[Feature Request]: Support emit prebuilt
chunk</issue_title>
> <issue_description>
> [\[Feature Request\]: Support emit prebuilt chunk · Issue
#4034 ·
rolldown/rolldown](https://github.com/rolldown/rolldown/issues/4034)</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> <comment_new><author>@Boshen</author><body>
> Plugin-legacy does not strictly require this, we have a draft PR
https://github.com/vitejs/rolldown-vite/pull/80</body></comment_new>
> </comments>
>
</details>
- Fixes #4034
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
Co-authored-by: shulaoda <[email protected]>
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
resolves #4210
Description
This PR implements a basic feature about emitting prebuilt chunks, outlined in #4210 (comment)