@absolutejs/absolute 0.1.2 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
1
  {
2
- "name": "@absolutejs/absolute",
3
- "version": "0.1.2",
4
- "description": "A fullstack meta-framework for building web applications with TypeScript",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/alexkahndev/absolutejs.git"
8
- },
9
- "main": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
11
- "license": "CC BY-NC 4.0",
12
- "author": "Alex Kahn",
13
- "scripts": {
14
- "build": "bun build src/**/* --outdir dist --minify --splitting --target=bun && tsc --emitDeclarationOnly --project tsconfig.json",
15
- "test": "echo \"Error: no test specified\" && exit 1",
16
- "format": "prettier --write \"./**/*.{js,jsx,ts,tsx,css}\"",
17
- "dev": "bun run --watch example/server.ts"
18
- },
19
- "dependencies": {
20
- "@elysiajs/static": "1.0.2",
21
- "elysia": "1.0.13",
22
- "react": "19.1.0",
23
- "react-dom": "19.1.0",
24
- "svelte": "4.2.15",
25
- "vue": "3.4.26"
26
- },
27
- "devDependencies": {
28
- "@types/bun": "1.1.1",
29
- "@types/react": "19.1.0",
30
- "@types/react-dom": "19.1.2",
31
- "@types/vue": "2.0.0",
32
- "typescript": "5.7.2"
33
- }
2
+ "name": "@absolutejs/absolute",
3
+ "version": "0.1.5",
4
+ "description": "A fullstack meta-framework for building web applications with TypeScript",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/alexkahndev/absolutejs.git"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/src/index.d.ts",
11
+ "license": "CC BY-NC 4.0",
12
+ "author": "Alex Kahn",
13
+ "scripts": {
14
+ "build": "rm -rf dist && bun build src/index.ts --outdir dist --minify --splitting --target=bun && tsc --emitDeclarationOnly --project tsconfig.json",
15
+ "test": "echo \"Error: no test specified\" && exit 1",
16
+ "format": "prettier --write \"./**/*.{js,jsx,ts,tsx,css,json}\"",
17
+ "dev": "bun run --watch example/server.ts"
18
+ },
19
+ "dependencies": {
20
+ "@elysiajs/static": "1.0.2",
21
+ "elysia": "1.0.13",
22
+ "react": "19.1.0",
23
+ "react-dom": "19.1.0",
24
+ "svelte": "4.2.15",
25
+ "vue": "3.4.26"
26
+ },
27
+ "devDependencies": {
28
+ "@types/bun": "1.1.1",
29
+ "@types/react": "19.1.0",
30
+ "@types/react-dom": "19.1.2",
31
+ "@types/vue": "2.0.0",
32
+ "typescript": "5.7.2"
33
+ }
34
34
  }
package/src/core/build.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { rm, mkdir, writeFile } from "node:fs/promises";
2
2
  import { join, basename } from "node:path";
3
- import { exit } from "node:process";
3
+ import { cwd, exit } from "node:process";
4
4
  import { $, build as bunBuild, Glob } from "bun";
