Updates
This commit is contained in:
@@ -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;
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user