mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +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,8 +150,11 @@ 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) {
|
||||||
|
if (handler) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
consola.warn('Module not resolved:', src)
|
||||||
|
}
|
||||||
|
|
||||||
// Resolve handler
|
// Resolve handler
|
||||||
if (!handler) {
|
if (!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