diff --git a/.gitignore b/.gitignore index f785dfc..79473aa 100644 --- a/.gitignore +++ b/.gitignore @@ -177,4 +177,5 @@ out /bin /build __fixtures__ -/public \ No newline at end of file +/public +/.data \ No newline at end of file diff --git a/dist/functions/init.js b/dist/functions/init.js index 6354291..2eaab82 100644 --- a/dist/functions/init.js +++ b/dist/functions/init.js @@ -3,8 +3,10 @@ import grabDirNames from "../utils/grab-dir-names"; import { execSync } from "child_process"; import path from "path"; import grabConfig from "./grab-config"; +import isDevelopment from "../utils/is-development"; export default async function () { const dirNames = grabDirNames(); + const is_dev = isDevelopment(); execSync(`rm -rf ${dirNames.BUNEXT_CACHE_DIR}`); execSync(`rm -rf ${dirNames.BUNX_CWD_MODULE_CACHE_DIR}`); try { @@ -31,6 +33,6 @@ export default async function () { const config = (await grabConfig()) || {}; global.CONFIG = { ...config, - development: true, + development: is_dev, }; } diff --git a/dist/functions/server/watcher.js b/dist/functions/server/watcher.js index c7696e6..e7de970 100644 --- a/dist/functions/server/watcher.js +++ b/dist/functions/server/watcher.js @@ -30,6 +30,9 @@ export default function watcher() { } return; } + if (!filename.match(/\.(tsx?|jsx?)$/)) { + return; + } if (!filename.match(/^src\/pages\//)) return; if (filename.match(/\/(--|\()/)) diff --git a/dist/functions/server/web-pages/generate-web-html.js b/dist/functions/server/web-pages/generate-web-html.js index e810f17..fb8cbb6 100644 --- a/dist/functions/server/web-pages/generate-web-html.js +++ b/dist/functions/server/web-pages/generate-web-html.js @@ -1,5 +1,5 @@ import { jsx as _jsx } from "react/jsx-runtime"; -import path from "path"; +import { renderToString } from "react-dom/server"; import grabContants from "../../../utils/grab-constants"; import EJSON from "../../../utils/ejson"; import isDevelopment from "../../../utils/is-development"; @@ -9,7 +9,6 @@ import { log } from "../../../utils/log"; import { AppData } from "../../../data/app-data"; export default async function genWebHTML({ component, pageProps, bundledMap, head: Head, module, meta, routeParams, debug, }) { const { ClientRootElementIDName, ClientWindowPagePropsName } = grabContants(); - const { renderToString } = await import(path.join(process.cwd(), "node_modules", "react-dom", "server")); if (debug) { log.info("component", component); } diff --git a/package.json b/package.json index a19dbce..05389a0 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,19 @@ "type": "module", "version": "1.0.6", "main": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + }, + "./types": { + "types": "./dist/types/index.d.ts", + "import": "./dist/types/index.js", + "default": "./dist/types/index.js" + } + }, "bin": { "bunext": "dist/commands/index.js" }, @@ -14,7 +27,7 @@ ], "scripts": { "dev": "tsc --watch", - "publish": "tsc --noEmit && tsc && git add . && git commit -m 'Update tests' && git push", + "publish": "tsc --noEmit && tsc && git add . && git commit -m 'Bugfixes: update types, update imports, update init function.' && git push", "compile": "bun build ./src/commands/index.ts --compile --outfile bin/bunext", "build": "tsc", "test": "bun test --max-concurrency=1" diff --git a/src/functions/init.ts b/src/functions/init.ts index 4e5c70d..d65bb03 100644 --- a/src/functions/init.ts +++ b/src/functions/init.ts @@ -4,9 +4,11 @@ import { execSync } from "child_process"; import path from "path"; import grabConfig from "./grab-config"; import type { BunextConfig } from "../types"; +import isDevelopment from "../utils/is-development"; export default async function () { const dirNames = grabDirNames(); + const is_dev = isDevelopment(); execSync(`rm -rf ${dirNames.BUNEXT_CACHE_DIR}`); execSync(`rm -rf ${dirNames.BUNX_CWD_MODULE_CACHE_DIR}`); @@ -48,6 +50,6 @@ export default async function () { global.CONFIG = { ...config, - development: true, + development: is_dev, }; } diff --git a/src/functions/server/watcher.ts b/src/functions/server/watcher.ts index 046f7fe..9baccf3 100644 --- a/src/functions/server/watcher.ts +++ b/src/functions/server/watcher.ts @@ -39,6 +39,10 @@ export default function watcher() { return; } + if (!filename.match(/\.(tsx?|jsx?)$/)) { + return; + } + if (!filename.match(/^src\/pages\//)) return; if (filename.match(/\/(--|\()/)) return; diff --git a/src/functions/server/web-pages/generate-web-html.tsx b/src/functions/server/web-pages/generate-web-html.tsx index b7654ec..4e37d09 100644 --- a/src/functions/server/web-pages/generate-web-html.tsx +++ b/src/functions/server/web-pages/generate-web-html.tsx @@ -1,4 +1,4 @@ -import path from "path"; +import { renderToString } from "react-dom/server"; import grabContants from "../../../utils/grab-constants"; import EJSON from "../../../utils/ejson"; import type { LivePageDistGenParams } from "../../../types"; @@ -21,10 +21,6 @@ export default async function genWebHTML({ const { ClientRootElementIDName, ClientWindowPagePropsName } = grabContants(); - const { renderToString } = await import( - path.join(process.cwd(), "node_modules", "react-dom", "server") - ); - if (debug) { log.info("component", component); }