From be98d35db2322edd8076067b8f0dcc742842d5d5 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Tue, 3 Dec 2024 13:32:59 +0200 Subject: [PATCH] Remove order: 'pre' from resolveId This causes the plugin to run too early in Vite, preventing any `resolve.alias` from taking effect or for any other plugin to handle node builtins, whether `builtins` or `builtinsPrefix` is set. For example, when you want to polyfill via alias some Node builtins, when building for both browser and Node.js. `enforce: 'pre'` is still needed to run early enough in the Vite plugins order. Which makes `resolveId` already run in the right place in the plugin order. For plain rollup, just place the plugin before other plugins that depend on aliases, for reference, the standard alias plugin doesn't include `order: 'pre'` as well, to allow control such control. --- source/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/source/index.ts b/source/index.ts index 4dd907c..d0d3744 100644 --- a/source/index.ts +++ b/source/index.ts @@ -233,7 +233,6 @@ function nodeExternals(options: ExternalsOptions = {}): Plugin { }, resolveId: { - order: 'pre', async handler(specifier, importer, { isEntry }) { if ( isEntry // Ignore entry points (they should always be resolved)