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,20 @@ export function normalizeRollupOutputOptionsObject(
253251 */
254252 outputOpts . hoistTransitiveImports = false ;
255253
254+ if ( 'onlyExplicitManualChunks' in outputOpts ) {
255+ outputOpts . onlyExplicitManualChunks = true ;
256+ } else {
257+ console . warn (
258+ `⚠️ Outdated rollup version detected. For the latest and greatest, we recommend to update to rollup@^4.52.0. This can improve preloading performance and reduce cache invalidation for a snappier user experience.`
259+ ) ;
260+ }
261+
256262 return outputOpts ;
257263}
258264
259265export function createRollupError ( id : string , diagnostic : Diagnostic ) {
260266 const loc = diagnostic . highlights [ 0 ] ?? { } ;
261- const err : Rollup . RollupError = Object . assign ( new Error ( diagnostic . message ) , {
267+ const err : RollupError = Object . assign ( new Error ( diagnostic . message ) , {
262268 id,
263269 plugin : 'qwik' ,
264270 loc : {
@@ -352,5 +358,5 @@ export interface QwikRollupPluginOptions {
352358 experimental ?: ( keyof typeof ExperimentalFeatures ) [ ] ;
353359}
354360export { ExperimentalFeatures } from './plugin' ;
355- type P < T > = Rollup . Plugin < T > & { api : T } ;
361+ type P < T > = Plugin < T > & { api : T } ;
356362export interface QwikRollupPlugin extends P < QwikRollupPluginApi > { }
0 commit comments