This PR updates the bundle transform function, allowing page.outputPath to be falsy when running under Eleventy Serverless.
This fixes an issue that causes placeholder strings to be rendered in Eleventy Serverless responses.
Details & Context
When using the shipping version of the bundler plugin in an Eleventy Serverless context, placeholder values are unexpectedly rendered to the resulting page. For example:
{# src/_includes/layouts/base.njk #}
<!-- Here comes a bundle result! -->
{%- getBundle "html", "head-preconnect" -%}
results in an un-transformed placeholder rendered in the response:
<!-- Here comes a bundle result! -->
/*__EleventyBundle:get:html:head-preconnect:EleventyBundle__*/
This appears to be the result of the test for page.outputPath:
Removing that check when running under Serverless — leaving only the test of whether content is a string — results in placeholder replacement by the plugin transform, as expected.
Summary
This PR updates the bundle transform function, allowing
page.outputPath
to be falsy when running under Eleventy Serverless.This fixes an issue that causes placeholder strings to be rendered in Eleventy Serverless responses.
Details & Context
When using the shipping version of the bundler plugin in an Eleventy Serverless context, placeholder values are unexpectedly rendered to the resulting page. For example:
results in an un-transformed placeholder rendered in the response:
This appears to be the result of the test for
page.outputPath
:https://github.com/11ty/eleventy-plugin-bundle/blob/5a95ce2e0863722ed8242f3e44cdcd94323a4982/eleventy.shortcodes.js#L63-L66
which is
false
when the page is rendered by Eleventy Serverless:Removing that check when running under Serverless — leaving only the test of whether
content
is a string — results in placeholder replacement by the plugin transform, as expected.