This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First stab at #280. This adds a
--legacy
flag tosapper build
andsapper export
.When the flag is set, Sapper creates two builds, by running your client config twice — once normally, and once with
process.env.SAPPER_LEGACY_BUILD === 'true'
. It has no opinion about how exactly you define a legacy build, but it's easy to do in a Rollup config file. The regular build goes inclient
, the legacy build goes inclient/legacy
.Later, when the middleware renders the page, it includes a block of code like this (except minified):
In other words, it selects between
client/client.xyz123,js
andclient/legacy/client.abc234.js
based on whether theasync
keyword is supported. This is the same way Meteor defines 'modern browser'.The thinking is that you would add the Babel plugin to your Rollup config and only run it if the env var was set. You can see what that looks like here: https://github.com/sveltejs/sapper-template-rollup/blob/babel/rollup/client.config.js (the app is deployed here, if anyone fancies verifying that it does in fact work in e.g. IE11, since I haven't had the chance to do that yet).
Does this seem like the right approach?