31 lines
910 B
TypeScript
31 lines
910 B
TypeScript
import type { BunPlugin } from 'bun';
|
|
|
|
/**
|
|
* Plugin to prevent Bun's bundler from analyzing certain URL patterns.
|
|
* Marks URLs that should remain as runtime URLs as external.
|
|
*/
|
|
const runtimeExternalUrlsPlugin: BunPlugin = {
|
|
name: 'runtime-external-urls',
|
|
setup(build) {
|
|
// Intercept resolution of paths that start with /
|
|
build.onResolve({ filter: /^\// }, args => {
|
|
// Mark specific runtime URLs as external to prevent bundler analysis
|
|
const externalPatterns = [
|
|
'/profile-picture.webp',
|
|
// Add other runtime URLs here as needed
|
|
];
|
|
|
|
if (externalPatterns.some(pattern => args.path.includes(pattern))) {
|
|
return {
|
|
path: args.path,
|
|
external: true, // This tells the bundler NOT to bundle this
|
|
};
|
|
}
|
|
|
|
return undefined; // Let normal resolution continue
|
|
});
|
|
},
|
|
};
|
|
|
|
export default runtimeExternalUrlsPlugin;
|