perf(plugins): prefer native jiti for bundled plugin dist modules

This commit is contained in:
Aaron U'Ren
2026-04-21 20:28:07 -05:00
committed by Gustavo Madeira Santana
parent fe663de8c7
commit 314f11ba8f
2 changed files with 7 additions and 3 deletions

View File

@@ -916,12 +916,16 @@ describe("plugin sdk alias helpers", () => {
}
});
it("keeps bundled plugin dist modules on the aliased Jiti path", () => {
it("prefers native jiti for bundled plugin dist .js modules, keeps .ts on aliased path", () => {
// Built .js/.mjs/.cjs files under dist/extensions/ should now delegate
// to shouldPreferNativeJiti() — which returns true on Linux/macOS for
// compiled artifacts, avoiding the slow jiti transform path.
expect(
resolvePluginLoaderJitiTryNative(`/repo/${bundledDistPluginFile("browser", "index.js")}`, {
preferBuiltDist: true,
}),
).toBe(false);
).toBe(true);
// TypeScript source files still need jiti's transform pipeline.
expect(
resolvePluginLoaderJitiTryNative(`/repo/${bundledDistPluginFile("browser", "helper.ts")}`, {
preferBuiltDist: true,

View File

@@ -671,7 +671,7 @@ export function resolvePluginLoaderJitiTryNative(
},
): boolean {
if (isBundledPluginDistModulePath(modulePath)) {
return false;
return shouldPreferNativeJiti(modulePath);
}
return (
shouldPreferNativeJiti(modulePath) ||