@absolutejs/absolute 0.1.14 → 0.1.16
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/dist/index.js +79 -79
- package/dist/src/core/build.d.ts +2 -1
- package/package.json +1 -1
- package/src/core/build.ts +18 -49
package/dist/src/core/build.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type BuildConfig = {
|
|
|
6
6
|
typeScriptDir?: string;
|
|
7
7
|
reactPagesDir?: string;
|
|
8
8
|
htmlDir?: string;
|
|
9
|
+
htmxDir?: string;
|
|
9
10
|
};
|
|
10
|
-
export declare const build: ({ buildDir, assetsDir, reactIndexDir, javascriptDir, typeScriptDir, reactPagesDir, htmlDir }?: BuildConfig) => Promise<Record<string, string> | null>;
|
|
11
|
+
export declare const build: ({ buildDir, assetsDir, reactIndexDir, javascriptDir, typeScriptDir, reactPagesDir, htmlDir, htmxDir }?: BuildConfig) => Promise<Record<string, string> | null>;
|
|
11
12
|
export {};
|
package/package.json
CHANGED
package/src/core/build.ts
CHANGED
|
@@ -17,33 +17,24 @@ type BuildConfig = {
|
|
|
17
17
|
typeScriptDir?: string;
|
|
18
18
|
reactPagesDir?: string;
|
|
19
19
|
htmlDir?: string;
|
|
20
|
+
htmxDir?: string;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
export const build = async ({
|
|
23
24
|
buildDir = "build",
|
|
24
|
-
assetsDir
|
|
25
|
+
assetsDir,
|
|
25
26
|
reactIndexDir,
|
|
26
27
|
javascriptDir,
|
|
27
28
|
typeScriptDir,
|
|
28
29
|
reactPagesDir,
|
|
29
|
-
htmlDir
|
|
30
|
+
htmlDir,
|
|
31
|
+
htmxDir
|
|
30
32
|
}: BuildConfig = {}) => {
|
|
31
33
|
const start = performance.now();
|
|
32
|
-
console.log("Building start");
|
|
33
|
-
console.log("Build config", {
|
|
34
|
-
buildDir,
|
|
35
|
-
assetsDir,
|
|
36
|
-
reactIndexDir,
|
|
37
|
-
javascriptDir,
|
|
38
|
-
typeScriptDir,
|
|
39
|
-
reactPagesDir,
|
|
40
|
-
htmlDir
|
|
41
|
-
});
|
|
42
34
|
|
|
43
|
-
console.log("Creating build directory");
|
|
44
35
|
const projectRoot = cwd();
|
|
45
36
|
const buildDirAbsolute = join(projectRoot, buildDir);
|
|
46
|
-
const assetsDirAbsolute = join(projectRoot, assetsDir);
|
|
37
|
+
const assetsDirAbsolute = assetsDir && join(projectRoot, assetsDir);
|
|
47
38
|
const reactIndexDirAbsolute =
|
|
48
39
|
reactIndexDir && join(projectRoot, reactIndexDir);
|
|
49
40
|
const javascriptDirAbsolute =
|
|
@@ -53,17 +44,8 @@ export const build = async ({
|
|
|
53
44
|
const reactPagesDirAbsolute =
|
|
54
45
|
reactPagesDir && join(projectRoot, reactPagesDir);
|
|
55
46
|
const htmlDirAbsolute = htmlDir && join(projectRoot, htmlDir);
|
|
47
|
+
const htmxDirAbsolute = htmxDir && join(projectRoot, htmxDir);
|
|
56
48
|
|
|
57
|
-
console.log("projectRoot:", projectRoot);
|
|
58
|
-
console.log("buildDirAbsolute:", buildDirAbsolute);
|
|
59
|
-
console.log("assetsDirAbsolute:", assetsDirAbsolute);
|
|
60
|
-
console.log("reactIndexDirAbsolute:", reactIndexDirAbsolute);
|
|
61
|
-
console.log("javascriptDirAbsolute:", javascriptDirAbsolute);
|
|
62
|
-
console.log("typeScriptDirAbsolute:", typeScriptDirAbsolute);
|
|
63
|
-
console.log("reactPagesDirAbsolute:", reactPagesDirAbsolute);
|
|
64
|
-
console.log("htmlDirAbsolute:", htmlDirAbsolute);
|
|
65
|
-
|
|
66
|
-
console.log("Cleaning build directory");
|
|
67
49
|
await rm(buildDirAbsolute, { force: true, recursive: true });
|
|
68
50
|
await mkdir(buildDirAbsolute);
|
|
69
51
|
|
|
@@ -104,14 +86,11 @@ export const build = async ({
|
|
|
104
86
|
.concat(javascriptEntryPaths)
|
|
105
87
|
.concat(typeScriptEntryPaths);
|
|
106
88
|
|
|
107
|
-
console.log("Entry points", entryPaths);
|
|
108
|
-
|
|
109
89
|
if (entryPaths.length === 0) {
|
|
110
90
|
console.warn("No entry points found, skipping build");
|
|
111
91
|
return null;
|
|
112
92
|
}
|
|
113
93
|
|
|
114
|
-
console.log("Building entry points");
|
|
115
94
|
const { logs, outputs } = await bunBuild({
|
|
116
95
|
entrypoints: entryPaths,
|
|
117
96
|
format: "esm",
|
|
@@ -129,14 +108,19 @@ export const build = async ({
|
|
|
129
108
|
console.info(log);
|
|
130
109
|
});
|
|
131
110
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
111
|
+
assetsDirAbsolute &&
|
|
112
|
+
(await $`cp -R ${assetsDirAbsolute} ${buildDirAbsolute}`);
|
|
113
|
+
|
|
114
|
+
if (htmlDirAbsolute) {
|
|
115
|
+
await mkdir(join(buildDirAbsolute, "html"));
|
|
116
|
+
await $`cp -R ${htmlDirAbsolute} ${join(buildDirAbsolute)}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (htmxDirAbsolute) {
|
|
120
|
+
await mkdir(join(buildDirAbsolute, "htmx"));
|
|
121
|
+
await $`cp -R ${htmxDirAbsolute} ${join(buildDirAbsolute)}`;
|
|
122
|
+
}
|
|
138
123
|
|
|
139
|
-
console.log("Generating manifest");
|
|
140
124
|
const manifest = outputs.reduce<Record<string, string>>((acc, artifact) => {
|
|
141
125
|
let relativePath = artifact.path;
|
|
142
126
|
|
|
@@ -178,25 +162,10 @@ export const build = async ({
|
|
|
178
162
|
return manifest;
|
|
179
163
|
};
|
|
180
164
|
|
|
181
|
-
const copyAssetsTobuildDirAbsolute = async (
|
|
182
|
-
assetsDirAbsolute: string,
|
|
183
|
-
buildDirAbsolute: string,
|
|
184
|
-
projectRoot: string
|
|
185
|
-
) => {
|
|
186
|
-
await $`cp -R ${assetsDirAbsolute} ${buildDirAbsolute}`;
|
|
187
|
-
await mkdir(join(buildDirAbsolute, "html"));
|
|
188
|
-
await mkdir(join(buildDirAbsolute, "htmx"));
|
|
189
|
-
|
|
190
|
-
await $`cp -R ${join(projectRoot, "example/html")} ${join(buildDirAbsolute)}`;
|
|
191
|
-
await $`cp -R ${join(projectRoot, "example/htmx")} ${join(buildDirAbsolute)}`;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
165
|
const generateReactIndexFiles = async (
|
|
195
166
|
reactPagesDirAbsolute: string,
|
|
196
167
|
reactIndexDirAbsolute: string
|
|
197
168
|
) => {
|
|
198
|
-
console.log("Generating React index files");
|
|
199
|
-
|
|
200
169
|
await rm(reactIndexDirAbsolute, { force: true, recursive: true });
|
|
201
170
|
await mkdir(reactIndexDirAbsolute);
|
|
202
171
|
|