diff --git a/.changeset/proud-numbers-jam.md b/.changeset/proud-numbers-jam.md new file mode 100644 index 0000000..c1483bc --- /dev/null +++ b/.changeset/proud-numbers-jam.md @@ -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. diff --git a/packages/plugin-tools/src/index.ts b/packages/plugin-tools/src/index.ts index 91d30f2..4b96c71 100644 --- a/packages/plugin-tools/src/index.ts +++ b/packages/plugin-tools/src/index.ts @@ -184,7 +184,7 @@ const load = async ( ): Promise => { 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 {