fix(up): only load the JavaScript loader plugin if necessary

This commit is contained in:
Joakim Carlstein 2023-11-22 15:40:53 +01:00
parent 60ae3b8c82
commit b57c86eaab
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@emigrate/cli': patch
---
Only load the JavaScript loader plugin if necessary

View file

@ -16,7 +16,6 @@ import {
} from '../errors.js'; } from '../errors.js';
import { type Config } from '../types.js'; import { type Config } from '../types.js';
import { withLeadingPeriod } from '../with-leading-period.js'; import { withLeadingPeriod } from '../with-leading-period.js';
import pluginLoaderJs from '../plugin-loader-js.js';
import { getMigrations } from '../get-migrations.js'; import { getMigrations } from '../get-migrations.js';
type ExtraFlags = { type ExtraFlags = {
@ -29,6 +28,7 @@ const getDuration = (start: [number, number]) => {
}; };
const lazyDefaultReporter = async () => import('../reporters/default.js'); const lazyDefaultReporter = async () => import('../reporters/default.js');
const lazyPluginLoaderJs = async () => import('../plugin-loader-js.js');
export default async function upCommand({ export default async function upCommand({
storage: storageConfig, storage: storageConfig,
@ -80,7 +80,7 @@ export default async function upCommand({
} }
const migrationFileExtensions = new Set(migrationFiles.map((migration) => migration.extension)); const migrationFileExtensions = new Set(migrationFiles.map((migration) => migration.extension));
const loaderPlugins = await getOrLoadPlugins('loader', [pluginLoaderJs, ...plugins]); const loaderPlugins = await getOrLoadPlugins('loader', [lazyPluginLoaderJs, ...plugins]);
const loaderByExtension = new Map<string, LoaderPlugin | undefined>( const loaderByExtension = new Map<string, LoaderPlugin | undefined>(
[...migrationFileExtensions].map( [...migrationFileExtensions].map(