@absolutejs/absolute 0.1.13 → 0.1.15
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 +77 -77
- package/dist/src/core/build.d.ts +2 -1
- package/package.json +1 -1
- package/src/core/build.ts +22 -47
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
|
|
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,16 +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("buildDirAbsolute:", buildDirAbsolute);
|
|
58
|
-
console.log("assetsDirAbsolute:", assetsDirAbsolute);
|
|
59
|
-
console.log("reactIndexDirAbsolute:", reactIndexDirAbsolute);
|
|
60
|
-
console.log("javascriptDirAbsolute:", javascriptDirAbsolute);
|
|
61
|
-
console.log("typeScriptDirAbsolute:", typeScriptDirAbsolute);
|
|
62
|
-
console.log("reactPagesDirAbsolute:", reactPagesDirAbsolute);
|
|
63
|
-
console.log("htmlDirAbsolute:", htmlDirAbsolute);
|
|
64
|
-
|
|
65
|
-
console.log("Cleaning build directory");
|
|
66
49
|
await rm(buildDirAbsolute, { force: true, recursive: true });
|
|
67
50
|
await mkdir(buildDirAbsolute);
|
|
68
51
|
|
|
@@ -103,9 +86,11 @@ export const build = async ({
|
|
|
103
86
|
.concat(javascriptEntryPaths)
|
|
104
87
|
.concat(typeScriptEntryPaths);
|
|
105
88
|
|
|
106
|
-
|
|
89
|
+
if (entryPaths.length === 0) {
|
|
90
|
+
console.warn("No entry points found, skipping build");
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
107
93
|
|
|
108
|
-
console.log("Building entry points");
|
|
109
94
|
const { logs, outputs } = await bunBuild({
|
|
110
95
|
entrypoints: entryPaths,
|
|
111
96
|
format: "esm",
|
|
@@ -123,14 +108,19 @@ export const build = async ({
|
|
|
123
108
|
console.info(log);
|
|
124
109
|
});
|
|
125
110
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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, "html")}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (htmxDirAbsolute) {
|
|
120
|
+
await mkdir(join(buildDirAbsolute, "htmx"));
|
|
121
|
+
await $`cp -R ${htmxDirAbsolute} ${join(buildDirAbsolute, "htmx")}`;
|
|
122
|
+
}
|
|
132
123
|
|
|
133
|
-
console.log("Generating manifest");
|
|
134
124
|
const manifest = outputs.reduce<Record<string, string>>((acc, artifact) => {
|
|
135
125
|
let relativePath = artifact.path;
|
|
136
126
|
|
|
@@ -172,25 +162,10 @@ export const build = async ({
|
|
|
172
162
|
return manifest;
|
|
173
163
|
};
|
|
174
164
|
|
|
175
|
-
const copyAssetsTobuildDirAbsolute = async (
|
|
176
|
-
assetsDirAbsolute: string,
|
|
177
|
-
buildDirAbsolute: string,
|
|
178
|
-
projectRoot: string
|
|
179
|
-
) => {
|
|
180
|
-
await $`cp -R ${assetsDirAbsolute} ${buildDirAbsolute}`;
|
|
181
|
-
await mkdir(join(buildDirAbsolute, "html"));
|
|
182
|
-
await mkdir(join(buildDirAbsolute, "htmx"));
|
|
183
|
-
|
|
184
|
-
await $`cp -R ${join(projectRoot, "example/html")} ${join(buildDirAbsolute)}`;
|
|
185
|
-
await $`cp -R ${join(projectRoot, "example/htmx")} ${join(buildDirAbsolute)}`;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
165
|
const generateReactIndexFiles = async (
|
|
189
166
|
reactPagesDirAbsolute: string,
|
|
190
167
|
reactIndexDirAbsolute: string
|
|
191
168
|
) => {
|
|
192
|
-
console.log("Generating React index files");
|
|
193
|
-
|
|
194
169
|
await rm(reactIndexDirAbsolute, { force: true, recursive: true });
|
|
195
170
|
await mkdir(reactIndexDirAbsolute);
|
|
196
171
|
|