@onyx.dev/onyx-database 0.1.4 → 0.1.5

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
@@ -35,6 +35,12 @@ function dropUndefined(obj) {
35
35
  }
36
36
  return out;
37
37
  }
38
+ async function nodeImport(spec) {
39
+ return import(
40
+ /* @vite-ignore */
41
+ spec
42
+ );
43
+ }
38
44
  function readEnv(targetId) {
39
45
  if (!gProcess?.env) return {};
40
46
  const env = gProcess.env;
@@ -62,8 +68,8 @@ function readEnv(targetId) {
62
68
  }
63
69
  async function readProjectFile(databaseId) {
64
70
  if (!isNode) return {};
65
- const fs = await import('fs/promises');
66
- const path = await import('path');
71
+ const fs = await nodeImport("node:fs/promises");
72
+ const path = await nodeImport("node:path");
67
73
  const cwd = gProcess?.cwd?.() ?? ".";
68
74
  const tryRead = async (p) => {
69
75
  const txt = await fs.readFile(p, "utf8");
@@ -90,9 +96,9 @@ async function readProjectFile(databaseId) {
90
96
  }
91
97
  async function readHomeProfile(databaseId) {
92
98
  if (!isNode) return {};
93
- const fs = await import('fs/promises');
94
- const os = await import('os');
95
- const path = await import('path');
99
+ const fs = await nodeImport("node:fs/promises");
100
+ const os = await nodeImport("node:os");
101
+ const path = await nodeImport("node:path");
96
102
  const home = os.homedir();
97
103
  const dir = path.join(home, ".onyx");
98
104
  const fileExists = async (p) => {
@@ -146,8 +152,8 @@ async function readHomeProfile(databaseId) {
146
152
  }
147
153
  async function readConfigPath(p) {
148
154
  if (!isNode) return {};
149
- const fs = await import('fs/promises');
150
- const path = await import('path');
155
+ const fs = await nodeImport("node:fs/promises");
156
+ const path = await nodeImport("node:path");
151
157
  const cwd = gProcess?.cwd?.() ?? ".";
152
158
  const resolved = path.isAbsolute(p) ? p : path.resolve(cwd, p);
153
159
  try {