fix(plugin-tools): prioritize prefixed plugin names over non-prefixed names when importing plugins
This is to not accidentally importing for instance the "pino" package if reporter is set to just "pino" and instead import the "@emigrate/reporter-pino" package if that's the case.
This commit is contained in:
parent
43a220d633
commit
20ed2e8a50
2 changed files with 6 additions and 1 deletions
5
.changeset/proud-numbers-jam.md
Normal file
5
.changeset/proud-numbers-jam.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@emigrate/plugin-tools': patch
|
||||
---
|
||||
|
||||
Try importing plugins (and reporters) using prefixes before importing without, this is to avoid issue with accidentaly importing other non-emigrate related packages. E.g. setting the reporter to "pino" would import the "pino" package without this fix and will import "@emigrate/reporter-pino" with this fix.
|
||||
|
|
@ -184,7 +184,7 @@ const load = async <T>(
|
|||
): Promise<T | undefined> => {
|
||||
const importFromEsm = await getImportFromEsm();
|
||||
|
||||
const importsToTry = name.startsWith('.') ? [name] : [name, ...prefixes.map((prefix) => `${prefix}${name}`)];
|
||||
const importsToTry = name.startsWith('.') ? [name] : [...prefixes.map((prefix) => `${prefix}${name}`), name];
|
||||
|
||||
for await (const importPath of importsToTry) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue