diff --git a/lib/common/utils.js b/lib/common/utils.js index 0045b11ec9..1ad1b77241 100644 --- a/lib/common/utils.js +++ b/lib/common/utils.js @@ -258,12 +258,12 @@ export const createRoutes = function createRoutes(files, srcDir, pagesDir) { let parent = routes keys.forEach((key, i) => { // remove underscore only, if its the prefix - const sanatizedKey = key.indexOf('_') === 0 + const sanitizedKey = key.indexOf('_') === 0 ? key.replace('_', '') : key route.name = route.name - ? route.name + '-' + sanatizedKey - : sanatizedKey + ? route.name + '-' + sanitizedKey + : sanitizedKey route.name += key === '_' ? 'all' : '' route.chunkName = file.replace(/\.(vue|js)$/, '') let child = _.find(parent, { name: route.name }) diff --git a/lib/core/module.js b/lib/core/module.js index 489fcdc528..9e64265ddd 100644 --- a/lib/core/module.js +++ b/lib/core/module.js @@ -22,7 +22,7 @@ export default class ModuleContainer { } addVendor(vendor) { - // Make it silent for backward compability with nuxt 1.x + // Make it silent for backward compatibility with nuxt 1.x } addTemplate(template) { @@ -112,7 +112,9 @@ export default class ModuleContainer { // Resolve handler if (!handler) { - handler = this.nuxt.requireModule(src, { esm: false }) + // If module is internal (src starts with '.' or alias '@' '~'), support esm + const isInnerModule = /^[.@~]/.test(src) + handler = this.nuxt.requireModule(src, { esm: isInnerModule }) } // Validate handler diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index c70bf4485d..fab4a76189 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -199,8 +199,8 @@ export default class Nuxt { } requireModule(_path, opts = {}) { - const _resovledPath = this.resolvePath(_path) - const m = opts.esm === false ? require(_resovledPath) : this.esm(_resovledPath) + const _resolvedPath = this.resolvePath(_path) + const m = opts.esm === false ? require(_resolvedPath) : this.esm(_resolvedPath) return (m && m.default) || m }