5
5
  import {
6
6
  MILLISECONDS_IN_A_MINUTE,
@@ -9,26 +9,47 @@ import {
9
9
  } from "../constants";
10
10
  import { updateScriptTags } from "../utils/updateScriptTags";
11
11
 
12
- const projectRoot = join(import.meta.dir, "..", "..");
13
- const buildDir = join(projectRoot, "example/build");
14
- const assetsDir = join(projectRoot, "example/assets");
15
- const reactIndexDir = join(projectRoot, "example/react/indexes");
16
- const javascriptDir = join(projectRoot, "example/javascript");
17
- const typeScriptDir = join(projectRoot, "example/typescript");
18
- const reactPagesDir = join(projectRoot, "example/react/pages");
19
- const htmlDir = join(projectRoot, "example/html");
20
-
21
- export const build = async () => {
12
+ type BuildConfig = {
13
+ buildDir?: string;
14
+ assetsDir?: string;
15
+ reactIndexDir?: string;
16
+ javascriptDir?: string;
17
+ typeScriptDir?: string;
18
+ reactPagesDir?: string;
19
+ htmlDir?: string;
20
+ }
21
+
22
+ export const build = async ({
23
+ buildDir = "build",
24
+ assetsDir = "src/backend/assets",
25
+ reactIndexDir = "src/frontend/react/indexes",
26
+ javascriptDir = "src/frontend/javascript",
27
+ typeScriptDir = "src/frontend/typescript",
28
+ reactPagesDir = "src/frontend/react/pages",
29
+ htmlDir = "src/frontend/html"
30
+ }:BuildConfig = {}) => {
22
31
  const start = performance.now();
23
-
24
- await rm(buildDir, { force: true, recursive: true });
25
- await generateReactIndexFiles();
32
+
33
+ const projectRoot = cwd();
34
+ const buildDirAbsolute = join(projectRoot, buildDir);
35
+ const assetsDirAbsolute = join(projectRoot, assetsDir);
36
+ const reactIndexDirAbsolute = join(projectRoot, reactIndexDir);
37
+ const javascriptDirAbsolute = join(projectRoot, javascriptDir);
38
+ const typeScriptDirAbsolute = join(projectRoot, typeScriptDir);
39
+ const reactPagesDirAbsolute = join(projectRoot, reactPagesDir);
40
+ const htmlDirAbsolute = join(projectRoot, htmlDir);
41
+
42
+ await rm(buildDirAbsolute, { force: true, recursive: true });
43
+ await generateReactIndexFiles(
44
+ reactPagesDirAbsolute,
45
+ reactIndexDirAbsolute
46
+ );
26
47
 
27
48
  const reactEntryGlob = new Glob("*.{tsx,jsx}");
28
49
  const reactEntryPaths: string[] = [];
29
50
  for await (const file of reactEntryGlob.scan({
30
51
  absolute: true,
31
- cwd: reactIndexDir
52
+ cwd: reactIndexDirAbsolute
32
53
  })) {
33
54
  reactEntryPaths.push(file);
34
55
  }
@@ -37,7 +58,7 @@ export const build = async () => {
37
58
  const javascriptEntryPaths: string[] = [];
38
59
  for await (const file of javascriptEntryGlob.scan({
39
60
  absolute: true,
40
- cwd: javascriptDir
61
+ cwd: javascriptDirAbsolute
41
62
  })) {
42
63
  javascriptEntryPaths.push(file);
43
64
  }
@@ -46,7 +67,7 @@ export const build = async () => {
46
67
  const typeScriptEntryPaths: string[] = [];
47
68
  for await (const file of typeScriptEntryGlob.scan({
48
69
  absolute: true,
49
- cwd: typeScriptDir
70
+ cwd: typeScriptDirAbsolute
50
71
  })) {
51
72
  typeScriptEntryPaths.push(file);
52
73
  }
@@ -58,7 +79,7 @@ export const build = async () => {
58
79
  entrypoints: entryPaths,
59
80
  format: "esm",
60
81
  naming: `[dir]/[name].[hash].[ext]`,
61
- outdir: buildDir
82
+ outdir: buildDirAbsolute
62
83
  }).catch((error) => {
63
84
  console.error("Build failed:", error);
64
85
  exit(1);
@@ -71,14 +92,17 @@ export const build = async () => {
71
92
  console.info(log);
72
93
  });
73
94
 
74
- await copyAssetsToBuildDir();
95
+ await copyAssetsTobuildDirAbsolute(
96
+ assetsDirAbsolute,
97
+ buildDirAbsolute,
98
+ projectRoot
99
+ );
75
100
 
76
- // TODO: Find a way to make this type-safe instead of string as the key it should be enumerated with the names of the files
77
101
  const manifest = outputs.reduce<Record<string, string>>((acc, artifact) => {
78
102
  let relativePath = artifact.path;
79
103
 
80
- if (relativePath.startsWith(buildDir)) {
81
- relativePath = relativePath.slice(buildDir.length);
104
+ if (relativePath.startsWith(buildDirAbsolute)) {
105
+ relativePath = relativePath.slice(buildDirAbsolute.length);
82
106
  }
83
107
 
84
108
  relativePath = relativePath.replace(/^\/+/, "");
@@ -98,7 +122,7 @@ export const build = async () => {
98
122
  return acc;
99
123
  }, {});
100
124
 
101
- await updateScriptTags(manifest, htmlDir);
125
+ await updateScriptTags(manifest, htmlDirAbsolute);
102
126
 
103
127
  const end = performance.now();
104
128
  const durationMs = end - start;
@@ -112,28 +136,32 @@ export const build = async () => {
112
136
  }
113
137
  console.log(`Build completed in ${duration}`);
114
138
 
115
- console.log("Outputs:", outputs);
116
- console.log("Manifest:", manifest);
117
-
118
139
  return manifest;
119
140
  };
120
141
 
121
- const copyAssetsToBuildDir = async () => {
122
- await $`cp -R ${assetsDir} ${buildDir}`;
123
- await mkdir(join(buildDir, "html"));
124
- await mkdir(join(buildDir, "htmx"));
125
-
126
- await $`cp -R ${join(projectRoot, "example/html")} ${join(buildDir)}`;
127
- await $`cp -R ${join(projectRoot, "example/htmx")} ${join(buildDir)}`;
142
+ const copyAssetsTobuildDirAbsolute = async (
143
+ assetsDirAbsolute: string,
144
+ buildDirAbsolute: string,
145
+ projectRoot: string
146
+ ) => {
147
+ await $`cp -R ${assetsDirAbsolute} ${buildDirAbsolute}`;
148
+ await mkdir(join(buildDirAbsolute, "html"));
149
+ await mkdir(join(buildDirAbsolute, "htmx"));
150
+
151
+ await $`cp -R ${join(projectRoot, "example/html")} ${join(buildDirAbsolute)}`;
152
+ await $`cp -R ${join(projectRoot, "example/htmx")} ${join(buildDirAbsolute)}`;
128
153
  };
129
154
 
130
- const generateReactIndexFiles = async () => {
131
- await rm(reactIndexDir, { force: true, recursive: true });
132
- await mkdir(reactIndexDir);
155
+ const generateReactIndexFiles = async (
156
+ reactPagesDirAbsolute: string,
157
+ reactIndexDirAbsolute: string
158
+ ) => {
159
+ await rm(reactIndexDirAbsolute, { force: true, recursive: true });
160
+ await mkdir(reactIndexDirAbsolute);
133
161
 
134
162
  const pagesGlob = new Glob("*.*");
135
163
  const files: string[] = [];
136
- for await (const file of pagesGlob.scan({ cwd: reactPagesDir })) {
164
+ for await (const file of pagesGlob.scan({ cwd: reactPagesDirAbsolute })) {
137
165
  files.push(file);
138
166
  }
139
167
  const promises = files.map(async (file) => {
@@ -146,7 +174,7 @@ const generateReactIndexFiles = async () => {
146
174
  ].join("\n");
147
175
 
148
176
  return writeFile(
149
- join(reactIndexDir, `${componentName}Index.tsx`),
177
+ join(reactIndexDirAbsolute, `${componentName}Index.tsx`),
150
178
  content
151
179
  );
152
180
  });
package/tsconfig.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "ESNext",
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
4
  "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "jsx": "react-jsx",
7
- "esModuleInterop": true,
8
- "forceConsistentCasingInFileNames": true,
9
- "outDir": "dist",
10
- "strict": true,
11
- "declaration": true,
12
- "skipLibCheck": true,
13
- "lib": ["DOM", "DOM.Iterable", "ESNext"],
14
- },
15
- "include": ["src/**/*", "example/**/*"],
16
- "exclude": ["node_modules"]
5
+ "moduleResolution": "bundler",
6
+ "jsx": "react-jsx",
7
+ "esModuleInterop": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "outDir": "dist",
10
+ "strict": true,
11
+ "declaration": true,
12
+ "skipLibCheck": true,
13
+ "lib": ["DOM", "DOM.Iterable", "ESNext"]
14
+ },
15
+ "include": ["src/**/*", "example/**/*"],
16
+ "exclude": ["node_modules"]
17
17
  }
@@ -1,2 +0,0 @@
1
- var _=1000,N=60000;var I=2,S=3000;
2
- export{_ as b,N as c,I as d,S as e};
@@ -1,2 +0,0 @@
1
- var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var k=(a,b,c)=>{c=a!=null?g(h(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var l=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);
2
- export{k as h,l as i};
@@ -1,2 +0,0 @@
1
- var _=1000,N=60000;var I=2,S=3000;
2
- export{_ as e,N as f,I as g,S as h};
@@ -1,2 +0,0 @@
1
- var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var k=(a,b,c)=>{c=a!=null?g(h(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var l=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);
2
- export{k,l};
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{b as C,c as T,d as F}from"../build-241dg605.js";import{g as M}from"../utils/updateScriptTags.js";import"../build-azzc5a4m.js";import{rm as _,mkdir as v,writeFile as g}from"node:fs/promises";import{join as z,basename as f}from"node:path";import{exit as E}from"node:process";var{$:L,build:b,Glob:$}=globalThis.Bun;var J=z(import.meta.dir,"..",".."),H=z(J,"example/build"),N=z(J,"example/assets"),k=z(J,"example/react/indexes"),h=z(J,"example/javascript"),j=z(J,"example/typescript"),I=z(J,"example/react/pages"),D=z(J,"example/html"),o=async()=>{let A=performance.now();await _(H,{force:!0,recursive:!0}),await m();let X=new $("*.{tsx,jsx}"),Y=[];for await(let q of X.scan({absolute:!0,cwd:k}))Y.push(q);let V=new $("*.js"),Z=[];for await(let q of V.scan({absolute:!0,cwd:h}))Z.push(q);let Q=new $("*.ts"),B=[];for await(let q of Q.scan({absolute:!0,cwd:j}))B.push(q);let y=Y.concat(Z).concat(B),{logs:P,outputs:O}=await b({entrypoints:y,format:"esm",naming:"[dir]/[name].[hash].[ext]",outdir:H}).catch((q)=>{console.error("Build failed:",q),E(1)});P.forEach((q)=>{if(q.level==="error")console.error(q);else if(q.level==="warning")console.warn(q);else if(q.level==="info"||q.level==="debug")console.info(q)}),await u();let x=O.reduce((q,R)=>{let K=R.path;if(K.startsWith(H))K=K.slice(H.length);K=K.replace(/^\/+/,"");let w=K.split("/").pop();if(!w)return q;let G=`.${R.hash}.`;if(!w.includes(G))throw new Error(`Expected hash delimiter ${G} in ${w}`);let[S]=w.split(G);return q[S]="/"+K,q},{});await M(x,D);let W=performance.now()-A,U;if(W<C)U=`${W.toFixed(F)}ms`;else if(W<T)U=`${(W/C).toFixed(F)}s`;else U=`${(W/T).toFixed(F)}m`;return console.log(`Build completed in ${U}`),console.log("Outputs:",O),console.log("Manifest:",x),x},u=async()=>{await L`cp -R ${N} ${H}`,await v(z(H,"html")),await v(z(H,"htmx")),await L`cp -R ${z(J,"example/html")} ${z(H)}`,await L`cp -R ${z(J,"example/htmx")} ${z(H)}`},m=async()=>{await _(k,{force:!0,recursive:!0}),await v(k);let A=new $("*.*"),X=[];for await(let V of A.scan({cwd:I}))X.push(V);let Y=X.map(async(V)=>{let Z=f(V),[Q]=Z.split("."),B=["import { hydrateRoot } from 'react-dom/client';",`import { ${Q} } from '../pages/${Q}';
3
- `,`hydrateRoot(document, <${Q} />);`].join(`
4
- `);return g(z(k,`${Q}Index.tsx`),B)});await Promise.all(Y)};export{o as build};
5
- export{o as a};