From bdf201d24d35ce6eba24833736e190decd51503c Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 6 Mar 2024 12:44:50 +0000 Subject: [PATCH] fix(nuxt): use exported `toExports` from `unimport` (#26086) --- packages/nuxt/src/imports/module.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nuxt/src/imports/module.ts b/packages/nuxt/src/imports/module.ts index 01ccd89488..3636c5a84d 100644 --- a/packages/nuxt/src/imports/module.ts +++ b/packages/nuxt/src/imports/module.ts @@ -2,7 +2,7 @@ import { existsSync } from 'node:fs' import { addTemplate, addVitePlugin, addWebpackPlugin, defineNuxtModule, isIgnored, logger, resolveAlias, tryResolveModule, updateTemplates, useNuxt } from '@nuxt/kit' import { isAbsolute, join, normalize, relative, resolve } from 'pathe' import type { Import, Unimport } from 'unimport' -import { createUnimport, scanDirExports } from 'unimport' +import { createUnimport, scanDirExports, toExports } from 'unimport' import type { ImportPresetWithDeprecation, ImportsOptions } from 'nuxt/schema' import { lookupNodeModuleSubpath, parseNodeModulePath } from 'mlly' @@ -79,7 +79,7 @@ export default defineNuxtModule>({ // Support for importing from '#imports' addTemplate({ filename: 'imports.mjs', - getContents: async () => await ctx.toExports() + '\nif (import.meta.dev) { console.warn("[nuxt] `#imports` should be transformed with real imports. There seems to be something wrong with the imports plugin.") }' + getContents: async () => toExports(await ctx.getImports()) + '\nif (import.meta.dev) { console.warn("[nuxt] `#imports` should be transformed with real imports. There seems to be something wrong with the imports plugin.") }' }) nuxt.options.alias['#imports'] = join(nuxt.options.buildDir, 'imports') @@ -177,7 +177,7 @@ function addDeclarationTemplates (ctx: Unimport, options: Partial ctx.toExports(nuxt.options.buildDir, true) + getContents: async ({ nuxt }) => toExports(await ctx.getImports(), nuxt.options.buildDir, true) }) addTemplate({