Skip to content
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

Fix imported CSS with FastBoot #1048

Merged
merged 1 commit into from
Dec 21, 2021

Conversation

simonihmig
Copy link
Collaborator

@simonihmig simonihmig commented Dec 11, 2021

When importing CSS from a JS module in a FastBoot enabled app, Embroider would emit something like this into index.html:

<fastboot-script src="/assets/chunk.957ca35b25015b34de4d.js"></fastboot-script>
<fastboot-script src="/assets/chunk.96eb691090beaf949370.css"></fastboot-script>

This makes FastBoot try to parse and evaluate CSS as JavaScript, which obviously fails.

I tried to add a test case to fastboot-app, but this fails due to even more FastBoot/CSS issues (#1049)...

When importing CSS from a JS module in a FastBoot enabled app, Embroider would emit something like this into index.html:

```
<fastboot-script src="/assets/chunk.957ca35b25015b34de4d.js"></fastboot-script>
<fastboot-script src="/assets/chunk.96eb691090beaf949370.css"></fastboot-script>
```

This makes FastBoot try to parse and evaluate CSS as JavaScript, which obviously fails.
@simonihmig simonihmig added the bug Something isn't working label Dec 11, 2021
@ef4
Copy link
Contributor

ef4 commented Dec 12, 2021

I guess I can see how it's possible to introduce "fastboot-only CSS", since you can import css files into JS modules that are Fastboot-only.

And I guess this PR is implying that that CSS will never do anything, and it will be dropped?

@simonihmig
Copy link
Collaborator Author

I guess I can see how it's possible to introduce "fastboot-only CSS", since you can import css files into JS modules that are Fastboot-only.

Actually I am not importing it from a FastBoot-only module. It is a regular module (so browser + FastBoot), but one that is lazily loaded (from a splitted route). When rendering that route in FastBoot, those lazy chunks are added with <fastboot-script> for FastBoot to process them eagerly AFAIU, right? And that breaks for CSS.

You can see this in the reproduction I used for #1049, the import-app-fastboot branch. I have the changes of this PR applied as a patch, but without it you should see the same error there. It is this lazy route that imports CSS and makes FastBoot fail.

@ef4 ef4 merged commit b118e51 into embroider-build:master Dec 21, 2021
@simonihmig simonihmig deleted the fix-fastboot-imported-css branch December 21, 2021 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants