@514labs/moose-lib 0.6.268-ci-25-gc7e0e198 → 0.6.268-ci-2-g822d274c

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 CHANGED
@@ -789,6 +789,7 @@ function getSourceDir() {
789
789
  return import_process.default.env.MOOSE_SOURCE_DIR || "app";
790
790
  }
791
791
  var isClientOnlyMode = () => import_process.default.env.MOOSE_CLIENT_ONLY === "true";
792
+ var isProductionMode = () => import_process.default.env.NODE_ENV === "production";
792
793
  var moose_internal = {
793
794
  tables: /* @__PURE__ */ new Map(),
794
795
  streams: /* @__PURE__ */ new Map(),
@@ -803,7 +804,11 @@ var getMooseInternal = () => globalThis.moose_internal;
803
804
  if (getMooseInternal() === void 0) {
804
805
  globalThis.moose_internal = moose_internal;
805
806
  }
806
- var loadIndex = () => {
807
+ var isRegistryEmpty = () => {
808
+ const registry = getMooseInternal();
809
+ return registry.tables.size === 0 && registry.streams.size === 0 && registry.ingestApis.size === 0 && registry.apis.size === 0 && registry.sqlResources.size === 0 && registry.workflows.size === 0 && registry.webApps.size === 0;
810
+ };
811
+ var reloadIndex = () => {
807
812
  const registry = getMooseInternal();
808
813
  registry.tables.clear();
809
814
  registry.streams.clear();
@@ -812,12 +817,14 @@ var loadIndex = () => {
812
817
  registry.sqlResources.clear();
813
818
  registry.workflows.clear();
814
819
  registry.webApps.clear();
815
- const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
816
- Object.keys(require.cache).forEach((key) => {
817
- if (key.startsWith(appDir)) {
818
- delete require.cache[key];
819
- }
820
- });
820
+ if (!isProductionMode()) {
821
+ const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
822
+ Object.keys(require.cache).forEach((key) => {
823
+ if (key.startsWith(appDir)) {
824
+ delete require.cache[key];
825
+ }
826
+ });
827
+ }
821
828
  try {
822
829
  require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
823
830
  } catch (error) {
@@ -831,6 +838,11 @@ var loadIndex = () => {
831
838
  throw new Error(errorMsg, { cause });
832
839
  }
833
840
  };
841
+ var ensureIndexLoaded = () => {
842
+ if (isRegistryEmpty()) {
843
+ reloadIndex();
844
+ }
845
+ };
834
846
  var dlqSchema = {
835
847
  version: "3.1",
836
848
  components: {
@@ -951,7 +963,7 @@ var dlqColumns = [
951
963
  }
952
964
  ];
953
965
  var getWorkflows = async () => {
954
- loadIndex();
966
+ ensureIndexLoaded();
955
967
  const registry = getMooseInternal();
956
968
  return registry.workflows;
957
969
  };