remove built-in AMP support#4710
Conversation
🦋 Changeset detectedLatest commit: 4c96bff The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
cc @john-michael-murphy as I know this'll probably affect you lot |
|
Migration looks doable. Thank you for the heads up. AMP is such a thorn! |
|
There's no good way to do automatic service worker installation (the transformer can't read the config, or |
benmccann
left a comment
There was a problem hiding this comment.
having kit in the name kit-amp seems a bit redundant. maybe just amp?
originally i was thinking that we might end up having kit-specific stuff in there, but i'm inclined to do this just because my muscles are so used to |
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
This removes the
amp: trueconfig option in favour of a more appropriate solution (we despise AMP and want to hasten its demise, but still need to provide some way for people to deal with it).It adds a new
@sveltejs/kit/ampmodule which exports atransformfunction, which:<script>tags<link rel="stylesheet">elementsamp-customattribute to<style><meta http-equiv>elementsadds<amp-install-serviceworker>if appropriateSome of these are TODO and I haven't quite figured out how to solve them. Also TODO:
Using it is relatively straightforward — set
inlineStyleThresholdtoInfinity(external stylesheets are disallowed), and add the following tosrc/hooks.js:One thing we lose is the ability to exclude CSS from components that are imported but not rendered for a given page. Given AMP's wholly arbitrary CSS size limit, that can be a problem. This can be solved (at least for prerendered pages, where it doesn't matter how expensive this sort of processing is) with something like https://github.com/purifycss/purifycss:
It's not quite as turnkey as the current solution, but it's fine.
Another thing we lose is validation. This, too, can easily be solved in userland by using
amphtml-validatordirectly.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpx changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0