Skip to content

Commit 3599432

Browse files
Add failure message for use of prerender.force
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`.
1 parent 97ab3b0 commit 3599432

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

packages/kit/src/core/config/index.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ test('fills in defaults', () => {
5050
prerender: {
5151
crawl: true,
5252
enabled: true,
53+
// TODO: remove this for the 1.0 release
54+
force: undefined,
5355
onError: 'fail',
5456
pages: ['*']
5557
},
@@ -150,6 +152,8 @@ test('fills in partial blanks', () => {
150152
prerender: {
151153
crawl: true,
152154
enabled: true,
155+
// TODO: remove this for the 1.0 release
156+
force: undefined,
153157
onError: 'fail',
154158
pages: ['*']
155159
},

packages/kit/src/core/config/options.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,22 @@ const options = {
121121
children: {
122122
crawl: expect_boolean(true),
123123
enabled: expect_boolean(true),
124+
// TODO: remove this for the 1.0 release
125+
force: {
126+
type: 'leaf',
127+
default: undefined,
128+
validate: (option, keypath) => {
129+
if (typeof option !== undefined) {
130+
const newSetting = option ? 'continue' : 'fail';
131+
const needsSetting = newSetting === 'continue';
132+
throw new Error(
133+
`${keypath} has been removed in favor of \`onError\`. In your case, set \`onError\` to "${newSetting}"${
134+
needsSetting ? '' : ' (or leave it undefined)'
135+
} to get the same behavior as you would with \`force: ${JSON.stringify(option)}\``
136+
);
137+
}
138+
}
139+
},
124140
onError: {
125141
type: 'leaf',
126142
default: 'fail',

packages/kit/src/core/config/test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function testLoadDefaultConfig(path) {
5454
exclude: []
5555
},
5656
paths: { base: '', assets: '/.' },
57-
prerender: { crawl: true, enabled: true, onError: 'fail', pages: ['*'] },
57+
prerender: { crawl: true, enabled: true, force: undefined, onError: 'fail', pages: ['*'] },
5858
router: true,
5959
ssr: true,
6060
target: null,

0 commit comments

Comments
 (0)