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 be reverted for the 1.0 release. It is purely here for
ease of transition from `force` to `onError`.
  • Loading branch information
happycollision committed Jul 26, 2021
1 parent 97ab3b0 commit d90b018
Show file tree
Hide file tree
Showing 3 changed files with 21 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,
// TODO: remove this for the 1.0 release
force: undefined,
onError: 'fail',
pages: ['*']
},
Expand Down Expand Up @@ -150,6 +152,8 @@ test('fills in partial blanks', () => {
prerender: {
crawl: true,
enabled: true,
// TODO: remove this for the 1.0 release
force: undefined,
onError: 'fail',
pages: ['*']
},
Expand Down
16 changes: 16 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,22 @@ const options = {
children: {
crawl: expect_boolean(true),
enabled: expect_boolean(true),
// TODO: remove this for the 1.0 release
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 d90b018

Please sign in to comment.