From 5962caecbf72b7e53624a889d123a3ebb1fa2698 Mon Sep 17 00:00:00 2001 From: Aurion SARL Date: Tue, 5 Nov 2024 17:37:36 +0100 Subject: [PATCH] fix(build): preserve getOptions in CJS wrapper Previously, the CJS wrapper only preserved 'meta' and 'getMeta' properties from Nuxt modules, causing issues with modules like sitemap which rely on the getOptions method. This commit adds getOptions to the CJS wrapper, ensuring full module API compatibility between ESM and CJS environments. --- src/commands/build.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/commands/build.ts b/src/commands/build.ts index b3cddff..63ad1f0 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -258,6 +258,9 @@ async function writeCJSStub(distDir: string) { } const _meta = module.exports.meta = require('./module.json') module.exports.getMeta = () => Promise.resolve(_meta) +module.exports.getOptions = function(...args) { + return import('./module.mjs').then(m => m.default.getOptions.call(this, ...args)) +} ` await fsp.writeFile(cjsStubFile, cjsStub, 'utf8') }