stonyx 0.2.3-alpha.37 → 0.2.3-alpha.39

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.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Shared constants for APP-OWNED `{ts,js}` resolution.
3
+ *
4
+ * Two resolvers pick an extension for a file in the consuming project's own
5
+ * tree — `resolveEntryPoint` (`./resolve-entry-point.ts`, since
6
+ * abofs/stonyx#67) and `importConfig` (`./import-config.ts`, since
7
+ * abofs/stonyx#90). They must agree on the candidate list, on the preference
8
+ * order, and on the wording of the dual-extension warning.
9
+ *
10
+ * They previously agreed by copy. Each string was pinned by its own suite, so
11
+ * editing one file left BOTH suites green while the two messages diverged —
12
+ * which is why this lives here and not at the top of either consumer
13
+ * (`docs/conventions/index.md` § Universal Rules: constants shared across
14
+ * files go in a dedicated constants file).
15
+ *
16
+ * MODULE-OWNED configs are not in scope: `./import-module-config.ts` resolves
17
+ * `.js` only, forever, and deliberately shares nothing with this file.
18
+ */
19
+ /** Candidate extensions in preference order — `.ts` wins over `.js`. */
20
+ export declare const EXTENSIONS: readonly ["ts", "js"];
21
+ /** The warning both app-owned resolvers emit when a `.ts`/`.js` pair exists. */
22
+ export declare function dualExtensionWarning(basePath: string): string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared constants for APP-OWNED `{ts,js}` resolution.
3
+ *
4
+ * Two resolvers pick an extension for a file in the consuming project's own
5
+ * tree — `resolveEntryPoint` (`./resolve-entry-point.ts`, since
6
+ * abofs/stonyx#67) and `importConfig` (`./import-config.ts`, since
7
+ * abofs/stonyx#90). They must agree on the candidate list, on the preference
8
+ * order, and on the wording of the dual-extension warning.
9
+ *
10
+ * They previously agreed by copy. Each string was pinned by its own suite, so
11
+ * editing one file left BOTH suites green while the two messages diverged —
12
+ * which is why this lives here and not at the top of either consumer
13
+ * (`docs/conventions/index.md` § Universal Rules: constants shared across
14
+ * files go in a dedicated constants file).
15
+ *
16
+ * MODULE-OWNED configs are not in scope: `./import-module-config.ts` resolves
17
+ * `.js` only, forever, and deliberately shares nothing with this file.
18
+ */
19
+ /** Candidate extensions in preference order — `.ts` wins over `.js`. */
20
+ export const EXTENSIONS = ['ts', 'js'];
21
+ /** The warning both app-owned resolvers emit when a `.ts`/`.js` pair exists. */
22
+ export function dualExtensionWarning(basePath) {
23
+ return `Warning: both ${basePath}.ts and ${basePath}.js exist. Using .ts — delete the .js to silence this warning (it is likely a stale compiled artifact or postinstall stub).`;
24
+ }
@@ -2,7 +2,9 @@
2
2
  * Resolve an APP-OWNED config — `<cwd>/config/environment`,
3
3
  * `<rootPath>/test/config/environment` — as `{ts,js}`, preferring `.ts`.
4
4
  * Mirrors `src/util/resolve-entry-point.ts`, which has resolved app-owned
5
- * entry points this way since abofs/stonyx#67.
5
+ * entry points this way since abofs/stonyx#67 — the candidate list and the
6
+ * dual-extension warning are shared through `./extension-resolution.ts` so
7
+ * the two cannot drift.
6
8
  *
7
9
  * These paths live in the consuming project's own tree, never inside
8
10
  * `node_modules`, so they load under the app's own loader and Node's type
@@ -1,11 +1,13 @@
1
1
  import { existsSync } from 'fs';
2
2
  import { pathToFileURL } from 'url';
3
- const EXTENSIONS = ['ts', 'js'];
3
+ import { EXTENSIONS, dualExtensionWarning } from './extension-resolution.js';
4
4
  /**
5
5
  * Resolve an APP-OWNED config — `<cwd>/config/environment`,
6
6
  * `<rootPath>/test/config/environment` — as `{ts,js}`, preferring `.ts`.
7
7
  * Mirrors `src/util/resolve-entry-point.ts`, which has resolved app-owned
8
- * entry points this way since abofs/stonyx#67.
8
+ * entry points this way since abofs/stonyx#67 — the candidate list and the
9
+ * dual-extension warning are shared through `./extension-resolution.ts` so
10
+ * the two cannot drift.
9
11
  *
10
12
  * These paths live in the consuming project's own tree, never inside
11
13
  * `node_modules`, so they load under the app's own loader and Node's type
@@ -26,7 +28,7 @@ export async function importConfig(basePath) {
26
28
  throw new Error(`Config not found: ${basePath}.{ts,js}`);
27
29
  }
28
30
  if (matches.length > 1) {
29
- console.warn(`Warning: both ${basePath}.ts and ${basePath}.js exist. Using .ts — delete the .js to silence this warning (it is likely a stale compiled artifact or postinstall stub).`);
31
+ console.warn(dualExtensionWarning(basePath));
30
32
  }
31
33
  const path = `${basePath}.${matches[0]}`;
32
34
  const mod = await import(pathToFileURL(path).href);
@@ -1,13 +1,13 @@
1
1
  import { existsSync } from 'fs';
2
2
  import { resolve } from 'path';
3
- const EXTENSIONS = ['ts', 'js'];
3
+ import { EXTENSIONS, dualExtensionWarning } from './extension-resolution.js';
4
4
  export function resolveEntryPoint(basePath) {
5
5
  const matches = EXTENSIONS.filter(ext => existsSync(resolve(`${basePath}.${ext}`)));
6
6
  if (matches.length === 0) {
7
7
  throw new Error(`Entry point not found: ${basePath}.{ts,js}`);
8
8
  }
9
9
  if (matches.length > 1) {
10
- console.warn(`Warning: both ${basePath}.ts and ${basePath}.js exist. Using .ts — delete the .js to silence this warning (it is likely a stale compiled artifact or postinstall stub).`);
10
+ console.warn(dualExtensionWarning(basePath));
11
11
  }
12
12
  const ext = matches[0];
13
13
  return resolve(`${basePath}.${ext}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stonyx",
3
- "version": "0.2.3-alpha.37",
3
+ "version": "0.2.3-alpha.39",
4
4
  "description": "Base stonyx framework module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",