Skip to content

Commit

Permalink
Remove order: 'pre' from resolveId
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
segevfiner authored Dec 3, 2024
1 parent 15b1a9a commit be98d35
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit be98d35

Please sign in to comment.