This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve
autoImports
deprecation dx (#7158)
- Loading branch information
Showing
7 changed files
with
100 additions
and
78 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Import } from 'unimport' | ||
import { useNuxt } from './context' | ||
import { assertNuxtCompatibility } from './compatibility' | ||
|
||
export function addImports (imports: Import | Import[]) { | ||
assertNuxtCompatibility({ bridge: true }) | ||
|
||
// TODO: Use imports:* when widely adopted | ||
useNuxt().hook('autoImports:extend', (_imports) => { | ||
_imports.push(...(Array.isArray(imports) ? imports : [imports])) | ||
}, { allowDeprecated: true }) | ||
} | ||
|
||
/** | ||
* @deprecated Please use `addImports` instead with nuxt>=3.0.0-rc.9 | ||
*/ | ||
export const addAutoImport = addImports | ||
|
||
export function addImportsDir (dirs: string | string[]) { | ||
assertNuxtCompatibility({ bridge: true }) | ||
|
||
// TODO: Use imports:* when widely adopted | ||
useNuxt().hook('autoImports:dirs', (_dirs: string[]) => { | ||
for (const dir of (Array.isArray(dirs) ? dirs : [dirs])) { | ||
_dirs.push(dir) | ||
} | ||
}, { allowDeprecated: true }) | ||
} | ||
|
||
/** | ||
* @deprecated Please use `addImportsDir` instead with nuxt>=3.0.0-rc.9 | ||
*/ | ||
export const addAutoImportDir = addImportsDir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters