@@ -3,19 +3,14 @@ import debugUtil from "debug";
33
44const debug = debugUtil ( "Eleventy:Bundle" ) ;
55
6- function eleventyBundleShortcodes ( eleventyConfig , pluginOptions = { } ) {
6+ export default function ( eleventyConfig , pluginOptions = { } ) {
77 let managers = eleventyConfig . getBundleManagers ( ) ;
88 let writeToFileSystem = true ;
9- let pagesUsingBundles = { } ;
109
1110 function bundleTransform ( content , stage = 0 ) {
12- if ( typeof content !== "string" ) {
13- return content ;
14- }
15-
11+ // Only run if content is string
1612 // Only run if managers are in play
17- // Only run on pages that have fetched bundles via `getBundle` or `getBundleFileUrl`
18- if ( Object . keys ( managers ) . length === 0 || this . page . url && ! pagesUsingBundles [ this . page . url ] ) {
13+ if ( typeof content !== "string" || Object . keys ( managers ) . length === 0 ) {
1914 return content ;
2015 }
2116
@@ -36,8 +31,6 @@ function eleventyBundleShortcodes(eleventyConfig, pluginOptions = {}) {
3631 return ;
3732 }
3833
39- pagesUsingBundles = { } ;
40-
4134 if ( outputMode !== "fs" ) {
4235 writeToFileSystem = false ;
4336 debug ( "Skipping writing to the file system due to output mode: %o" , outputMode ) ;
@@ -52,11 +45,6 @@ function eleventyBundleShortcodes(eleventyConfig, pluginOptions = {}) {
5245 throw new Error ( `Invalid bundle type: ${ type } . Available options: ${ Object . keys ( managers ) } ` ) ;
5346 }
5447
55- let url = explicitUrl || this . page ?. url ;
56- if ( url ) {
57- pagesUsingBundles [ url ] = true ;
58- }
59-
6048 return OutOfOrderRender . getAssetKey ( "get" , type , bucket ) ;
6149 } ) ;
6250
@@ -67,11 +55,6 @@ function eleventyBundleShortcodes(eleventyConfig, pluginOptions = {}) {
6755 throw new Error ( `Invalid bundle type: ${ type } . Available options: ${ Object . keys ( managers ) } ` ) ;
6856 }
6957
70- let url = explicitUrl || this . page ?. url ;
71- if ( url ) {
72- pagesUsingBundles [ url ] = true ;
73- }
74-
7558 return OutOfOrderRender . getAssetKey ( "file" , type , bucket ) ;
7659 } ) ;
7760
@@ -98,5 +81,3 @@ function eleventyBundleShortcodes(eleventyConfig, pluginOptions = {}) {
9881 } ) ;
9982 } ) ;
10083} ;
101-
102- export default eleventyBundleShortcodes ;
0 commit comments