@polycode-projects/the-mechanical-code-talker 3.1.3 → 3.1.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polycode-projects/the-mechanical-code-talker",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The Mechanical Code Talker (tmct) — a tolerant, offline, $0 chat surface that guides you toward precision queries about a software repository. ELIZA/PARRY-style but domain-obsessed with code. No model calls; indexes a repo on request (tmct index) or reads any producer's graph.",
|
|
@@ -3,14 +3,23 @@
|
|
|
3
3
|
//
|
|
4
4
|
// A static `import "wink-nlp"` would drag the ~1 MB model into the base/viewer bundle.
|
|
5
5
|
// Instead, `registerWinkModel` lets a browser/bundler entry hand in an already-imported
|
|
6
|
-
// `{ winkNLP, model }` pair once; Node instead resolves lazily via `createRequire
|
|
6
|
+
// `{ winkNLP, model }` pair once; Node instead resolves lazily via `createRequire`,
|
|
7
|
+
// fetched at call time from `process.getBuiltinModule("node:module")` rather than a
|
|
8
|
+
// top-level `import { createRequire } from "node:module"`. A top-level import declares
|
|
9
|
+
// the `createRequire` binding in this module's own output, and a downstream consumer
|
|
10
|
+
// that bundles tmct alongside other CJS dependencies (esbuild, `--format=esm`) can
|
|
11
|
+
// inject its own auto-generated `createRequire` shim into the same bundle scope,
|
|
12
|
+
// producing a duplicate top-level declaration and a `SyntaxError` at Node module-parse
|
|
13
|
+
// time. Resolving it lazily via `process.getBuiltinModule` keeps the bundled output free
|
|
14
|
+
// of any top-level `createRequire` declaration, so there's nothing left to collide with.
|
|
15
|
+
// Don't "simplify" this back to a top-level import. `process.getBuiltinModule` needs
|
|
16
|
+
// Node 22.3.0/20.16.0+; this package's `engines.node` floor (">=24") already clears
|
|
17
|
+
// that, so lowering the floor later needs to keep clearing it too.
|
|
7
18
|
//
|
|
8
19
|
// The loader stays synchronous. Failure is cached as null — a checkout without the
|
|
9
20
|
// optional deps, or a page that never registered a model, runs adapter-less rather
|
|
10
21
|
// than throwing.
|
|
11
22
|
|
|
12
|
-
import { createRequire } from "node:module";
|
|
13
|
-
|
|
14
23
|
let injected; // browser/bundler-supplied `() => ({ winkNLP, model })`, or undefined
|
|
15
24
|
let cached; // undefined = not tried yet; null = unavailable (tried once, honestly off)
|
|
16
25
|
|
|
@@ -40,7 +49,7 @@ function loadWinkModel() {
|
|
|
40
49
|
/** Node fallback: resolve wink through the module system (never a guessed path).
|
|
41
50
|
* CJS deps, so `createRequire`. */
|
|
42
51
|
function nodeRequireWink() {
|
|
43
|
-
const require = createRequire(import.meta.url);
|
|
52
|
+
const require = process.getBuiltinModule("node:module").createRequire(import.meta.url);
|
|
44
53
|
return {
|
|
45
54
|
winkNLP: require("wink-nlp"),
|
|
46
55
|
model: require("wink-eng-lite-web-model"),
|