You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Astro v4.5.10
Node v20.10.0
System Windows (x64)
Package Manager pnpm
Output static
Adapter none
Integrations @astrojs/sitemap
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
First of all, I thought it was a problem with the vitePwa plugin, where from my first issue on their github here : vite-pwa/vite-plugin-pwa#694
In fact it's more due to the way the Astro template syntax works, in my opinion this is inconsistent:
In a .astro file, in template part :
when I wrote <script src="/src/pwa.ts"></script> , the typescript file was process and bundle as expected .
but
when I do the same import in a {...} block (sorry I don't know this block type name in Astro template) like this : {true && <script src="/src/pwa.ts"></script>}
the pwa.ts file is not processed and bundled and the generated html source code is : <script src="/src/pwa.ts"></script>
What's the expected result?
In a Astro template file, for JS or TS script import in a {...} : {true && <script src="/src/pwa.ts"></script>}
The ts (or js) script should be processed and bundled as if it were written <script src="/src/pwa.ts"></script> in the astro file.
This is a design constraint and intentional. All of your scripts are bundled together at the page level. If some are conditional they can't be bundled together. So they are treated as inline and not optimized.
There's no way to have conditional scripts that get bundled.
This is a design constraint and intentional. All of your scripts are bundled together at the page level. If some are conditional they can't be bundled together. So they are treated as inline and not optimized.
There's no way to have conditional scripts that get bundled.
Thanks you for this response.
In my case I have try with this code in the astro file :
It appears to work like I expect.
I see the pwa.ts (ts file) is processed ! and bundled I think like a "static script load tag".
May be not bundled in the hoisted.xxx.js file but in a separate pwa.xxx.js
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
First of all, I thought it was a problem with the vitePwa plugin, where from my first issue on their github here :
vite-pwa/vite-plugin-pwa#694
In fact it's more due to the way the Astro template syntax works, in my opinion this is inconsistent:
In a .astro file, in template part :
<script src="/src/pwa.ts"></script>
, the typescript file was process and bundle as expected .but
{...}
block (sorry I don't know this block type name in Astro template) like this :{true && <script src="/src/pwa.ts"></script>}
the pwa.ts file is not processed and bundled and the generated html source code is :
<script src="/src/pwa.ts"></script>
What's the expected result?
In a Astro template file, for JS or TS script import in a
{...}
:{true && <script src="/src/pwa.ts"></script>}
The ts (or js) script should be processed and bundled as if it were written
<script src="/src/pwa.ts"></script>
in the astro file.Link to Minimal Reproducible Example
https://gitlab.com/ekliptus49/vite-plugin-pwa-astro-minimal-sw-issue/-/blob/master/src/pages/index.astro
Participation
The text was updated successfully, but these errors were encountered: