Update Package.json.
This commit is contained in:
Vendored
+74
@@ -0,0 +1,74 @@
|
||||
import { resolve } from "path";
|
||||
import { readFileSync } from "fs";
|
||||
const shimPath = resolve(import.meta.dir, "lightningcss-wasm-shim.ts");
|
||||
const wasmBytes = readFileSync(resolve(import.meta.dir, "node_modules/lightningcss-wasm/lightningcss_node.wasm"));
|
||||
const wasmBase64 = wasmBytes.toString("base64");
|
||||
const result = await Bun.build({
|
||||
entrypoints: ["./src/commands/index.ts"],
|
||||
outdir: "./build",
|
||||
target: "bun",
|
||||
plugins: [
|
||||
{
|
||||
name: "alias-lightningcss-to-wasm",
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /^lightningcss$/ }, () => {
|
||||
return {
|
||||
path: "lightningcss",
|
||||
namespace: "lcss-wasm-shim",
|
||||
};
|
||||
});
|
||||
build.onResolve({ filter: /^lightningcss\// }, () => {
|
||||
return {
|
||||
path: "lightningcss",
|
||||
namespace: "lcss-wasm-shim",
|
||||
};
|
||||
});
|
||||
build.onLoad({ filter: /.*/, namespace: "lcss-wasm-shim" }, () => {
|
||||
return {
|
||||
contents: `
|
||||
import init, {
|
||||
transform as wasmTransform,
|
||||
transformStyleAttribute as wasmTransformStyleAttribute,
|
||||
bundle as wasmBundle,
|
||||
bundleAsync as wasmBundleAsync,
|
||||
Features,
|
||||
browserslistToTargets,
|
||||
composeVisitors,
|
||||
} from "lightningcss-wasm";
|
||||
|
||||
const wasmBytes = Uint8Array.from(atob("${wasmBase64}"), c => c.charCodeAt(0));
|
||||
await init(wasmBytes);
|
||||
|
||||
export {
|
||||
wasmTransform as transform,
|
||||
wasmTransformStyleAttribute as transformStyleAttribute,
|
||||
wasmBundle as bundle,
|
||||
wasmBundleAsync as bundleAsync,
|
||||
Features,
|
||||
browserslistToTargets,
|
||||
composeVisitors,
|
||||
};
|
||||
`,
|
||||
loader: "ts",
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
if (!result.success) {
|
||||
console.error("Build failed:", result.logs);
|
||||
process.exit(1);
|
||||
}
|
||||
Bun.spawnSync({
|
||||
cmd: [
|
||||
"bun",
|
||||
"build",
|
||||
"./build/index.js",
|
||||
"--compile",
|
||||
"--outfile",
|
||||
"bin/bunext",
|
||||
],
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
});
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import { readFileSync } from "fs";
|
||||
import { resolve, dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import init, { transform as wasmTransform, transformStyleAttribute as wasmTransformStyleAttribute, bundle as wasmBundle, bundleAsync as wasmBundleAsync, Features, browserslistToTargets, composeVisitors, } from "lightningcss-wasm";
|
||||
// Resolve the .wasm file at build time — Bun's bundler will inline this
|
||||
// as a static path that gets embedded into the bundle.
|
||||
const wasmBytes = readFileSync(require.resolve("lightningcss-wasm/lightningcss_node.wasm"));
|
||||
await init(wasmBytes.toString());
|
||||
export { wasmTransform as transform, wasmTransformStyleAttribute as transformStyleAttribute, wasmBundle as bundle, wasmBundleAsync as bundleAsync, Features, browserslistToTargets, composeVisitors, };
|
||||
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bun
|
||||
import { program } from "commander";
|
||||
import start from "./start";
|
||||
import dev from "./dev";
|
||||
import ora, {} from "ora";
|
||||
import init from "../functions/init";
|
||||
import grabDirNames from "../utils/grab-dir-names";
|
||||
import build from "./build";
|
||||
global.ORA_SPINNER = ora();
|
||||
global.ORA_SPINNER.clear();
|
||||
global.HMR_CONTROLLERS = [];
|
||||
global.IS_FIRST_BUNDLE_READY = false;
|
||||
global.BUNDLER_REBUILDS = 0;
|
||||
global.PAGE_FILES = [];
|
||||
await init();
|
||||
const { PAGES_DIR } = grabDirNames();
|
||||
const router = new Bun.FileSystemRouter({
|
||||
style: "nextjs",
|
||||
dir: PAGES_DIR,
|
||||
});
|
||||
global.ROUTER = router;
|
||||
/**
|
||||
* # Describe Program
|
||||
*/
|
||||
program
|
||||
.name(`bunext`)
|
||||
.description(`A React Next JS replacement built with bun JS`)
|
||||
.version(`1.0.0`);
|
||||
/**
|
||||
* # Declare Commands
|
||||
*/
|
||||
program.addCommand(dev());
|
||||
program.addCommand(start());
|
||||
program.addCommand(build());
|
||||
/**
|
||||
* # Handle Unavailable Commands
|
||||
*/
|
||||
program.on("command:*", () => {
|
||||
console.error("Invalid command: %s\nSee --help for a list of available commands.", program.args.join(" "));
|
||||
process.exit(1);
|
||||
});
|
||||
/**
|
||||
* # Parse Arguments
|
||||
*/
|
||||
program.parse(Bun.argv);
|
||||
@@ -1,8 +1,5 @@
|
||||
import isDevelopment from "../../../utils/is-development";
|
||||
import * as esbuild from "esbuild";
|
||||
import postcss from "postcss";
|
||||
import tailwindcss from "@tailwindcss/postcss";
|
||||
import { readFile } from "fs/promises";
|
||||
import grabDirNames from "../../../utils/grab-dir-names";
|
||||
import path from "path";
|
||||
import tailwindEsbuildPlugin from "./tailwind-esbuild-plugin";
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import isDevelopment from "../../../utils/is-development";
|
||||
import * as esbuild from "esbuild";
|
||||
import postcss from "postcss";
|
||||
import tailwindcss from "@tailwindcss/postcss";
|
||||
import { readFile } from "fs/promises";
|
||||
import grabDirNames from "../../../utils/grab-dir-names";
|
||||
import path from "path";
|
||||
import { execSync } from "child_process";
|
||||
import tailwindEsbuildPlugin from "./tailwind-esbuild-plugin";
|
||||
export default async function grabTsxStringModule({ tsx, file_path, }) {
|
||||
const dev = isDevelopment();
|
||||
|
||||
Vendored
+2
-45
@@ -1,45 +1,2 @@
|
||||
#!/usr/bin/env bun
|
||||
import { program } from "commander";
|
||||
import start from "./commands/start";
|
||||
import dev from "./commands/dev";
|
||||
import ora, {} from "ora";
|
||||
import init from "./functions/init";
|
||||
import grabDirNames from "./utils/grab-dir-names";
|
||||
import build from "./commands/build";
|
||||
global.ORA_SPINNER = ora();
|
||||
global.ORA_SPINNER.clear();
|
||||
global.HMR_CONTROLLERS = [];
|
||||
global.IS_FIRST_BUNDLE_READY = false;
|
||||
global.BUNDLER_REBUILDS = 0;
|
||||
global.PAGE_FILES = [];
|
||||
await init();
|
||||
const { PAGES_DIR } = grabDirNames();
|
||||
const router = new Bun.FileSystemRouter({
|
||||
style: "nextjs",
|
||||
dir: PAGES_DIR,
|
||||
});
|
||||
global.ROUTER = router;
|
||||
/**
|
||||
* # Describe Program
|
||||
*/
|
||||
program
|
||||
.name(`bunext`)
|
||||
.description(`A React Next JS replacement built with bun JS`)
|
||||
.version(`1.0.0`);
|
||||
/**
|
||||
* # Declare Commands
|
||||
*/
|
||||
program.addCommand(dev());
|
||||
program.addCommand(start());
|
||||
program.addCommand(build());
|
||||
/**
|
||||
* # Handle Unavailable Commands
|
||||
*/
|
||||
program.on("command:*", () => {
|
||||
console.error("Invalid command: %s\nSee --help for a list of available commands.", program.args.join(" "));
|
||||
process.exit(1);
|
||||
});
|
||||
/**
|
||||
* # Parse Arguments
|
||||
*/
|
||||
program.parse(Bun.argv);
|
||||
const bunext = {};
|
||||
export default bunext;
|
||||
|
||||
Reference in New Issue
Block a user