mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
fix(core): correct deprecated hooks (#7002)
This commit is contained in:
parent
084a1ca1af
commit
6e09e7824d
@ -21,7 +21,7 @@
|
||||
"execa": "^3.4.0",
|
||||
"exit": "^0.1.2",
|
||||
"fs-extra": "^8.1.0",
|
||||
"hable": "^2.3.2",
|
||||
"hable": "^3.0.0",
|
||||
"minimist": "^1.2.0",
|
||||
"opener": "1.5.1",
|
||||
"pretty-bytes": "^5.3.0",
|
||||
|
@ -17,7 +17,7 @@
|
||||
"debug": "^4.1.1",
|
||||
"esm": "^3.2.25",
|
||||
"fs-extra": "^8.1.0",
|
||||
"hable": "^2.3.2",
|
||||
"hable": "^3.0.0",
|
||||
"hash-sum": "^2.0.0",
|
||||
"std-env": "^2.2.1"
|
||||
},
|
||||
|
@ -25,9 +25,17 @@ export default class Nuxt extends Hookable {
|
||||
|
||||
// Deprecated hooks
|
||||
this.deprecateHooks({
|
||||
'render:context': 'render:routeContext',
|
||||
'render:routeContext': 'vue-renderer:ssr:context',
|
||||
showReady: 'webpack:done' // Workaround to deprecate showReady
|
||||
// #3294 - 7514db73b25c23b8c14ebdafbb4e129ac282aabd
|
||||
'render:context': {
|
||||
to: '_render:context',
|
||||
message: '`render:context(nuxt)` is deprecated, Please use `vue-renderer:ssr:context(context)`'
|
||||
},
|
||||
// #3773
|
||||
'render:routeContext': {
|
||||
to: '_render:context',
|
||||
message: '`render:routeContext(nuxt)` is deprecated, Please use `vue-renderer:ssr:context(context)`'
|
||||
},
|
||||
showReady: 'webpack:done'
|
||||
})
|
||||
|
||||
// Add Legacy aliases
|
||||
|
@ -36,12 +36,6 @@ describe('core: nuxt', () => {
|
||||
expect(nuxt.moduleContainer).toBeInstanceOf(ModuleContainer)
|
||||
expect(nuxt.server).toBeInstanceOf(Server)
|
||||
|
||||
expect(nuxt._deprecatedHooks).toEqual({
|
||||
'render:context': 'render:routeContext',
|
||||
'render:routeContext': 'vue-renderer:ssr:context',
|
||||
showReady: 'webpack:done'
|
||||
})
|
||||
|
||||
expect(defineAlias).toBeCalledTimes(2)
|
||||
expect(defineAlias).nthCalledWith(1, nuxt, nuxt.resolver, ['resolveAlias', 'resolvePath'])
|
||||
expect(defineAlias).nthCalledWith(2, nuxt, nuxt.server, ['renderRoute', 'renderAndGetWindow', 'listen'])
|
||||
@ -64,6 +58,17 @@ describe('core: nuxt', () => {
|
||||
expect(nuxt.callHook).toBeCalledWith('webpack:done')
|
||||
})
|
||||
|
||||
for (const name of ['render:context', 'render:routeContext']) {
|
||||
test('should deprecate ' + name, async () => {
|
||||
const nuxt = new Nuxt()
|
||||
const fn = jest.fn()
|
||||
nuxt.hook(name, fn)
|
||||
await nuxt.callHook('_render:context')
|
||||
expect(fn).toBeCalledTimes(1)
|
||||
expect(fn).toBeCalledWith()
|
||||
})
|
||||
}
|
||||
|
||||
test('should display fatal message if ready failed', async () => {
|
||||
const err = new Error('nuxt ready failed')
|
||||
const nuxt = new Nuxt()
|
||||
|
@ -91,8 +91,9 @@ export default class SSRRenderer extends BaseRenderer {
|
||||
|
||||
// Call ssr:context hook
|
||||
await this.serverContext.nuxt.callHook('vue-renderer:ssr:context', renderContext)
|
||||
// TODO: Remove in next major release
|
||||
await this.serverContext.nuxt.callHook('render:routeContext', renderContext.nuxt)
|
||||
|
||||
// TODO: Remove in next major release (#4722)
|
||||
await this.serverContext.nuxt.callHook('_render:context', renderContext.nuxt)
|
||||
|
||||
// Fallback to empty response
|
||||
if (!renderContext.nuxt.serverRendered) {
|
||||
|
@ -5741,7 +5741,6 @@ fsevents@^1.2.7:
|
||||
dependencies:
|
||||
bindings "^1.5.0"
|
||||
nan "^2.12.1"
|
||||
node-pre-gyp "*"
|
||||
|
||||
fsevents@^2.1.2, fsevents@~2.1.2:
|
||||
version "2.1.2"
|
||||
@ -6035,10 +6034,10 @@ gzip-size@^5.0.0:
|
||||
duplexer "^0.1.1"
|
||||
pify "^4.0.1"
|
||||
|
||||
hable@^2.3.2:
|
||||
version "2.3.2"
|
||||
resolved "https://registry.npmjs.org/hable/-/hable-2.3.2.tgz#7867ffec0b67e63136937613d9a0bc646ac9d7fe"
|
||||
integrity sha512-qJ9WoXl/15LNlG1KeAuBjCNGStUb+MCQ5biPxOmwRyESH8CSWwZB4xEnzCduuQ3I/mlgui28t8/oMAGT1Rpb2g==
|
||||
hable@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.npmjs.org/hable/-/hable-3.0.0.tgz#6de089b2df946635cf8134b9e4859f1b62de255f"
|
||||
integrity sha512-7+G0/2/COR8pwteYFqHIVYfQpuEiO2HXwJrhCBJVgrNrl9O5eaUoJVDGXUJX+0RpGncNVTuestexjk1afj01wQ==
|
||||
|
||||
handlebars@^4.4.0:
|
||||
version "4.7.3"
|
||||
|
Loading…
Reference in New Issue
Block a user