@adonisjs/assembler 8.0.0-next.20 → 8.0.0-next.22

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.
@@ -252,8 +252,11 @@ var IndexGeneratorSource = class {
252
252
  */
253
253
  #createBarrelFileKeyGenerator(config) {
254
254
  return function(key) {
255
- const paths = key.split("/");
255
+ let paths = key.split("/");
256
256
  let baseName = new StringBuilder(paths.pop());
257
+ if (config.skipSegments?.length) {
258
+ paths = paths.filter((p) => !config.skipSegments.includes(p));
259
+ }
257
260
  if (config.computeBaseName) {
258
261
  baseName = config.computeBaseName(baseName);
259
262
  } else {
package/build/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FileBuffer,
3
3
  IndexGenerator
4
- } from "./chunk-4452KFDQ.js";
4
+ } from "./chunk-NR7VMFWO.js";
5
5
  import {
6
6
  RoutesScanner
7
7
  } from "./chunk-NAASGAFO.js";
@@ -635,14 +635,6 @@ var ShortcutsManager = class {
635
635
 
636
636
  // src/dev_server.ts
637
637
  var DevServer = class _DevServer {
638
- /**
639
- * Pre-allocated info object for hot-hook change events to avoid repeated object creation
640
- */
641
- static #HOT_HOOK_CHANGE_INFO = {
642
- source: "hot-hook",
643
- fullReload: false,
644
- hotReloaded: false
645
- };
646
638
  /**
647
639
  * Pre-allocated info object for hot-hook full reload events
648
640
  */
@@ -690,6 +682,10 @@ var DevServer = class _DevServer {
690
682
  * Reference to the child process
691
683
  */
692
684
  #httpServer;
685
+ /**
686
+ * Flag to track if the HTTP server child process is alive
687
+ */
688
+ #isHttpServerAlive = false;
693
689
  /**
694
690
  * Keyboard shortcuts manager instance
695
691
  */
@@ -864,6 +860,56 @@ var DevServer = class _DevServer {
864
860
  process.stdout.write("\x1Bc");
865
861
  }
866
862
  }
863
+ /**
864
+ * Creates our file system watcher
865
+ */
866
+ #createWatcher(options) {
867
+ const watcher = watch({
868
+ usePolling: options?.poll ?? false,
869
+ cwd: this.cwdPath,
870
+ ignoreInitial: true,
871
+ ignored: (file, stats) => {
872
+ if (!stats) return false;
873
+ if (file.includes("inertia") && !file.includes("node_modules")) return false;
874
+ if (stats.isFile()) return !this.#fileSystem.shouldWatchFile(file);
875
+ return !this.#fileSystem.shouldWatchDirectory(file);
876
+ }
877
+ });
878
+ watcher.on("error", (error) => {
879
+ this.ui.logger.warning("file system watcher failure");
880
+ this.ui.logger.fatal(error);
881
+ this.#onError?.(error);
882
+ this.#watcher?.close();
883
+ });
884
+ watcher.on("ready", () => {
885
+ this.ui.logger.info("watching file system for changes...");
886
+ });
887
+ return watcher;
888
+ }
889
+ /**
890
+ * Handles file change events in HMR mode by forwarding to hot-hook
891
+ * or restarting the server if dead.
892
+ */
893
+ #handleHmrWatcherEvent(options) {
894
+ const relativePath = string3.toUnixSlash(options.filePath);
895
+ const absolutePath = join2(this.cwdPath, relativePath);
896
+ if (this.#isHttpServerAlive === false) {
897
+ this.#clearScreen();
898
+ this.ui.logger.log(`${this.ui.colors.green(options.displayLabel)} ${relativePath}`);
899
+ this.#restartHTTPServer();
900
+ return;
901
+ }
902
+ if (options.action === "add") {
903
+ this.#hooks.runner("fileAdded").run(relativePath, absolutePath, this);
904
+ } else if (options.action === "unlink") {
905
+ this.#hooks.runner("fileRemoved").run(relativePath, absolutePath, this);
906
+ }
907
+ this.#httpServer?.send({
908
+ type: "hot-hook:file-changed",
909
+ path: absolutePath,
910
+ action: options.action
911
+ });
912
+ }
867
913
  /**
868
914
  * Handles file change events and triggers appropriate server actions
869
915
  *
@@ -1073,7 +1119,7 @@ var DevServer = class _DevServer {
1073
1119
  async #startHTTPServer(port) {
1074
1120
  await this.#hooks.runner("devServerStarting").run(this);
1075
1121
  debug_default('starting http server using "%s" file, options %O', this.scriptFile, this.options);
1076
- return new Promise(async (resolve) => {
1122
+ return new Promise((resolve) => {
1077
1123
  this.#httpServer = runNode(this.cwd, {
1078
1124
  script: this.scriptFile,
1079
1125
  env: { PORT: port, ...this.options.env },
@@ -1081,6 +1127,7 @@ var DevServer = class _DevServer {
1081
1127
  reject: true,
1082
1128
  scriptArgs: this.options.scriptArgs
1083
1129
  });
1130
+ this.#isHttpServerAlive = true;
1084
1131
  this.#httpServer.on("message", async (message) => {
1085
1132
  if (this.#isAdonisJSReadyMessage(message)) {
1086
1133
  debug_default("received http server ready message %O", message);
@@ -1091,17 +1138,7 @@ var DevServer = class _DevServer {
1091
1138
  await this.#processRoutes(message.routesFileLocation);
1092
1139
  } else if (this.#mode === "hmr" && this.#isHotHookMessage(message)) {
1093
1140
  debug_default("received hot-hook message %O", message);
1094
- if (message.type === "hot-hook:file-changed") {
1095
- const absolutePath = message.path ? string3.toUnixSlash(message.path) : "";
1096
- const relativePath = relative3(this.cwdPath, absolutePath);
1097
- if (message.action === "add") {
1098
- this.#hooks.runner("fileAdded").run(relativePath, absolutePath, this);
1099
- } else if (message.action === "change") {
1100
- this.#hooks.runner("fileChanged").run(relativePath, absolutePath, _DevServer.#HOT_HOOK_CHANGE_INFO, this);
1101
- } else if (message.action === "unlink") {
1102
- this.#hooks.runner("fileRemoved").run(relativePath, absolutePath, this);
1103
- }
1104
- } else if (message.type === "hot-hook:full-reload") {
1141
+ if (message.type === "hot-hook:full-reload") {
1105
1142
  const absolutePath = message.path ? string3.toUnixSlash(message.path) : "";
1106
1143
  const relativePath = relative3(this.cwdPath, absolutePath);
1107
1144
  this.#hooks.runner("fileChanged").run(relativePath, absolutePath, _DevServer.#HOT_HOOK_FULL_RELOAD_INFO, this);
@@ -1113,12 +1150,14 @@ var DevServer = class _DevServer {
1113
1150
  }
1114
1151
  });
1115
1152
  this.#httpServer.then((result) => {
1153
+ this.#isHttpServerAlive = false;
1116
1154
  if (!this.#watcher) {
1117
1155
  this.#onClose?.(result.exitCode);
1118
1156
  } else {
1119
1157
  this.ui.logger.info("Underlying HTTP server closed. Still watching for changes");
1120
1158
  }
1121
1159
  }).catch((error) => {
1160
+ this.#isHttpServerAlive = false;
1122
1161
  if (!this.#watcher) {
1123
1162
  this.#onError?.(error);
1124
1163
  } else {
@@ -1205,13 +1244,22 @@ var DevServer = class _DevServer {
1205
1244
  this.options.nodeArgs.push("--import=hot-hook/register");
1206
1245
  this.options.env = {
1207
1246
  ...this.options.env,
1208
- HOT_HOOK_INCLUDE: this.#fileSystem.includes.join(","),
1209
- HOT_HOOK_IGNORE: this.#fileSystem.excludes.filter((exclude) => !exclude.includes("inertia")).join(","),
1210
- HOT_HOOK_RESTART: (this.options.metaFiles ?? []).filter(({ reloadServer }) => !!reloadServer).map(({ pattern }) => pattern).join(",")
1247
+ HOT_HOOK_WATCH: "false"
1211
1248
  };
1212
1249
  }
1213
1250
  this.ui.logger.info("starting HTTP server...");
1214
1251
  await this.#startHTTPServer(this.#stickyPort);
1252
+ if (this.#mode !== "hmr") return;
1253
+ this.#watcher = this.#createWatcher();
1254
+ this.#watcher.on("add", (filePath) => {
1255
+ this.#handleHmrWatcherEvent({ filePath, action: "add", displayLabel: "add" });
1256
+ });
1257
+ this.#watcher.on("change", (filePath) => {
1258
+ this.#handleHmrWatcherEvent({ filePath, action: "change", displayLabel: "update" });
1259
+ });
1260
+ this.#watcher.on("unlink", (filePath) => {
1261
+ this.#handleHmrWatcherEvent({ filePath, action: "unlink", displayLabel: "delete" });
1262
+ });
1215
1263
  }
1216
1264
  /**
1217
1265
  * Starts the development server in watch mode and restarts on file changes
@@ -1235,32 +1283,7 @@ var DevServer = class _DevServer {
1235
1283
  }
1236
1284
  this.ui.logger.info("starting HTTP server...");
1237
1285
  await this.#startHTTPServer(this.#stickyPort);
1238
- this.#watcher = watch({
1239
- usePolling: options?.poll ?? false,
1240
- cwd: this.cwdPath,
1241
- ignoreInitial: true,
1242
- ignored: (file, stats) => {
1243
- if (!stats) {
1244
- return false;
1245
- }
1246
- if (file.includes("inertia") && !file.includes("node_modules")) {
1247
- return false;
1248
- }
1249
- if (stats.isFile()) {
1250
- return !this.#fileSystem.shouldWatchFile(file);
1251
- }
1252
- return !this.#fileSystem.shouldWatchDirectory(file);
1253
- }
1254
- });
1255
- this.#watcher.on("ready", () => {
1256
- this.ui.logger.info("watching file system for changes...");
1257
- });
1258
- this.#watcher.on("error", (error) => {
1259
- this.ui.logger.warning("file system watcher failure");
1260
- this.ui.logger.fatal(error);
1261
- this.#onError?.(error);
1262
- this.#watcher?.close();
1263
- });
1286
+ this.#watcher = this.#createWatcher({ poll: options?.poll });
1264
1287
  this.#watcher.on("add", (filePath) => {
1265
1288
  const relativePath = string3.toUnixSlash(filePath);
1266
1289
  const absolutePath = join2(this.cwdPath, relativePath);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  IndexGenerator
3
- } from "../../chunk-4452KFDQ.js";
3
+ } from "../../chunk-NR7VMFWO.js";
4
4
  import "../../chunk-JFBQ4OEM.js";
5
5
  export {
6
6
  IndexGenerator
@@ -38,6 +38,7 @@ export type IndexGeneratorSourceConfig = ({
38
38
  glob?: string[];
39
39
  importAlias?: string;
40
40
  removeSuffix?: string;
41
+ skipSegments?: string[];
41
42
  };
42
43
  /**
43
44
  * Marks a given optional property as required
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/assembler",
3
3
  "description": "Provides utilities to run AdonisJS development server and build project for production",
4
- "version": "8.0.0-next.20",
4
+ "version": "8.0.0-next.22",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -53,7 +53,7 @@
53
53
  "cross-env": "^10.1.0",
54
54
  "del-cli": "^7.0.0",
55
55
  "eslint": "^9.37.0",
56
- "hot-hook": "^0.4.1-next.0",
56
+ "hot-hook": "^0.4.1-next.2",
57
57
  "p-event": "^7.0.0",
58
58
  "prettier": "^3.6.2",
59
59
  "release-it": "^19.0.5",