Skip to content

Commit

Permalink
Add failure message for use of prerender.force
Browse files Browse the repository at this point in the history
This commit can eventually be reverted, once the team thinks enough
people have updated and are using the new `prerender.onError` option. It
is purely here for ease of transition from `force` to `onError`.
  • Loading branch information
happycollision committed Jul 25, 2021
1 parent 3e839b0 commit a49af69
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/kit/src/core/config/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ test('fills in defaults', () => {
prerender: {
crawl: true,
enabled: true,
// This can be removed entirely after we remove the validation error associated with using `force`
force: undefined,
onError: 'fail',
pages: ['*']
},
Expand Down Expand Up @@ -150,6 +152,8 @@ test('fills in partial blanks', () => {
prerender: {
crawl: true,
enabled: true,
// This can be removed entirely after we remove the validation error associated with using `force`
force: undefined,
onError: 'fail',
pages: ['*']
},
Expand Down
15 changes: 15 additions & 0 deletions packages/kit/src/core/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ const options = {
children: {
crawl: expect_boolean(true),
enabled: expect_boolean(true),
force: {
type: 'leaf',
default: undefined,
validate: (option, keypath) => {
if (typeof option !== undefined) {
const newSetting = option ? 'continue' : 'fail';
const needsSetting = newSetting === 'continue';
throw new Error(
`${keypath} has been removed in favor of \`onError\`. In your case, set \`onError\` to "${newSetting}"${
needsSetting ? '' : ' (or leave it undefined)'
} to get the same behavior as you would with \`force: ${JSON.stringify(option)}\``
);
}
}
},
onError: {
type: 'leaf',
default: 'fail',
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/config/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function testLoadDefaultConfig(path) {
exclude: []
},
paths: { base: '', assets: '/.' },
prerender: { crawl: true, enabled: true, onError: 'fail', pages: ['*'] },
prerender: { crawl: true, enabled: true, force: undefined, onError: 'fail', pages: ['*'] },
router: true,
ssr: true,
target: null,
Expand Down

0 comments on commit a49af69

Please sign in to comment.