-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<script tag import> in {curly brace syntax} is not processed like a simple <script tag import> in Astro template file #10685
Comments
Do you need to add the https://docs.astro.build/en/reference/directives-reference/#isinline |
They are expecting it to be 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. <script>
import { BUILD_Config } from "@data/configs";
BUILD_Config.PWA.ENABLE && import("../pwa.ts");
</script> It appears to work like I expect. Is there is a problem to do this ? Thanks you |
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: