refactor(modules): one @use path resolution for the CLI and LSP hosts (@gram-lang/modules/node) #309

Merged
abiwab merged 4 commits from refactor/modules-node-path into dev/1.6 2026-11-29 11:20:09 +01:00
Owner

Lot 1b of .notes/v1.6/plan-finitions-techniques-1.6.md, plus the completion check of lot 1a, which only exists on dev/1.6.

⚠️ Merge after #306 (main) and the main → dev/1.6 merge: this branch contains fix/use-path-hardening merged in, so its diff includes #306 until then.

  • @gram-lang/modules/node (new exports entry, like ./lint): resolveProjectPath(specifier, fromPath, projectRoot, paths?, path = node:path): the @/ / @alias/ / relative resolution and confinement the two hosts used to copy. Pure path arithmetic. The path parameter lets the tests run Windows rules on Linux (path.win32: other drive, drive-letter case, ..notes).
  • createCliModuleHost calls it directly; the LSP host wraps it in fileURLToPath / pathToFileURL. Case tables moved to packages/modules/tests/node-path.test.ts; each host keeps a wiring test.
  • The main entry stays free of node:* (playground): @types/node referenced in node.ts only, and a test checks that node.ts is the only source file importing a node: module.
  • provideImportExportCompletions calls validateSpecifier() before host.resolve(): the @use … as {…} completion never reads a module the graph refuses (./sub\base.gram test with a file that really exists under that name). A dev/1.6 feature, so no changeset.
  • Docs reference/api/modules.mdx (en/fr): validateSpecifier and resolveProjectPath.
  • minor changeset on @gram-lang/modules.

Checks: build, modules / cli / language-server tests, typecheck, lint, conformance, dedupe:check.

Lot 1b of `.notes/v1.6/plan-finitions-techniques-1.6.md`, plus the completion check of lot 1a, which only exists on `dev/1.6`. ⚠️ **Merge after #306** (main) **and the `main` → `dev/1.6` merge**: this branch contains `fix/use-path-hardening` merged in, so its diff includes #306 until then. - **`@gram-lang/modules/node`** (new `exports` entry, like `./lint`): `resolveProjectPath(specifier, fromPath, projectRoot, paths?, path = node:path)`: the `@/` / `@alias/` / relative resolution and confinement the two hosts used to copy. Pure path arithmetic. The `path` parameter lets the tests run Windows rules on Linux (`path.win32`: other drive, drive-letter case, `..notes`). - `createCliModuleHost` calls it directly; the LSP host wraps it in `fileURLToPath` / `pathToFileURL`. Case tables moved to `packages/modules/tests/node-path.test.ts`; each host keeps a wiring test. - The main entry stays free of `node:*` (playground): `@types/node` referenced in `node.ts` only, and a test checks that `node.ts` is the only source file importing a `node:` module. - **`provideImportExportCompletions`** calls `validateSpecifier()` before `host.resolve()`: the `@use … as {…}` completion never reads a module the graph refuses (`./sub\base.gram` test with a file that really exists under that name). A `dev/1.6` feature, so no changeset. - Docs `reference/api/modules.mdx` (en/fr): `validateSpecifier` and `resolveProjectPath`. - `minor` changeset on `@gram-lang/modules`. Checks: build, modules / cli / language-server tests, typecheck, lint, conformance, `dedupe:check`.
Merge remote-tracking branch 'origin/dev/1.6' into refactor/modules-node-path
All checks were successful
CI / Build & Test (pull_request) Successful in 6m20s
c65eb7c467
abiwab merged commit 22858e726a into dev/1.6 2026-11-29 11:20:09 +01:00
Sign in to join this conversation.
No description provided.