@ereo/bundler 0.2.29 → 0.2.36
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/dev/hmr.d.ts.map +1 -1
- package/dist/index.js +83 -64
- package/dist/plugins/islands.d.ts.map +1 -1
- package/dist/prod/build.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/dev/hmr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../../src/dev/hmr.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAU,eAAe,EAAE,MAAM,KAAK,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,YAAY,GACZ,WAAW,GACX,eAAe,GACf,eAAe,GACf,kBAAkB,GAClB,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,8BAA8B;IAC9B,MAAM,CAAC,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;IACF,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,qDAAqD;IACrD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,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MAAM,GAAG,IAAI;IAqCxB;;OAEG;YACW,qBAAqB;IAmEnC;;OAEG;IACH,IAAI,IAAI,IAAI;CAOb;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,GAAG,UAAU,CAE3D"}
|
package/dist/index.js
CHANGED
|
@@ -265,13 +265,17 @@ class HMRServer {
|
|
|
265
265
|
send(update) {
|
|
266
266
|
this.lastUpdate = update;
|
|
267
267
|
const message = JSON.stringify(update);
|
|
268
|
+
const failed = [];
|
|
268
269
|
for (const client of this.clients) {
|
|
269
270
|
try {
|
|
270
271
|
client.send(message);
|
|
271
272
|
} catch {
|
|
272
|
-
|
|
273
|
+
failed.push(client);
|
|
273
274
|
}
|
|
274
275
|
}
|
|
276
|
+
for (const client of failed) {
|
|
277
|
+
this.clients.delete(client);
|
|
278
|
+
}
|
|
275
279
|
}
|
|
276
280
|
reload(reason) {
|
|
277
281
|
this.send({
|
|
@@ -821,12 +825,11 @@ var ERROR_OVERLAY_SCRIPT = `
|
|
|
821
825
|
</script>
|
|
822
826
|
`;
|
|
823
827
|
// src/prod/build.ts
|
|
824
|
-
import { join
|
|
828
|
+
import { join, relative, dirname, basename, extname } from "path";
|
|
825
829
|
import { mkdir, rm, readdir, stat, copyFile } from "fs/promises";
|
|
826
830
|
import { initFileRouter } from "@ereo/router";
|
|
827
831
|
|
|
828
832
|
// src/plugins/islands.ts
|
|
829
|
-
import { basename } from "path";
|
|
830
833
|
var ISLAND_DIRECTIVE_PATTERN = /client:(load|idle|visible|media)(?:="([^"]+)")?/g;
|
|
831
834
|
var COMPONENT_EXPORT_PATTERN = /export\s+(?:default\s+)?(?:function|const|class)\s+(\w+)/g;
|
|
832
835
|
var USE_CLIENT_PATTERN = /^['"]use client['"]/m;
|
|
@@ -834,6 +837,7 @@ function extractIslands(content, filePath) {
|
|
|
834
837
|
const islands = [];
|
|
835
838
|
const isClientComponent = USE_CLIENT_PATTERN.test(content);
|
|
836
839
|
if (!isClientComponent) {
|
|
840
|
+
ISLAND_DIRECTIVE_PATTERN.lastIndex = 0;
|
|
837
841
|
const hasDirectives = ISLAND_DIRECTIVE_PATTERN.test(content);
|
|
838
842
|
if (!hasDirectives) {
|
|
839
843
|
return islands;
|
|
@@ -845,7 +849,6 @@ function extractIslands(content, filePath) {
|
|
|
845
849
|
while ((match = COMPONENT_EXPORT_PATTERN.exec(content)) !== null) {
|
|
846
850
|
componentNames.push(match[1]);
|
|
847
851
|
}
|
|
848
|
-
const fileName = basename(filePath, ".tsx").replace(".ts", "");
|
|
849
852
|
if (isClientComponent && componentNames.length > 0) {
|
|
850
853
|
islands.push({
|
|
851
854
|
id: generateIslandId(filePath),
|
|
@@ -862,8 +865,9 @@ function generateIslandId(filePath) {
|
|
|
862
865
|
}
|
|
863
866
|
function transformIslandJSX(code) {
|
|
864
867
|
let transformed = code;
|
|
868
|
+
let counter = 0;
|
|
865
869
|
transformed = transformed.replace(/<(\w+)\s+([^>]*client:(load|idle|visible|media)[^>]*)>/g, (match, tag, props, strategy) => {
|
|
866
|
-
const id = `island-${
|
|
870
|
+
const id = `island-${tag}-${counter++}`;
|
|
867
871
|
return `<${tag} data-island="${id}" data-strategy="${strategy}" ${props}>`;
|
|
868
872
|
});
|
|
869
873
|
return transformed;
|
|
@@ -905,9 +909,12 @@ initializeIslands();
|
|
|
905
909
|
`.trim();
|
|
906
910
|
}
|
|
907
911
|
function createIslandsPlugin() {
|
|
908
|
-
|
|
912
|
+
let islands = [];
|
|
909
913
|
return {
|
|
910
914
|
name: "ereo:islands",
|
|
915
|
+
buildStart() {
|
|
916
|
+
islands = [];
|
|
917
|
+
},
|
|
911
918
|
transform(code, id) {
|
|
912
919
|
if (!id.endsWith(".tsx") && !id.endsWith(".jsx")) {
|
|
913
920
|
return null;
|
|
@@ -935,6 +942,7 @@ function findIslandByName(islands, name) {
|
|
|
935
942
|
return islands.find((i) => i.name === name);
|
|
936
943
|
}
|
|
937
944
|
function hasIslands(content) {
|
|
945
|
+
ISLAND_DIRECTIVE_PATTERN.lastIndex = 0;
|
|
938
946
|
return USE_CLIENT_PATTERN.test(content) || ISLAND_DIRECTIVE_PATTERN.test(content);
|
|
939
947
|
}
|
|
940
948
|
|
|
@@ -966,7 +974,7 @@ var DEFAULT_ASSET_EXTENSIONS = [
|
|
|
966
974
|
async function build(options = {}) {
|
|
967
975
|
const startTime = performance.now();
|
|
968
976
|
const root = options.root || process.cwd();
|
|
969
|
-
const outDir = options.outDir ||
|
|
977
|
+
const outDir = options.outDir || join(root, ".ereo");
|
|
970
978
|
const minify = options.minify ?? true;
|
|
971
979
|
const sourcemap = options.sourcemap ?? true;
|
|
972
980
|
const splitting = options.splitting ?? true;
|
|
@@ -990,7 +998,7 @@ async function build(options = {}) {
|
|
|
990
998
|
}
|
|
991
999
|
}
|
|
992
1000
|
const router = await initFileRouter({
|
|
993
|
-
routesDir:
|
|
1001
|
+
routesDir: join(root, "app/routes")
|
|
994
1002
|
});
|
|
995
1003
|
const routes = router.getRoutes();
|
|
996
1004
|
const routeCount = countRoutes(routes);
|
|
@@ -1007,7 +1015,7 @@ async function build(options = {}) {
|
|
|
1007
1015
|
Building server bundle...`);
|
|
1008
1016
|
const serverResult = await buildServer({
|
|
1009
1017
|
root,
|
|
1010
|
-
outDir:
|
|
1018
|
+
outDir: join(outDir, "server"),
|
|
1011
1019
|
routes,
|
|
1012
1020
|
minify,
|
|
1013
1021
|
sourcemap,
|
|
@@ -1024,7 +1032,7 @@ async function build(options = {}) {
|
|
|
1024
1032
|
Building client bundle...`);
|
|
1025
1033
|
const clientResult = await buildClient({
|
|
1026
1034
|
root,
|
|
1027
|
-
outDir:
|
|
1035
|
+
outDir: join(outDir, "client"),
|
|
1028
1036
|
routes,
|
|
1029
1037
|
minify,
|
|
1030
1038
|
sourcemap,
|
|
@@ -1041,7 +1049,7 @@ async function build(options = {}) {
|
|
|
1041
1049
|
Building island bundles...`);
|
|
1042
1050
|
const islandResult = await buildIslands({
|
|
1043
1051
|
root,
|
|
1044
|
-
outDir:
|
|
1052
|
+
outDir: join(outDir, "client/islands"),
|
|
1045
1053
|
islands,
|
|
1046
1054
|
minify,
|
|
1047
1055
|
sourcemap,
|
|
@@ -1058,7 +1066,7 @@ async function build(options = {}) {
|
|
|
1058
1066
|
Building CSS bundle...`);
|
|
1059
1067
|
const cssResult = await buildCSS({
|
|
1060
1068
|
root,
|
|
1061
|
-
outDir:
|
|
1069
|
+
outDir: join(outDir, "assets"),
|
|
1062
1070
|
cssFiles,
|
|
1063
1071
|
minify,
|
|
1064
1072
|
sourcemap,
|
|
@@ -1074,7 +1082,7 @@ async function build(options = {}) {
|
|
|
1074
1082
|
Copying static assets...`);
|
|
1075
1083
|
const assetResult = await copyAssets({
|
|
1076
1084
|
root,
|
|
1077
|
-
outDir:
|
|
1085
|
+
outDir: join(outDir, "assets"),
|
|
1078
1086
|
extensions: assetExtensions
|
|
1079
1087
|
});
|
|
1080
1088
|
allOutputs.push(...assetResult.outputs);
|
|
@@ -1127,12 +1135,12 @@ function generateBuildId() {
|
|
|
1127
1135
|
async function cleanAndCreateDirs(outDir) {
|
|
1128
1136
|
await rm(outDir, { recursive: true, force: true });
|
|
1129
1137
|
await mkdir(outDir, { recursive: true });
|
|
1130
|
-
await mkdir(
|
|
1131
|
-
await mkdir(
|
|
1132
|
-
await mkdir(
|
|
1133
|
-
await mkdir(
|
|
1134
|
-
await mkdir(
|
|
1135
|
-
await mkdir(
|
|
1138
|
+
await mkdir(join(outDir, "server"), { recursive: true });
|
|
1139
|
+
await mkdir(join(outDir, "server/routes"), { recursive: true });
|
|
1140
|
+
await mkdir(join(outDir, "client"), { recursive: true });
|
|
1141
|
+
await mkdir(join(outDir, "client/islands"), { recursive: true });
|
|
1142
|
+
await mkdir(join(outDir, "client/chunks"), { recursive: true });
|
|
1143
|
+
await mkdir(join(outDir, "assets"), { recursive: true });
|
|
1136
1144
|
}
|
|
1137
1145
|
function countRoutes(routes) {
|
|
1138
1146
|
let count = 0;
|
|
@@ -1164,7 +1172,7 @@ async function extractAllIslands(root, routes) {
|
|
|
1164
1172
|
}
|
|
1165
1173
|
}
|
|
1166
1174
|
};
|
|
1167
|
-
const componentsDir =
|
|
1175
|
+
const componentsDir = join(root, "app/components");
|
|
1168
1176
|
try {
|
|
1169
1177
|
const componentFiles = await scanForFiles(componentsDir, [".tsx", ".jsx"]);
|
|
1170
1178
|
for (const file of componentFiles) {
|
|
@@ -1190,7 +1198,7 @@ async function scanForFiles(dir, extensions) {
|
|
|
1190
1198
|
try {
|
|
1191
1199
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
1192
1200
|
for (const entry of entries) {
|
|
1193
|
-
const fullPath =
|
|
1201
|
+
const fullPath = join(dir, entry.name);
|
|
1194
1202
|
if (entry.isDirectory()) {
|
|
1195
1203
|
const subFiles = await scanForFiles(fullPath, extensions);
|
|
1196
1204
|
files.push(...subFiles);
|
|
@@ -1207,9 +1215,9 @@ async function scanForFiles(dir, extensions) {
|
|
|
1207
1215
|
async function collectCSSFiles(root) {
|
|
1208
1216
|
const cssFiles = [];
|
|
1209
1217
|
const dirsToScan = [
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1218
|
+
join(root, "app"),
|
|
1219
|
+
join(root, "styles"),
|
|
1220
|
+
join(root, "src")
|
|
1213
1221
|
];
|
|
1214
1222
|
for (const dir of dirsToScan) {
|
|
1215
1223
|
try {
|
|
@@ -1234,7 +1242,7 @@ async function buildServer(options) {
|
|
|
1234
1242
|
const errors = [];
|
|
1235
1243
|
const routeModules = {};
|
|
1236
1244
|
const entrypoints = [];
|
|
1237
|
-
const routesDir =
|
|
1245
|
+
const routesDir = join(outDir, "routes");
|
|
1238
1246
|
const collectEntrypoints = (routeList) => {
|
|
1239
1247
|
for (const route of routeList) {
|
|
1240
1248
|
entrypoints.push(route.file);
|
|
@@ -1284,11 +1292,11 @@ async function buildServer(options) {
|
|
|
1284
1292
|
});
|
|
1285
1293
|
if (output.kind === "entry-point") {
|
|
1286
1294
|
const sourcePath = entrypoints.find((e) => {
|
|
1287
|
-
const routeRelPath = relative(
|
|
1295
|
+
const routeRelPath = relative(join(root, "app/routes"), e).replace(/\\/g, "/").replace(/\.[^.]+$/, ".js");
|
|
1288
1296
|
return output.path.replace(/\\/g, "/").endsWith(routeRelPath);
|
|
1289
1297
|
});
|
|
1290
1298
|
if (sourcePath) {
|
|
1291
|
-
const routeId = relative(
|
|
1299
|
+
const routeId = relative(join(root, "app/routes"), sourcePath).replace(/\.[^.]+$/, "").replace(/\\/g, "/");
|
|
1292
1300
|
routeModules[routeId] = relativePath;
|
|
1293
1301
|
const outputRelativeToRoutesDir = relative(routesDir, output.path).replace(/\\/g, "/");
|
|
1294
1302
|
routeOutputMap.set(sourcePath, outputRelativeToRoutesDir);
|
|
@@ -1299,7 +1307,7 @@ async function buildServer(options) {
|
|
|
1299
1307
|
errors.push(error instanceof Error ? error.message : String(error));
|
|
1300
1308
|
}
|
|
1301
1309
|
const serverEntry = generateServerEntry(routes, root, routeOutputMap);
|
|
1302
|
-
const serverEntryPath =
|
|
1310
|
+
const serverEntryPath = join(outDir, "_entry.server.ts");
|
|
1303
1311
|
await Bun.write(serverEntryPath, serverEntry);
|
|
1304
1312
|
try {
|
|
1305
1313
|
const entryResult = await Bun.build({
|
|
@@ -1344,10 +1352,11 @@ async function buildServer(options) {
|
|
|
1344
1352
|
function generateServerEntry(routes, root, routeOutputMap) {
|
|
1345
1353
|
const imports = [];
|
|
1346
1354
|
const routeRegistrations = [];
|
|
1347
|
-
|
|
1348
|
-
|
|
1355
|
+
let routeCounter = 0;
|
|
1356
|
+
const processRoute = (route) => {
|
|
1357
|
+
const varName = `route_${routeCounter++}`;
|
|
1349
1358
|
const outputPath = routeOutputMap.get(route.file);
|
|
1350
|
-
const importPath = outputPath ? `./routes/${outputPath}` : `./routes/${relative(
|
|
1359
|
+
const importPath = outputPath ? `./routes/${outputPath}` : `./routes/${relative(join(root, "app/routes"), route.file).replace(/\\/g, "/").replace(/\.[^.]+$/, ".js")}`;
|
|
1351
1360
|
imports.push(`import * as ${varName} from '${importPath}';`);
|
|
1352
1361
|
routeRegistrations.push(` {
|
|
1353
1362
|
id: '${route.id}',
|
|
@@ -1357,12 +1366,12 @@ function generateServerEntry(routes, root, routeOutputMap) {
|
|
|
1357
1366
|
layout: ${route.layout || false},
|
|
1358
1367
|
}`);
|
|
1359
1368
|
if (route.children) {
|
|
1360
|
-
route.children.forEach((child
|
|
1361
|
-
processRoute(child
|
|
1369
|
+
route.children.forEach((child) => {
|
|
1370
|
+
processRoute(child);
|
|
1362
1371
|
});
|
|
1363
1372
|
}
|
|
1364
1373
|
};
|
|
1365
|
-
routes.forEach((route
|
|
1374
|
+
routes.forEach((route) => processRoute(route));
|
|
1366
1375
|
return `/**
|
|
1367
1376
|
* Server Entry - Auto-generated by @ereo/bundler
|
|
1368
1377
|
* Do not edit this file directly.
|
|
@@ -1404,8 +1413,8 @@ async function buildClient(options) {
|
|
|
1404
1413
|
const outputs = [];
|
|
1405
1414
|
const errors = [];
|
|
1406
1415
|
const chunks = {};
|
|
1407
|
-
const clientEntry =
|
|
1408
|
-
const clientEntryAlt =
|
|
1416
|
+
const clientEntry = join(root, "app/entry.client.tsx");
|
|
1417
|
+
const clientEntryAlt = join(root, "app/entry.client.ts");
|
|
1409
1418
|
const hasClientEntry = await Bun.file(clientEntry).exists();
|
|
1410
1419
|
const hasClientEntryAlt = await Bun.file(clientEntryAlt).exists();
|
|
1411
1420
|
let entrypoint;
|
|
@@ -1414,7 +1423,7 @@ async function buildClient(options) {
|
|
|
1414
1423
|
} else if (hasClientEntryAlt) {
|
|
1415
1424
|
entrypoint = clientEntryAlt;
|
|
1416
1425
|
} else {
|
|
1417
|
-
const defaultEntry =
|
|
1426
|
+
const defaultEntry = join(outDir, "_entry.client.tsx");
|
|
1418
1427
|
await Bun.write(defaultEntry, generateDefaultClientEntry(routes));
|
|
1419
1428
|
entrypoint = defaultEntry;
|
|
1420
1429
|
}
|
|
@@ -1447,7 +1456,7 @@ async function buildClient(options) {
|
|
|
1447
1456
|
isEntry: output.kind === "entry-point"
|
|
1448
1457
|
});
|
|
1449
1458
|
if (output.kind === "chunk") {
|
|
1450
|
-
const chunkName =
|
|
1459
|
+
const chunkName = basename(output.path, extname(output.path));
|
|
1451
1460
|
chunks[chunkName] = relativePath;
|
|
1452
1461
|
}
|
|
1453
1462
|
}
|
|
@@ -1456,7 +1465,7 @@ async function buildClient(options) {
|
|
|
1456
1465
|
}
|
|
1457
1466
|
if (!hasClientEntry && !hasClientEntryAlt) {
|
|
1458
1467
|
try {
|
|
1459
|
-
await rm(
|
|
1468
|
+
await rm(join(outDir, "_entry.client.tsx"));
|
|
1460
1469
|
} catch (error) {}
|
|
1461
1470
|
}
|
|
1462
1471
|
return {
|
|
@@ -1510,10 +1519,10 @@ async function buildIslands(options) {
|
|
|
1510
1519
|
return { outputs, errors, islands: islandMap };
|
|
1511
1520
|
}
|
|
1512
1521
|
const islandEntry = generateIslandEntry(islands);
|
|
1513
|
-
const islandEntryPath =
|
|
1522
|
+
const islandEntryPath = join(outDir, "_islands.entry.ts");
|
|
1514
1523
|
await Bun.write(islandEntryPath, islandEntry);
|
|
1515
1524
|
const islandManifest = generateIslandManifest(islands);
|
|
1516
|
-
await Bun.write(
|
|
1525
|
+
await Bun.write(join(outDir, "manifest.json"), islandManifest);
|
|
1517
1526
|
const islandEntrypoints = islands.map((island) => island.file);
|
|
1518
1527
|
try {
|
|
1519
1528
|
const result = await Bun.build({
|
|
@@ -1545,7 +1554,7 @@ async function buildIslands(options) {
|
|
|
1545
1554
|
isEntry: output.kind === "entry-point"
|
|
1546
1555
|
});
|
|
1547
1556
|
if (output.kind === "entry-point") {
|
|
1548
|
-
const sourceIsland = islands.find((i) => output.path.includes(
|
|
1557
|
+
const sourceIsland = islands.find((i) => output.path.includes(basename(i.file, extname(i.file))));
|
|
1549
1558
|
if (sourceIsland) {
|
|
1550
1559
|
islandMap[sourceIsland.id] = relativePath;
|
|
1551
1560
|
}
|
|
@@ -1592,7 +1601,7 @@ ${content}
|
|
|
1592
1601
|
errors.push(`Failed to read CSS file ${cssFile}: ${error}`);
|
|
1593
1602
|
}
|
|
1594
1603
|
}
|
|
1595
|
-
const outputPath =
|
|
1604
|
+
const outputPath = join(outDir, "styles.css");
|
|
1596
1605
|
if (minify) {
|
|
1597
1606
|
combinedCSS = minifyCSS(combinedCSS);
|
|
1598
1607
|
}
|
|
@@ -1623,23 +1632,29 @@ ${content}
|
|
|
1623
1632
|
return { outputs, errors };
|
|
1624
1633
|
}
|
|
1625
1634
|
function minifyCSS(css) {
|
|
1626
|
-
|
|
1635
|
+
const placeholders = [];
|
|
1636
|
+
const safeCss = css.replace(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|url\(\s*(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^)]*?)\s*\))/g, (match) => {
|
|
1637
|
+
placeholders.push(match);
|
|
1638
|
+
return `__EREO_PH${placeholders.length - 1}__`;
|
|
1639
|
+
});
|
|
1640
|
+
const minified = safeCss.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
|
|
1641
|
+
return minified.replace(/__EREO_PH(\d+)__/g, (_, idx) => placeholders[Number(idx)]);
|
|
1627
1642
|
}
|
|
1628
1643
|
async function copyAssets(options) {
|
|
1629
1644
|
const { root, outDir, extensions } = options;
|
|
1630
1645
|
const outputs = [];
|
|
1631
1646
|
const assetDirs = [
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1647
|
+
join(root, "public"),
|
|
1648
|
+
join(root, "app/assets"),
|
|
1649
|
+
join(root, "assets")
|
|
1635
1650
|
];
|
|
1636
1651
|
for (const dir of assetDirs) {
|
|
1637
1652
|
try {
|
|
1638
1653
|
const files = await scanForFiles(dir, extensions);
|
|
1639
1654
|
for (const file of files) {
|
|
1640
1655
|
const relativePath = relative(dir, file);
|
|
1641
|
-
const destPath =
|
|
1642
|
-
await mkdir(
|
|
1656
|
+
const destPath = join(outDir, relativePath);
|
|
1657
|
+
await mkdir(dirname(destPath), { recursive: true });
|
|
1643
1658
|
await copyFile(file, destPath);
|
|
1644
1659
|
const fileStat = await stat(destPath);
|
|
1645
1660
|
outputs.push({
|
|
@@ -1648,7 +1663,11 @@ async function copyAssets(options) {
|
|
|
1648
1663
|
type: "asset"
|
|
1649
1664
|
});
|
|
1650
1665
|
}
|
|
1651
|
-
} catch (error) {
|
|
1666
|
+
} catch (error) {
|
|
1667
|
+
if (error?.code !== "ENOENT") {
|
|
1668
|
+
console.warn(` [Assets] Failed to process ${dir}: ${error?.message ?? error}`);
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1652
1671
|
}
|
|
1653
1672
|
return { outputs };
|
|
1654
1673
|
}
|
|
@@ -1710,7 +1729,7 @@ async function generateManifest(options) {
|
|
|
1710
1729
|
assets,
|
|
1711
1730
|
css: cssFiles
|
|
1712
1731
|
};
|
|
1713
|
-
await Bun.write(
|
|
1732
|
+
await Bun.write(join(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
1714
1733
|
}
|
|
1715
1734
|
function formatSize(bytes) {
|
|
1716
1735
|
if (bytes < 1024)
|
|
@@ -1788,7 +1807,7 @@ function analyzeBuild(result) {
|
|
|
1788
1807
|
};
|
|
1789
1808
|
}
|
|
1790
1809
|
// src/plugins/types.ts
|
|
1791
|
-
import { join as
|
|
1810
|
+
import { join as join2 } from "path";
|
|
1792
1811
|
function extractParams(path) {
|
|
1793
1812
|
const params = {};
|
|
1794
1813
|
const segments = path.split("/").filter(Boolean);
|
|
@@ -2225,14 +2244,14 @@ function generateIndexFile(fileNames) {
|
|
|
2225
2244
|
}
|
|
2226
2245
|
async function writeRouteTypes(outDir, routes, options = {}) {
|
|
2227
2246
|
const types = generateRouteTypes(routes, options);
|
|
2228
|
-
const outPath =
|
|
2247
|
+
const outPath = join2(outDir, "routes.d.ts");
|
|
2229
2248
|
await Bun.write(outPath, types);
|
|
2230
2249
|
console.log(`\x1B[32m\u2713\x1B[0m Route types written to ${outPath}`);
|
|
2231
2250
|
}
|
|
2232
2251
|
async function writeSplitRouteTypes(outDir, routes, options = {}) {
|
|
2233
2252
|
const files = generateSplitRouteTypes(routes, options);
|
|
2234
2253
|
for (const [fileName, content] of files) {
|
|
2235
|
-
const outPath =
|
|
2254
|
+
const outPath = join2(outDir, fileName);
|
|
2236
2255
|
await Bun.write(outPath, content);
|
|
2237
2256
|
}
|
|
2238
2257
|
console.log(`\x1B[32m\u2713\x1B[0m Split route types written to ${outDir} (${files.size} files)`);
|
|
@@ -2425,7 +2444,7 @@ export declare function useNavigate(): {
|
|
|
2425
2444
|
`.trim();
|
|
2426
2445
|
}
|
|
2427
2446
|
// src/plugins/tailwind.ts
|
|
2428
|
-
import { join as
|
|
2447
|
+
import { join as join3, resolve } from "path";
|
|
2429
2448
|
import { readFileSync, existsSync, statSync } from "fs";
|
|
2430
2449
|
import postcss from "postcss";
|
|
2431
2450
|
import tailwindcss from "tailwindcss";
|
|
@@ -2456,10 +2475,10 @@ function createTailwindPlugin(options = {}) {
|
|
|
2456
2475
|
async function loadTailwindConfig() {
|
|
2457
2476
|
const configPaths = [
|
|
2458
2477
|
config ? resolve(root, config) : null,
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2478
|
+
join3(root, "tailwind.config.js"),
|
|
2479
|
+
join3(root, "tailwind.config.ts"),
|
|
2480
|
+
join3(root, "tailwind.config.mjs"),
|
|
2481
|
+
join3(root, "tailwind.config.cjs")
|
|
2463
2482
|
].filter(Boolean);
|
|
2464
2483
|
for (const configPath of configPaths) {
|
|
2465
2484
|
try {
|
|
@@ -2714,7 +2733,7 @@ ${code}`;
|
|
|
2714
2733
|
];
|
|
2715
2734
|
if (server.watcher) {
|
|
2716
2735
|
for (const configFile of configPaths) {
|
|
2717
|
-
const fullPath =
|
|
2736
|
+
const fullPath = join3(root, configFile);
|
|
2718
2737
|
if (existsSync(fullPath)) {
|
|
2719
2738
|
server.watcher.add(fullPath);
|
|
2720
2739
|
}
|
|
@@ -2835,12 +2854,12 @@ async function hasTailwindConfig(root) {
|
|
|
2835
2854
|
"tailwind.config.mjs"
|
|
2836
2855
|
];
|
|
2837
2856
|
for (const file of configFiles) {
|
|
2838
|
-
if (existsSync(
|
|
2857
|
+
if (existsSync(join3(root, file))) {
|
|
2839
2858
|
return true;
|
|
2840
2859
|
}
|
|
2841
2860
|
}
|
|
2842
2861
|
try {
|
|
2843
|
-
const pkgPath =
|
|
2862
|
+
const pkgPath = join3(root, "package.json");
|
|
2844
2863
|
if (existsSync(pkgPath)) {
|
|
2845
2864
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
2846
2865
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
@@ -2858,8 +2877,8 @@ function tailwindMiddleware(options = {}) {
|
|
|
2858
2877
|
if (!processor) {
|
|
2859
2878
|
const configPaths = [
|
|
2860
2879
|
options.config ? resolve(root, options.config) : null,
|
|
2861
|
-
|
|
2862
|
-
|
|
2880
|
+
join3(root, "tailwind.config.js"),
|
|
2881
|
+
join3(root, "tailwind.config.ts")
|
|
2863
2882
|
].filter(Boolean);
|
|
2864
2883
|
for (const configPath of configPaths) {
|
|
2865
2884
|
if (existsSync(configPath)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"islands.d.ts","sourceRoot":"","sources":["../../src/plugins/islands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"islands.d.ts","sourceRoot":"","sources":["../../src/plugins/islands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,M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AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CA2CA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ereo/bundler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.36",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "Enoch Kujem Abassey",
|
|
6
6
|
"homepage": "https://ereojs.github.io/ereoJS",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"typecheck": "tsc --noEmit"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@ereo/core": "^0.2.
|
|
36
|
-
"@ereo/router": "^0.2.
|
|
35
|
+
"@ereo/core": "^0.2.36",
|
|
36
|
+
"@ereo/router": "^0.2.36",
|
|
37
37
|
"postcss": "^8.4.35",
|
|
38
38
|
"tailwindcss": "^3.4.1",
|
|
39
39
|
"autoprefixer": "^10.4.17",
|