refactor: update node polyfills and add buffer-polyfill plugin

Modify the node polyfills configuration to include additional modules and add a new buffer-polyfill plugin to handle Buffer imports in env.mjs files. This change ensures compatibility with required Node.js modules in the Vite environment.
This commit is contained in:
KevIsDev 2025-04-02 21:38:50 +01:00
parent c63732d2f4
commit cdbf9ba730

View File

@ -96,8 +96,28 @@ export default defineConfig((config) => {
},
plugins: [
nodePolyfills({
include: ['path', 'buffer', 'process'],
include: ['buffer', 'process', 'util', 'stream'],
globals: {
Buffer: true,
process: true,
global: true,
},
protocolImports: true,
exclude: ['child_process', 'fs', 'path'],
}),
{
name: 'buffer-polyfill',
transform(code, id) {
if (id.includes('env.mjs')) {
return {
code: `import { Buffer } from 'buffer';\n${code}`,
map: null,
};
}
return null;
},
},
config.mode !== 'test' && remixCloudflareDevProxy(),
remixVitePlugin({
future: {