1- import type { Rollup } from 'vite' ;
2-
31import type {
42 Diagnostic ,
53 EntryStrategy ,
@@ -18,6 +16,7 @@ import {
1816 type QwikPlugin ,
1917 type QwikPluginOptions ,
2018} from './plugin' ;
19+ import type { OutputOptions , Plugin , PreRenderedChunk , RollupError } from 'rollup' ;
2120
2221type QwikRollupPluginApi = {
2322 getOptimizer : ( ) => Optimizer ;
@@ -129,10 +128,10 @@ export function qwikRollup(qwikRollupOpts: QwikRollupPluginOptions = {}): any {
129128
130129export function normalizeRollupOutputOptions (
131130 qwikPlugin : QwikPlugin ,
132- rollupOutputOpts : Rollup . OutputOptions | Rollup . OutputOptions [ ] | undefined ,
131+ rollupOutputOpts : OutputOptions | OutputOptions [ ] | undefined ,
133132 useAssetsDir : boolean ,
134133 outDir ?: string
135- ) : Rollup . OutputOptions | Rollup . OutputOptions [ ] {
134+ ) : OutputOptions | OutputOptions [ ] {
136135 if ( Array . isArray ( rollupOutputOpts ) ) {
137136 // make sure at least one output is present in every case
138137 if ( ! rollupOutputOpts . length ) {
@@ -153,10 +152,10 @@ export function normalizeRollupOutputOptions(
153152
154153export function normalizeRollupOutputOptionsObject (
155154 qwikPlugin : QwikPlugin ,
156- rollupOutputOptsObj : Rollup . OutputOptions | undefined ,
155+ rollupOutputOptsObj : OutputOptions | undefined ,
157156 useAssetsDir : boolean
158- ) : Rollup . OutputOptions {
159- const outputOpts : Rollup . OutputOptions = { ...rollupOutputOptsObj } ;
157+ ) : OutputOptions {
158+ const outputOpts : OutputOptions = { ...rollupOutputOptsObj } ;
160159 const opts = qwikPlugin . getOptions ( ) ;
161160 const optimizer = qwikPlugin . getOptimizer ( ) ;
162161 const manualChunks = qwikPlugin . manualChunks ;
@@ -170,7 +169,7 @@ export function normalizeRollupOutputOptionsObject(
170169 : assetFileNames ;
171170 }
172171
173- let fileName : string | ( ( chunkInfo : Rollup . PreRenderedChunk ) => string ) | undefined ;
172+ let fileName : string | ( ( chunkInfo : PreRenderedChunk ) => string ) | undefined ;
174173 if ( opts . buildMode === 'production' && ! opts . debug ) {
175174 fileName = 'build/q-[hash].js' ;
176175 } else {
@@ -199,15 +198,14 @@ export function normalizeRollupOutputOptionsObject(
199198 } ;
200199 }
201200 // client development/debug output
202- const getFilePath = ( fileNamePattern : string | ( ( info : Rollup . PreRenderedChunk ) => string ) ) =>
201+ const getFilePath = ( fileNamePattern : string | ( ( info : PreRenderedChunk ) => string ) ) =>
203202 typeof fileNamePattern === 'string'
204203 ? useAssetsDir
205204 ? `${ opts . assetsDir } /${ fileNamePattern } `
206205 : fileNamePattern
207206 : useAssetsDir
208- ? ( chunkInfo : Rollup . PreRenderedChunk ) =>
209- `${ opts . assetsDir } /${ fileNamePattern ( chunkInfo ) } `
210- : ( chunkInfo : Rollup . PreRenderedChunk ) => fileNamePattern ( chunkInfo ) ;
207+ ? ( chunkInfo : PreRenderedChunk ) => `${ opts . assetsDir } /${ fileNamePattern ( chunkInfo ) } `
208+ : ( chunkInfo : PreRenderedChunk ) => fileNamePattern ( chunkInfo ) ;
211209
212210 if ( ! outputOpts . entryFileNames ) {
213211 outputOpts . entryFileNames = getFilePath ( fileName ) ;
@@ -253,12 +251,17 @@ export function normalizeRollupOutputOptionsObject(
253251 */
254252 outputOpts . hoistTransitiveImports = false ;
255253
254+ outputOpts . onlyExplicitManualChunks = true ;
255+ console . warn (
256+ `⚠️ For the latest and greatest, we recommend to install rollup@^4.52.0 directly in your project. It enables the new Rollup \`outputOpts.onlyExplicitManualChunks\` feature flag, which improves preloading performance and reduces cache invalidation for a snappier user experience.`
257+ ) ;
258+
256259 return outputOpts ;
257260}
258261
259262export function createRollupError ( id : string , diagnostic : Diagnostic ) {
260263 const loc = diagnostic . highlights [ 0 ] ?? { } ;
261- const err : Rollup . RollupError = Object . assign ( new Error ( diagnostic . message ) , {
264+ const err : RollupError = Object . assign ( new Error ( diagnostic . message ) , {
262265 id,
263266 plugin : 'qwik' ,
264267 loc : {
@@ -352,5 +355,5 @@ export interface QwikRollupPluginOptions {
352355 experimental ?: ( keyof typeof ExperimentalFeatures ) [ ] ;
353356}
354357export { ExperimentalFeatures } from './plugin' ;
355- type P < T > = Rollup . Plugin < T > & { api : T } ;
358+ type P < T > = Plugin < T > & { api : T } ;
356359export interface QwikRollupPlugin extends P < QwikRollupPluginApi > { }
0 commit comments