diff --git a/docs/guide/migration.md b/docs/guide/migration.md index 9a0a28564484a7..e61d6412cc7c63 100644 --- a/docs/guide/migration.md +++ b/docs/guide/migration.md @@ -342,7 +342,6 @@ The following options are deprecated and will be removed in the future: These breaking changes are expected to only affect a minority of use cases: - **[TODO: this will be fixed before stable release]** https://github.com/rolldown/rolldown/issues/5726 (affects nuxt, qwik) -- **[TODO: this will be fixed before stable release]** Legacy chunks are emitted as an asset file instead of a chunk file due to the lack of prebuilt chunk emit feature ([rolldown#4304](https://github.com/rolldown/rolldown/issues/4034)). This means the chunk related options does not apply to legacy chunks and the manifest file will not include legacy chunks as a chunk file. - **[TODO: this will be fixed before stable release]** `@vite-ignore` comment edge case ([rolldown-vite#426](https://github.com/vitejs/rolldown-vite/issues/426)) - [Extglobs](https://github.com/micromatch/picomatch/blob/master/README.md#extglobs) are not supported yet ([rolldown-vite#365](https://github.com/vitejs/rolldown-vite/issues/365)) - `define` does not share reference for objects: When you pass an object as a value to `define`, each variable will have a separate copy of the object. See [Oxc Transformer document](https://oxc.rs/docs/guide/usage/transformer/global-variable-replacement#define) for more details. diff --git a/packages/plugin-legacy/src/index.ts b/packages/plugin-legacy/src/index.ts index 3555d6448cf888..e7919ea82a651f 100644 --- a/packages/plugin-legacy/src/index.ts +++ b/packages/plugin-legacy/src/index.ts @@ -900,9 +900,16 @@ async function buildPolyfillChunk( // add the chunk to the bundle ctx.emitFile({ - type: 'asset', + type: 'prebuilt-chunk', + name: polyfillChunk.name, fileName: polyfillChunk.fileName, - source: polyfillChunk.code, + code: polyfillChunk.code, + facadeModuleId: polyfillChunk.facadeModuleId ?? undefined, + isEntry: polyfillChunk.isEntry, + isDynamicEntry: polyfillChunk.isDynamicEntry, + exports: [], + map: polyfillChunk.map ?? undefined, + sourcemapFileName: polyfillChunk.sourcemapFileName ?? undefined, }) if (polyfillChunk.sourcemapFileName) { const polyfillChunkMapAsset = _polyfillChunk.output.find( diff --git a/playground/legacy/__tests__/legacy.spec.ts b/playground/legacy/__tests__/legacy.spec.ts index 39135c89094f66..a1adb0eb3a2030 100644 --- a/playground/legacy/__tests__/legacy.spec.ts +++ b/playground/legacy/__tests__/legacy.spec.ts @@ -86,11 +86,10 @@ describe.runIf(isBuild)('build', () => { test('should generate correct manifest', async () => { const manifest = readManifest() // legacy polyfill - // FIXME: needs https://github.com/rolldown/rolldown/issues/4034 - // expect(manifest['../../vite/legacy-polyfills-legacy']).toBeDefined() - // expect(manifest['../../vite/legacy-polyfills-legacy'].src).toBe( - // '../../vite/legacy-polyfills-legacy', - // ) + expect(manifest['../../vite/legacy-polyfills-legacy']).toBeDefined() + expect(manifest['../../vite/legacy-polyfills-legacy'].src).toBe( + '../../vite/legacy-polyfills-legacy', + ) expect(manifest['custom0-legacy.js'].file).toMatch( /chunk-X-legacy\.[-\w]{8}.js/, ) @@ -101,11 +100,10 @@ describe.runIf(isBuild)('build', () => { /chunk-X-legacy[-\w]{8}.js/, ) // modern polyfill - // FIXME: needs https://github.com/rolldown/rolldown/issues/4034 - // expect(manifest['../../vite/legacy-polyfills']).toBeDefined() - // expect(manifest['../../vite/legacy-polyfills'].src).toBe( - // '../../vite/legacy-polyfills', - // ) + expect(manifest['../../vite/legacy-polyfills']).toBeDefined() + expect(manifest['../../vite/legacy-polyfills'].src).toBe( + '../../vite/legacy-polyfills', + ) }) test('should minify legacy chunks with terser', async () => { diff --git a/playground/legacy/__tests__/watch/legacy-styles-only-entry-watch.spec.ts b/playground/legacy/__tests__/watch/legacy-styles-only-entry-watch.spec.ts index 528f85c57903b8..20a62b5855411f 100644 --- a/playground/legacy/__tests__/watch/legacy-styles-only-entry-watch.spec.ts +++ b/playground/legacy/__tests__/watch/legacy-styles-only-entry-watch.spec.ts @@ -17,7 +17,7 @@ test.runIf(isBuild)('rebuilds styles only entry on change', async () => { ) expect(findAssetFile(/polyfills-legacy-.+\.js/, 'watch')).toBeTruthy() const numberOfManifestEntries = Object.keys(readManifest('watch')).length - expect(numberOfManifestEntries).toBe(2) // FIXME: needs https://github.com/rolldown/rolldown/issues/4034 + expect(numberOfManifestEntries).toBe(3) editFile('style-only-entry.css', (originalContents) => originalContents.replace('#ff69b4', '#ffb6c1'),