@intentius/chant 0.124.16 → 0.124.17
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/cli/commands/check-lexicon-plugin.d.ts.map +1 -1
- package/dist/cli/commands/check-lexicon-plugin.js +2 -1
- package/dist/cli/commands/lint.d.ts.map +1 -1
- package/dist/cli/commands/lint.js +3 -2
- package/dist/components/discover.d.ts.map +1 -1
- package/dist/components/discover.js +2 -1
- package/dist/config-sandbox.d.ts.map +1 -1
- package/dist/config-sandbox.js +5 -1
- package/dist/discovery/import.d.ts.map +1 -1
- package/dist/discovery/import.js +2 -1
- package/dist/discovery/sandbox/driver.d.ts.map +1 -1
- package/dist/discovery/sandbox/driver.js +8 -3
- package/dist/lexicon-module.d.ts.map +1 -1
- package/dist/lexicon-module.js +4 -3
- package/dist/lint/policy-import.d.ts.map +1 -1
- package/dist/lint/policy-import.js +2 -1
- package/dist/lint/rule-loader.d.ts.map +1 -1
- package/dist/lint/rule-loader.js +2 -1
- package/dist/module-interop.d.ts +20 -0
- package/dist/module-interop.d.ts.map +1 -0
- package/dist/module-interop.js +39 -0
- package/dist/op/discover.d.ts.map +1 -1
- package/dist/op/discover.js +3 -2
- package/dist/wave-runtime.mjs +174 -174
- package/dist/workspace/lineage-migrations.d.ts.map +1 -1
- package/dist/workspace/lineage-migrations.js +2 -1
- package/package.json +1 -1
- package/src/cli/commands/check-lexicon-plugin.ts +2 -1
- package/src/cli/commands/lint.ts +3 -2
- package/src/cli/compiled-cli.e2e.test.ts +42 -1
- package/src/components/discover.ts +2 -1
- package/src/config-sandbox.ts +5 -1
- package/src/discovery/import.ts +2 -1
- package/src/discovery/sandbox/driver.ts +8 -3
- package/src/lexicon-module.ts +4 -3
- package/src/lint/policy-import.ts +2 -1
- package/src/lint/rule-loader.ts +2 -1
- package/src/module-interop.test.ts +65 -0
- package/src/module-interop.ts +39 -0
- package/src/op/discover.ts +3 -2
- package/src/workspace/lineage-migrations.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-lexicon-plugin.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/check-lexicon-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"check-lexicon-plugin.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/check-lexicon-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAIpE,MAAM,WAAW,aAAa;IAC5B,iDAAiD;IACjD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAoB9D;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAyB5E;AAED,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,aAAa,GAAG,OAAO,CAE/F;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG;IAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAOvF"}
|
|
@@ -23,6 +23,7 @@ import { isAbsolute, join, resolve } from "path";
|
|
|
23
23
|
import { pathToFileURL } from "url";
|
|
24
24
|
import { isLexiconPlugin } from "../../lexicon.js";
|
|
25
25
|
import { ensureTypeScriptLoader } from "../../ts-loader.js";
|
|
26
|
+
import { esModuleNamespace } from "../../module-interop.js";
|
|
26
27
|
/**
|
|
27
28
|
* The module a lexicon package presents to consumers.
|
|
28
29
|
*
|
|
@@ -64,7 +65,7 @@ export async function loadLexiconFromDir(dir) {
|
|
|
64
65
|
let mod;
|
|
65
66
|
try {
|
|
66
67
|
ensureTypeScriptLoader();
|
|
67
|
-
mod = (await import(pathToFileURL(entry).href));
|
|
68
|
+
mod = esModuleNamespace((await import(pathToFileURL(entry).href)));
|
|
68
69
|
}
|
|
69
70
|
catch (error) {
|
|
70
71
|
return { entry, error: `import failed: ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/lint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAW,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/lint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAW,MAAM,iBAAiB,CAAC;AAyCzE;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAW5D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAoBhC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,WAAW,CAAC;AAsBnD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,WAAW,CAAC;AA2I9C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,uBAAuB;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,oBAAoB;IACpB,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IACrC,qCAAqC;IACrC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AA6eD;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA+N3E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAIxD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,GACtC,MAAM,IAAI,CAiCZ"}
|
|
@@ -30,6 +30,7 @@ import { getProvenance } from "../../provenance.js";
|
|
|
30
30
|
import { runLexiconPostSynthChecks } from "./build.js";
|
|
31
31
|
import { armSandboxPolicyExecution, runProjectPolicies } from "../../lint/policy-sandbox.js";
|
|
32
32
|
import { ensureTypeScriptLoader } from "../../ts-loader.js";
|
|
33
|
+
import { esModuleNamespace } from "../../module-interop.js";
|
|
33
34
|
// Import config loader
|
|
34
35
|
import { loadConfig, resolveRulesForFile, resolveConfiguredSeverity, findProjectRoot } from "../../lint/config.js";
|
|
35
36
|
import { loadChantConfig, resolveKnowledgeDir, resolveDiscoveryGlobs } from "../../config.js";
|
|
@@ -79,7 +80,7 @@ export async function loadPluginRules(plugins, configDir) {
|
|
|
79
80
|
let mod;
|
|
80
81
|
try {
|
|
81
82
|
ensureTypeScriptLoader();
|
|
82
|
-
mod = await import(resolved);
|
|
83
|
+
mod = esModuleNamespace(await import(resolved));
|
|
83
84
|
}
|
|
84
85
|
catch (err) {
|
|
85
86
|
throw new Error(`Failed to load plugin "${pluginPath}": ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -482,7 +483,7 @@ async function runOpCheckDiagnostics(infraPath, files, buildParams, plugins = []
|
|
|
482
483
|
for (const filePath of opFiles) {
|
|
483
484
|
try {
|
|
484
485
|
ensureTypeScriptLoader();
|
|
485
|
-
const mod = await import(filePath);
|
|
486
|
+
const mod = esModuleNamespace(await import(filePath));
|
|
486
487
|
const entity = mod.default;
|
|
487
488
|
if (!entity || typeof entity !== "object")
|
|
488
489
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/components/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/components/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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 -49,6 +49,7 @@ import { hasDiscoveryMarkerSync } from "../discovery/files.js";
|
|
|
49
49
|
import { resolveDiscoveryGlobs } from "../config.js";
|
|
50
50
|
import { walkDiscovery, workspaceMemberDirs } from "../discovery/walk.js";
|
|
51
51
|
import { ensureTypeScriptLoader } from "../ts-loader.js";
|
|
52
|
+
import { esModuleNamespace } from "../module-interop.js";
|
|
52
53
|
/**
|
|
53
54
|
* Every `*.component.ts` file under `path`, through the one discovery walk
|
|
54
55
|
* (`../discovery/walk.ts`, #2527): the same dot-directory, `dist`,
|
|
@@ -127,7 +128,7 @@ async function importAndCollectComponents(sourceFiles) {
|
|
|
127
128
|
// a bare "." path) would otherwise be treated by `import()` as a bare
|
|
128
129
|
// package specifier and fail with "Cannot find package 'x.component.ts'".
|
|
129
130
|
ensureTypeScriptLoader();
|
|
130
|
-
const exports = await import(pathToFileURL(resolve(filePath)).href);
|
|
131
|
+
const exports = esModuleNamespace(await import(pathToFileURL(resolve(filePath)).href));
|
|
131
132
|
modules.push({ file: filePath, exports });
|
|
132
133
|
}
|
|
133
134
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-sandbox.d.ts","sourceRoot":"","sources":["../src/config-sandbox.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"config-sandbox.d.ts","sourceRoot":"","sources":["../src/config-sandbox.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAoDtG;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AAED,kEAAkE;AAClE,wBAAgB,8BAA8B,IAAI,OAAO,CAExD;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,IAAI,IAAI,CAG3D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,qBAAqB,GAAG,OAAO,CAK5E;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,EAClB,WAAW,GAAE,MAA4B,GACxC,OAAO,CAAC,OAAO,CAAC,CAclB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAUlF"}
|
package/dist/config-sandbox.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
2
|
import { importConfigModule, requireConfigModule } from "./config-import.js";
|
|
3
|
+
import { esModuleNamespace } from "./module-interop.js";
|
|
3
4
|
/**
|
|
4
5
|
* chant #1113 — decides WHERE a project's `chant.config.ts` is evaluated.
|
|
5
6
|
*
|
|
@@ -77,7 +78,10 @@ export function resetSandboxConfigEvaluationForTests() {
|
|
|
77
78
|
* evaluated, never how its result is read.
|
|
78
79
|
*/
|
|
79
80
|
export function selectConfigExport(namespace) {
|
|
80
|
-
|
|
81
|
+
// A config tsx compiled as CommonJS arrives as `{ default: module.exports }`
|
|
82
|
+
// under a native import (#3897); read the module's own namespace instead.
|
|
83
|
+
const ns = esModuleNamespace(namespace);
|
|
84
|
+
return ns.default ?? ns.config ?? ns;
|
|
81
85
|
}
|
|
82
86
|
/**
|
|
83
87
|
* Evaluate a project's `chant.config.ts` and return its configuration object,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/discovery/import.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/discovery/import.ts"],"names":[],"mappings":"AA8BA;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAclC"}
|
package/dist/discovery/import.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DiscoveryError } from "../errors.js";
|
|
2
2
|
import { ensureTypeScriptLoader } from "../ts-loader.js";
|
|
3
|
+
import { esModuleNamespace } from "../module-interop.js";
|
|
3
4
|
/**
|
|
4
5
|
* Modules whose evaluation threw, and the error each threw with (#2368).
|
|
5
6
|
*
|
|
@@ -54,7 +55,7 @@ export async function importModule(path) {
|
|
|
54
55
|
throw failed;
|
|
55
56
|
try {
|
|
56
57
|
ensureTypeScriptLoader();
|
|
57
|
-
return await import(path);
|
|
58
|
+
return esModuleNamespace(await import(path));
|
|
58
59
|
}
|
|
59
60
|
catch (error) {
|
|
60
61
|
const message = error instanceof Error ? error.message : "Unknown import error";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../../src/discovery/sandbox/driver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../../src/discovery/sandbox/driver.ts"],"names":[],"mappings":"AAgEA,MAAM,WAAW,qBAAqB;IACpC,qIAAqI;IACrI,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,oNAAoN;IACpN,SAAS,EAAE,MAAM,CAAC;CACnB;AAOD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,EAAE,CAsB3E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAqH3E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CA8CrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAiGjF"}
|
|
@@ -56,6 +56,8 @@ const POST_SYNTH_MODULE = join(dirname(DISCOVERY_DIR), "lint", "post-synth.ts");
|
|
|
56
56
|
// file, so the driver's `setBuildParams` call below mutates the one object
|
|
57
57
|
// every bundled import observes.
|
|
58
58
|
const PARAMS_MODULE = join(dirname(DISCOVERY_DIR), "params.ts");
|
|
59
|
+
// #3897: a project file tsx compiled as CommonJS reads as its own namespace.
|
|
60
|
+
const INTEROP_MODULE = join(dirname(DISCOVERY_DIR), "module-interop.ts");
|
|
59
61
|
/** Escape a value for embedding as a JS/TS source-level literal. */
|
|
60
62
|
function lit(value) {
|
|
61
63
|
return JSON.stringify(value);
|
|
@@ -116,6 +118,7 @@ export function generateDriverSource(options) {
|
|
|
116
118
|
`import { classifyChildError } from ${lit(CHILD_ERRORS_MODULE)};`,
|
|
117
119
|
`import { getProvenance } from ${lit(PROVENANCE_MODULE)};`,
|
|
118
120
|
`import { setBuildParams } from ${lit(PARAMS_MODULE)};`,
|
|
121
|
+
`import { esModuleNamespace } from ${lit(INTEROP_MODULE)};`,
|
|
119
122
|
`import { writeSync } from "node:fs";`,
|
|
120
123
|
``,
|
|
121
124
|
`const BUILD_ROOT = ${lit(buildRoot)};`,
|
|
@@ -163,7 +166,7 @@ export function generateDriverSource(options) {
|
|
|
163
166
|
` const errors = [];`,
|
|
164
167
|
];
|
|
165
168
|
for (const file of files) {
|
|
166
|
-
lines.push(` importing = ${lit(file)};`, ` try {`, ` const mod = await import(${lit(file)});`, ` modules.push({ file: ${lit(file)}, exports: mod });`, ` } catch (err) {`, ` errors.push(classifyChildError(${lit(file)}, err).toJSON());`, ` }`, ` importing = undefined;`);
|
|
169
|
+
lines.push(` importing = ${lit(file)};`, ` try {`, ` const mod = esModuleNamespace(await import(${lit(file)}));`, ` modules.push({ file: ${lit(file)}, exports: mod });`, ` } catch (err) {`, ` errors.push(classifyChildError(${lit(file)}, err).toJSON());`, ` }`, ` importing = undefined;`);
|
|
167
170
|
}
|
|
168
171
|
lines.push(``, ` let entities = new Map();`, ` try {`, ` entities = collectEntities(modules, BUILD_ROOT);`, ` } catch (err) {`, ` errors.push(classifyChildError(errFile(err), err, "resolution").toJSON());`, ` await send({ entitySet: { entities: [] }, errors, provenanceByName: {} });`, ` return;`, ` }`, ``,
|
|
169
172
|
// Recorded BEFORE resolveAttrRefs/encode — not for the parent's own
|
|
@@ -198,6 +201,7 @@ export function generateConfigDriverSource(configPath) {
|
|
|
198
201
|
return [
|
|
199
202
|
`import { classifyChildError } from ${lit(CHILD_ERRORS_MODULE)};`,
|
|
200
203
|
`import { scanConfigWireSafety } from ${lit(CONFIG_WIRE_MODULE)};`,
|
|
204
|
+
`import { esModuleNamespace } from ${lit(INTEROP_MODULE)};`,
|
|
201
205
|
`import { writeSync } from "node:fs";`,
|
|
202
206
|
``,
|
|
203
207
|
...sendFunctionSource(),
|
|
@@ -205,7 +209,7 @@ export function generateConfigDriverSource(configPath) {
|
|
|
205
209
|
`async function main() {`,
|
|
206
210
|
` let namespace;`,
|
|
207
211
|
` try {`,
|
|
208
|
-
` namespace = await import(${lit(configPath)});`,
|
|
212
|
+
` namespace = esModuleNamespace(await import(${lit(configPath)}));`,
|
|
209
213
|
` } catch (err) {`,
|
|
210
214
|
` await send({ kind: "chant-config", ok: false, error: classifyChildError(${lit(configPath)}, err).toJSON() });`,
|
|
211
215
|
` return;`,
|
|
@@ -273,6 +277,7 @@ export function generatePolicyDriverSource(policyPaths) {
|
|
|
273
277
|
`import { classifyChildError } from ${lit(CHILD_ERRORS_MODULE)};`,
|
|
274
278
|
`import { decodePolicyBuildResult, scanPolicyDiagnostics, PolicyWireError } from ${lit(POLICY_WIRE_MODULE)};`,
|
|
275
279
|
`import { runPostSynthChecks, isPostSynthCheck } from ${lit(POST_SYNTH_MODULE)};`,
|
|
280
|
+
`import { esModuleNamespace } from ${lit(INTEROP_MODULE)};`,
|
|
276
281
|
`import { writeSync } from "node:fs";`,
|
|
277
282
|
``,
|
|
278
283
|
...sendFunctionSource(),
|
|
@@ -315,7 +320,7 @@ export function generatePolicyDriverSource(policyPaths) {
|
|
|
315
320
|
// the same order `loadPolicyChecks` collects in, so the diagnostics sequence
|
|
316
321
|
// matches the in-process one exactly.
|
|
317
322
|
for (const policyPath of policyPaths) {
|
|
318
|
-
lines.push(` try {`, ` const mod = await import(${lit(policyPath)});`, ` for (const value of Object.values(mod)) {`, ` if (isPostSynthCheck(value)) checks.push(guard(value, ${lit(policyPath)}));`, ` }`, ` } catch (err) {`, ` await fail(${lit(policyPath)}, err, "import");`, ` return;`, ` }`);
|
|
323
|
+
lines.push(` try {`, ` const mod = esModuleNamespace(await import(${lit(policyPath)}));`, ` for (const value of Object.values(mod)) {`, ` if (isPostSynthCheck(value)) checks.push(guard(value, ${lit(policyPath)}));`, ` }`, ` } catch (err) {`, ` await fail(${lit(policyPath)}, err, "import");`, ` return;`, ` }`);
|
|
319
324
|
}
|
|
320
325
|
lines.push(``, ` let diagnostics;`, ` try {`, ` diagnostics = runPostSynthChecks(checks, buildResult, request.env ?? undefined);`, ` } catch (err) {`, ` await fail("", err, "resolution");`, ` return;`, ` }`, ``, ` await send({ kind: "chant-policy", ok: true, diagnostics });`, `}`, ``,
|
|
321
326
|
// Registered synchronously at module top level — see the doc above on why
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicon-module.d.ts","sourceRoot":"","sources":["../src/lexicon-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;
|
|
1
|
+
{"version":3,"file":"lexicon-module.d.ts","sourceRoot":"","sources":["../src/lexicon-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1F,mEAAmE;AACn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B,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAYpG;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAsB,EAC/B,KAAK,GAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAe,GAC/C,MAAM,CAKR;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK,GAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAe,GAC/C,MAAM,EAAE,CAEV;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI9D;AAUD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAsB,GAAG,MAAM,GAAG,SAAS,CAMpG;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAW1H"}
|
package/dist/lexicon-module.js
CHANGED
|
@@ -27,6 +27,7 @@ import { createRequire } from "node:module";
|
|
|
27
27
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
28
28
|
import { pathToFileURL } from "node:url";
|
|
29
29
|
import { ensureTypeScriptLoader } from "./ts-loader.js";
|
|
30
|
+
import { esModuleNamespace } from "./module-interop.js";
|
|
30
31
|
/** The lexicon name an entry declares, whichever form it takes. */
|
|
31
32
|
export function lexiconDeclarationName(entry) {
|
|
32
33
|
return typeof entry === "string" ? entry : entry.name;
|
|
@@ -156,7 +157,7 @@ export async function importLexiconModule(name) {
|
|
|
156
157
|
return undefined;
|
|
157
158
|
try {
|
|
158
159
|
ensureTypeScriptLoader();
|
|
159
|
-
return (await import(path));
|
|
160
|
+
return esModuleNamespace((await import(path)));
|
|
160
161
|
}
|
|
161
162
|
catch (err) {
|
|
162
163
|
throw new Error(`lexicon "${name}" is declared with module ${path}, which could not be loaded: ` +
|
|
@@ -227,7 +228,7 @@ export function resolveFromProject(spec, fromDir = process.cwd()) {
|
|
|
227
228
|
export async function importLexiconPackage(spec, fromDir = process.cwd()) {
|
|
228
229
|
try {
|
|
229
230
|
ensureTypeScriptLoader();
|
|
230
|
-
return (await import(spec));
|
|
231
|
+
return esModuleNamespace((await import(spec)));
|
|
231
232
|
}
|
|
232
233
|
catch (err) {
|
|
233
234
|
const pkg = packageNameOf(spec);
|
|
@@ -236,6 +237,6 @@ export async function importLexiconPackage(spec, fromDir = process.cwd()) {
|
|
|
236
237
|
const resolved = resolveFromProject(spec, fromDir);
|
|
237
238
|
if (resolved === undefined)
|
|
238
239
|
throw err;
|
|
239
|
-
return (await import(pathToFileURL(resolved).href));
|
|
240
|
+
return esModuleNamespace((await import(pathToFileURL(resolved).href)));
|
|
240
241
|
}
|
|
241
242
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-import.d.ts","sourceRoot":"","sources":["../../src/lint/policy-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"policy-import.d.ts","sourceRoot":"","sources":["../../src/lint/policy-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAED,iEAAiE;AACjE,wBAAgB,6BAA6B,IAAI,OAAO,CAEvD;AAED,4IAA4I;AAC5I,wBAAgB,mCAAmC,IAAI,IAAI,CAE1D;AAED,2HAA2H;AAC3H,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAQ3F"}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* that might forget to ask.
|
|
24
24
|
*/
|
|
25
25
|
import { ensureTypeScriptLoader } from "../ts-loader.js";
|
|
26
|
+
import { esModuleNamespace } from "../module-interop.js";
|
|
26
27
|
/** Whether this process must run project policy modules inside the sandbox boundary instead of here. */
|
|
27
28
|
let armed = false;
|
|
28
29
|
/**
|
|
@@ -58,5 +59,5 @@ export async function importPolicyModule(policyPath) {
|
|
|
58
59
|
throw new Error(`Refusing to import the policy module ${policyPath} into the chant process under --sandbox: it is project-authored code and must be imported inside the sandbox boundary (packages/core/src/lint/policy-sandbox.ts's runProjectPolicies).`);
|
|
59
60
|
}
|
|
60
61
|
ensureTypeScriptLoader();
|
|
61
|
-
return (await import(policyPath));
|
|
62
|
+
return esModuleNamespace((await import(policyPath)));
|
|
62
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-loader.d.ts","sourceRoot":"","sources":["../../src/lint/rule-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"rule-loader.d.ts","sourceRoot":"","sources":["../../src/lint/rule-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAiDvC;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAsC5E"}
|
package/dist/lint/rule-loader.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readdirSync, existsSync } from "fs";
|
|
2
2
|
import { dirname, join, resolve } from "path";
|
|
3
3
|
import { ensureTypeScriptLoader } from "../ts-loader.js";
|
|
4
|
+
import { esModuleNamespace } from "../module-interop.js";
|
|
4
5
|
/**
|
|
5
6
|
* Type guard to check if a value conforms to the LintRule interface.
|
|
6
7
|
*/
|
|
@@ -74,7 +75,7 @@ export async function loadLocalRules(projectDir) {
|
|
|
74
75
|
let mod;
|
|
75
76
|
try {
|
|
76
77
|
ensureTypeScriptLoader();
|
|
77
|
-
mod = await import(filePath);
|
|
78
|
+
mod = esModuleNamespace(await import(filePath));
|
|
78
79
|
}
|
|
79
80
|
catch (err) {
|
|
80
81
|
throw new Error(`Failed to load rule file "${file}": ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The namespace a project module was authored with, whichever module format
|
|
3
|
+
* tsx compiled it to (#3897).
|
|
4
|
+
*
|
|
5
|
+
* A `.ts` file with no `"type": "module"` `package.json` above it is compiled
|
|
6
|
+
* by tsx as CommonJS: `exports.default = ...` plus a non-enumerable
|
|
7
|
+
* `__esModule: true` marker. The compiled CLI loads project files with a
|
|
8
|
+
* native `import()`, and Node hands a CommonJS module back as a namespace
|
|
9
|
+
* whose `default` is the whole `module.exports`. So `export default x` arrives
|
|
10
|
+
* as `namespace.default.default`. Under the source CLI tsx's ESM loader sits
|
|
11
|
+
* in front of the `import()` and does this interop itself, which is why the
|
|
12
|
+
* nesting only showed up once the CLI ran compiled (#3879).
|
|
13
|
+
*
|
|
14
|
+
* When `namespace.default` carries the `__esModule` marker, the module's real
|
|
15
|
+
* namespace is that exports object: this returns a copy of it with the marker
|
|
16
|
+
* left out. Anything else, including an ES module whose default export is an
|
|
17
|
+
* object that happens to have a `default` key, is returned unchanged.
|
|
18
|
+
*/
|
|
19
|
+
export declare function esModuleNamespace<T extends Record<string, unknown>>(namespace: T): T;
|
|
20
|
+
//# sourceMappingURL=module-interop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-interop.d.ts","sourceRoot":"","sources":["../src/module-interop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAWpF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The namespace a project module was authored with, whichever module format
|
|
3
|
+
* tsx compiled it to (#3897).
|
|
4
|
+
*
|
|
5
|
+
* A `.ts` file with no `"type": "module"` `package.json` above it is compiled
|
|
6
|
+
* by tsx as CommonJS: `exports.default = ...` plus a non-enumerable
|
|
7
|
+
* `__esModule: true` marker. The compiled CLI loads project files with a
|
|
8
|
+
* native `import()`, and Node hands a CommonJS module back as a namespace
|
|
9
|
+
* whose `default` is the whole `module.exports`. So `export default x` arrives
|
|
10
|
+
* as `namespace.default.default`. Under the source CLI tsx's ESM loader sits
|
|
11
|
+
* in front of the `import()` and does this interop itself, which is why the
|
|
12
|
+
* nesting only showed up once the CLI ran compiled (#3879).
|
|
13
|
+
*
|
|
14
|
+
* When `namespace.default` carries the `__esModule` marker, the module's real
|
|
15
|
+
* namespace is that exports object: this returns a copy of it with the marker
|
|
16
|
+
* left out. Anything else, including an ES module whose default export is an
|
|
17
|
+
* object that happens to have a `default` key, is returned unchanged.
|
|
18
|
+
*/
|
|
19
|
+
export function esModuleNamespace(namespace) {
|
|
20
|
+
// `in` before the read: a vitest factory mock throws on reading an export
|
|
21
|
+
// it does not define, and most modules have no `default` at all.
|
|
22
|
+
if (namespace === null || typeof namespace !== "object" || !("default" in namespace))
|
|
23
|
+
return namespace;
|
|
24
|
+
const exported = namespace.default;
|
|
25
|
+
if (!isCommonJsEsModule(exported))
|
|
26
|
+
return namespace;
|
|
27
|
+
const unwrapped = {};
|
|
28
|
+
for (const key of Object.keys(exported)) {
|
|
29
|
+
if (key !== "__esModule")
|
|
30
|
+
unwrapped[key] = exported[key];
|
|
31
|
+
}
|
|
32
|
+
return unwrapped;
|
|
33
|
+
}
|
|
34
|
+
/** A CommonJS `module.exports` that a compiler marked as an ES module. */
|
|
35
|
+
function isCommonJsEsModule(value) {
|
|
36
|
+
return (value !== null &&
|
|
37
|
+
(typeof value === "object" || typeof value === "function") &&
|
|
38
|
+
value.__esModule === true);
|
|
39
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/op/discover.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/op/discover.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAI1E,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AA6GD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA6CrF;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,kBAAkB,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACzC,wCAAwC;IACxC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,2GAA2G;IAC3G,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA2C/F"}
|
package/dist/op/discover.js
CHANGED
|
@@ -6,6 +6,7 @@ import { hasDiscoveryMarkerSync } from "../discovery/files.js";
|
|
|
6
6
|
import { resolveDiscoveryGlobs } from "../config.js";
|
|
7
7
|
import { isStewardDeclaration } from "./steward.js";
|
|
8
8
|
import { ensureTypeScriptLoader } from "../ts-loader.js";
|
|
9
|
+
import { esModuleNamespace } from "../module-interop.js";
|
|
9
10
|
async function findGitRoot(cwd) {
|
|
10
11
|
const rt = getRuntime();
|
|
11
12
|
const result = await rt.spawn(["git", "rev-parse", "--show-toplevel"], { cwd });
|
|
@@ -132,7 +133,7 @@ export async function discoverOps(opts) {
|
|
|
132
133
|
for (const filePath of files) {
|
|
133
134
|
try {
|
|
134
135
|
ensureTypeScriptLoader();
|
|
135
|
-
const mod = (await import(filePath));
|
|
136
|
+
const mod = esModuleNamespace((await import(filePath)));
|
|
136
137
|
const exported = opsExportedBy(mod);
|
|
137
138
|
// A file may hold a steward and no Op (#2731): the steward sits beside
|
|
138
139
|
// the Ops it runs, and `discoverStewards` reads it from here.
|
|
@@ -180,7 +181,7 @@ export async function discoverStewards(opts) {
|
|
|
180
181
|
let mod;
|
|
181
182
|
try {
|
|
182
183
|
ensureTypeScriptLoader();
|
|
183
|
-
mod = (await import(filePath));
|
|
184
|
+
mod = esModuleNamespace((await import(filePath)));
|
|
184
185
|
}
|
|
185
186
|
catch (err) {
|
|
186
187
|
errors.push(`${filePath}: ${err instanceof Error ? err.message : String(err)}`);
|