mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 22:55:13 +00:00
fix(core): don't skip loading runtime modules if one is improperly resolved (#10193)
This commit is contained in:
parent
940fc7dcbb
commit
e0ca3d1af8
@ -150,7 +150,10 @@ export default class ModuleContainer {
|
|||||||
|
|
||||||
// Prevent adding buildModules-listed entries in production
|
// Prevent adding buildModules-listed entries in production
|
||||||
if (this.options.buildModules.includes(handler) && this.options._start) {
|
if (this.options.buildModules.includes(handler) && this.options._start) {
|
||||||
return
|
if (handler) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
consola.warn('Module not resolved:', src)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve handler
|
// Resolve handler
|
||||||
|
@ -431,6 +431,28 @@ describe('core: module', () => {
|
|||||||
await expect(module.addModule('moduleTest')).rejects.toThrow('Module should export a function: moduleTest')
|
await expect(module.addModule('moduleTest')).rejects.toThrow('Module should export a function: moduleTest')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('should prevent adding same handler to modules and buildModules', async () => {
|
||||||
|
const handler = jest.fn(() => true)
|
||||||
|
handler.meta = {
|
||||||
|
name: 'moduleTest'
|
||||||
|
}
|
||||||
|
|
||||||
|
const module = new ModuleContainer({
|
||||||
|
resolver: { requireModule },
|
||||||
|
options: {
|
||||||
|
...defaultOptions,
|
||||||
|
buildModules: [handler],
|
||||||
|
_start: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const result = await module.addModule({ handler }, true)
|
||||||
|
|
||||||
|
expect(result).toBeUndefined()
|
||||||
|
expect(handler).toBeCalledTimes(0)
|
||||||
|
expect(module.requiredModules.moduleTest).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
test('should prevent multiple adding when requireOnce is enabled', async () => {
|
test('should prevent multiple adding when requireOnce is enabled', async () => {
|
||||||
const module = new ModuleContainer({
|
const module = new ModuleContainer({
|
||||||
resolver: { requireModule },
|
resolver: { requireModule },
|
||||||
|
Loading…
Reference in New Issue
Block a user