This commit is contained in:
2026-03-23 07:42:00 +01:00
parent 567fb4f746
commit 4b8b610e32
43 changed files with 635 additions and 169 deletions
@@ -71,6 +71,7 @@ export default async function allPagesBunBundler(params?: Params) {
chunk: "chunks/[hash].[ext]",
},
plugins: [tailwindcss],
// plugins: [tailwindcss, BunSkipNonBrowserPlugin],
splitting: true,
target,
metafile: true,
@@ -0,0 +1,35 @@
const BunSkipNonBrowserPlugin: Bun.BunPlugin = {
name: "skip-non-browser",
setup(build) {
build.onResolve({ filter: /^(bun:|node:)/ }, (args) => {
return { path: args.path, external: true };
});
build.onResolve({ filter: /^[^./]/ }, (args) => {
// If it's a built-in like 'fs' or 'path', skip it immediately
const excludes = [
"fs",
"path",
"os",
"crypto",
"net",
"events",
"util",
];
if (excludes.includes(args.path) || args.path.startsWith("node:")) {
return { path: args.path, external: true };
}
try {
Bun.resolveSync(args.path, args.importer || process.cwd());
return null;
} catch (e) {
console.warn(`[Skip] Mark as external: ${args.path}`);
return { path: args.path, external: true };
}
});
},
};
export default BunSkipNonBrowserPlugin;
+8 -1
View File
@@ -3,6 +3,7 @@ import grabDirNames from "../utils/grab-dir-names";
import path from "path";
import grabConfig from "./grab-config";
import type { BunextConfig } from "../types";
import { log } from "../utils/log";
export default async function () {
const dirNames = grabDirNames();
@@ -29,7 +30,13 @@ export default async function () {
"react-dom",
);
if (dirNames.BUNX_ROOT_DIR !== dirNames.ROOT_DIR) {
if (
dirNames.ROOT_DIR.startsWith(dirNames.BUNX_ROOT_DIR) &&
!dirNames.ROOT_DIR.includes(`${dirNames.BUNX_ROOT_DIR}/test/`)
) {
log.error(`Can't Run From this Directory => ${dirNames.ROOT_DIR}`);
process.exit(1);
} else {
rmSync(react_package_dir, { recursive: true });
rmSync(react_dom_package_dir, { recursive: true });
}