@absolutejs/absolute 0.1.6 → 0.1.8
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 +75 -75
- package/package.json +1 -1
- package/src/core/build.ts +21 -12
package/package.json
CHANGED
package/src/core/build.ts
CHANGED
|
@@ -22,25 +22,31 @@ type BuildConfig = {
|
|
|
22
22
|
export const build = async ({
|
|
23
23
|
buildDir = "build",
|
|
24
24
|
assetsDir = "src/backend/assets",
|
|
25
|
-
reactIndexDir
|
|
26
|
-
javascriptDir
|
|
27
|
-
typeScriptDir
|
|
28
|
-
reactPagesDir
|
|
29
|
-
htmlDir
|
|
25
|
+
reactIndexDir,
|
|
26
|
+
javascriptDir,
|
|
27
|
+
typeScriptDir,
|
|
28
|
+
reactPagesDir,
|
|
29
|
+
htmlDir
|
|
30
30
|
}:BuildConfig = {}) => {
|
|
31
31
|
const start = performance.now();
|
|
32
|
+
console.log("Building start");
|
|
32
33
|
|
|
34
|
+
console.log("Creating build directory");
|
|
33
35
|
const projectRoot = cwd();
|
|
34
36
|
const buildDirAbsolute = join(projectRoot, buildDir);
|
|
35
37
|
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);
|
|
38
|
+
const reactIndexDirAbsolute = reactIndexDir && join(projectRoot, reactIndexDir)
|
|
39
|
+
const javascriptDirAbsolute = javascriptDir && join(projectRoot, javascriptDir);
|
|
40
|
+
const typeScriptDirAbsolute = typeScriptDir && join(projectRoot, typeScriptDir);
|
|
41
|
+
const reactPagesDirAbsolute = reactPagesDir && join(projectRoot, reactPagesDir);
|
|
42
|
+
const htmlDirAbsolute = htmlDir && join(projectRoot, htmlDir);
|
|
41
43
|
|
|
44
|
+
console.log("Cleaning build directory");
|
|
42
45
|
await rm(buildDirAbsolute, { force: true, recursive: true });
|
|
43
|
-
await
|
|
46
|
+
await mkdir(buildDirAbsolute);
|
|
47
|
+
|
|
48
|
+
console.log("Generating React index files");
|
|
49
|
+
(reactPagesDirAbsolute && reactIndexDirAbsolute) && await generateReactIndexFiles(
|
|
44
50
|
reactPagesDirAbsolute,
|
|
45
51
|
reactIndexDirAbsolute
|
|
46
52
|
);
|
|
@@ -75,6 +81,7 @@ export const build = async ({
|
|
|
75
81
|
.concat(javascriptEntryPaths)
|
|
76
82
|
.concat(typeScriptEntryPaths);
|
|
77
83
|
|
|
84
|
+
console.log("Building entry points");
|
|
78
85
|
const { logs, outputs } = await bunBuild({
|
|
79
86
|
entrypoints: entryPaths,
|
|
80
87
|
format: "esm",
|
|
@@ -92,12 +99,14 @@ export const build = async ({
|
|
|
92
99
|
console.info(log);
|
|
93
100
|
});
|
|
94
101
|
|
|
102
|
+
console.log("Copying assets to build directory");
|
|
95
103
|
await copyAssetsTobuildDirAbsolute(
|
|
96
104
|
assetsDirAbsolute,
|
|
97
105
|
buildDirAbsolute,
|
|
98
106
|
projectRoot
|
|
99
107
|
);
|
|
100
108
|
|
|
109
|
+
console.log("Generating manifest");
|
|
101
110
|
const manifest = outputs.reduce<Record<string, string>>((acc, artifact) => {
|
|
102
111
|
let relativePath = artifact.path;
|
|
103
112
|
|
|
@@ -122,7 +131,7 @@ export const build = async ({
|
|
|
122
131
|
return acc;
|
|
123
132
|
}, {});
|
|
124
133
|
|
|
125
|
-
await updateScriptTags(manifest, htmlDirAbsolute);
|
|
134
|
+
htmlDirAbsolute && await updateScriptTags(manifest, htmlDirAbsolute);
|
|
126
135
|
|
|
127
136
|
const end = performance.now();
|
|
128
137
|
const durationMs = end - start;
|