frontmcp 1.1.0 → 1.1.2-beta.1
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 +5 -5
- package/src/commands/build/adapters/cloudflare.js +56 -4
- package/src/commands/build/adapters/cloudflare.js.map +1 -1
- package/src/commands/build/adapters/distributed.js +4 -1
- package/src/commands/build/adapters/distributed.js.map +1 -1
- package/src/commands/build/adapters/lambda.js +32 -0
- package/src/commands/build/adapters/lambda.js.map +1 -1
- package/src/commands/build/bundler.js +23 -1
- package/src/commands/build/bundler.js.map +1 -1
- package/src/commands/build/exec/cli-runtime/extract-public-message.snippet.d.ts +18 -0
- package/src/commands/build/exec/cli-runtime/extract-public-message.snippet.js +58 -0
- package/src/commands/build/exec/cli-runtime/extract-public-message.snippet.js.map +1 -0
- package/src/commands/build/exec/cli-runtime/generate-cli-entry.d.ts +2 -2
- package/src/commands/build/exec/cli-runtime/generate-cli-entry.js +195 -47
- package/src/commands/build/exec/cli-runtime/generate-cli-entry.js.map +1 -1
- package/src/commands/build/exec/cli-runtime/schema-extractor.d.ts +7 -0
- package/src/commands/build/exec/cli-runtime/schema-extractor.js +17 -1
- package/src/commands/build/exec/cli-runtime/schema-extractor.js.map +1 -1
- package/src/commands/build/exec/index.d.ts +11 -0
- package/src/commands/build/exec/index.js +68 -20
- package/src/commands/build/exec/index.js.map +1 -1
- package/src/commands/build/exec/installer-script.d.ts +8 -2
- package/src/commands/build/exec/installer-script.js +34 -15
- package/src/commands/build/exec/installer-script.js.map +1 -1
- package/src/commands/build/exec/manifest.d.ts +16 -3
- package/src/commands/build/exec/manifest.js +17 -5
- package/src/commands/build/exec/manifest.js.map +1 -1
- package/src/commands/build/exec/runner-script.d.ts +9 -1
- package/src/commands/build/exec/runner-script.js +60 -2
- package/src/commands/build/exec/runner-script.js.map +1 -1
- package/src/commands/build/index.js +86 -22
- package/src/commands/build/index.js.map +1 -1
- package/src/commands/build/load-entry-config.d.ts +33 -0
- package/src/commands/build/load-entry-config.js +206 -0
- package/src/commands/build/load-entry-config.js.map +1 -0
- package/src/commands/build/mcpb/manifest.d.ts +14 -0
- package/src/commands/build/mcpb/manifest.js +29 -0
- package/src/commands/build/mcpb/manifest.js.map +1 -1
- package/src/commands/build/types.d.ts +36 -1
- package/src/commands/build/types.js.map +1 -1
- package/src/commands/dev/doctor.js +7 -3
- package/src/commands/dev/doctor.js.map +1 -1
- package/src/commands/package/install.d.ts +1 -1
- package/src/commands/package/install.js +10 -8
- package/src/commands/package/install.js.map +1 -1
- package/src/commands/package/types.d.ts +2 -1
- package/src/commands/package/types.js.map +1 -1
- package/src/config/frontmcp-config.loader.d.ts +20 -0
- package/src/config/frontmcp-config.loader.js +152 -5
- package/src/config/frontmcp-config.loader.js.map +1 -1
- package/src/config/index.d.ts +1 -1
- package/src/config/index.js +2 -1
- package/src/config/index.js.map +1 -1
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.loadFrontMcpConfig = loadFrontMcpConfig;
|
|
10
|
+
exports.tryLoadFrontMcpConfig = tryLoadFrontMcpConfig;
|
|
10
11
|
exports.validateConfig = validateConfig;
|
|
11
12
|
exports.findDeployment = findDeployment;
|
|
12
13
|
exports.getDeploymentTargets = getDeploymentTargets;
|
|
13
14
|
const tslib_1 = require("tslib");
|
|
14
15
|
const fs = tslib_1.__importStar(require("fs"));
|
|
15
16
|
const path = tslib_1.__importStar(require("path"));
|
|
17
|
+
const utils_1 = require("@frontmcp/utils");
|
|
16
18
|
const frontmcp_config_schema_1 = require("./frontmcp-config.schema");
|
|
17
19
|
const CONFIG_FILENAMES = [
|
|
18
20
|
'frontmcp.config.ts',
|
|
@@ -36,6 +38,57 @@ async function loadFrontMcpConfig(cwd) {
|
|
|
36
38
|
const raw = await loadRawConfig(cwd);
|
|
37
39
|
return validateConfig(raw);
|
|
38
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Variant that load-errors propagate (parse failures in `frontmcp.config.ts`,
|
|
43
|
+
* missing dependencies, etc.) but schema-validation errors return `undefined`.
|
|
44
|
+
*
|
|
45
|
+
* Used by `runBuild` to support both shapes: the new top-level
|
|
46
|
+
* `frontmcpConfigSchema` (with `deployments`) and the older exec-only shape
|
|
47
|
+
* (top-level `cli`, `sea`, `esbuild`) that `loadExecConfig` consumes
|
|
48
|
+
* directly. A user with the old shape should still get a successful build
|
|
49
|
+
* — the exec-loader picks the file up from disk by itself.
|
|
50
|
+
*
|
|
51
|
+
* Returns `undefined` when:
|
|
52
|
+
* - no config file is present (caller falls back to CLI flags), or
|
|
53
|
+
* - the file loads but doesn't match the new schema (legacy shape).
|
|
54
|
+
*
|
|
55
|
+
* Throws when:
|
|
56
|
+
* - the file exists but can't be parsed (TS syntax error, ESM/CJS mismatch
|
|
57
|
+
* that even esbuild can't recover from, etc.) — i.e., #365 silent-default
|
|
58
|
+
* regressions.
|
|
59
|
+
*/
|
|
60
|
+
async function tryLoadFrontMcpConfig(cwd) {
|
|
61
|
+
let raw;
|
|
62
|
+
try {
|
|
63
|
+
raw = await loadRawConfig(cwd);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
// Distinguish "no config and no package.json" from real load failures.
|
|
67
|
+
// `deriveFromPackageJson` throws this exact message — treat it as "no config".
|
|
68
|
+
if (err.message?.startsWith('No frontmcp.config found')) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
const result = frontmcp_config_schema_1.frontmcpConfigSchema.safeParse(raw);
|
|
74
|
+
if (!result.success) {
|
|
75
|
+
// Distinguish two failure shapes:
|
|
76
|
+
// 1. Legacy exec-only config — top-level `cli` / `sea` / `esbuild`,
|
|
77
|
+
// no `deployments` key. Return undefined so `loadExecConfig` picks
|
|
78
|
+
// it up directly. Pre-v1.1 fixtures live in this branch.
|
|
79
|
+
// 2. Anything else — looks like the user attempted a v1.1 config and
|
|
80
|
+
// got it wrong (typo'd `deployments`, invalid `target`, etc.).
|
|
81
|
+
// Throw so we don't silently fall back to defaults — that was the
|
|
82
|
+
// silent-corruption mode #365 was trying to eliminate.
|
|
83
|
+
const obj = typeof raw === 'object' && raw !== null ? raw : undefined;
|
|
84
|
+
const isLegacyExecOnlyShape = !!obj && !('deployments' in obj) && ('cli' in obj || 'sea' in obj || 'esbuild' in obj);
|
|
85
|
+
if (isLegacyExecOnlyShape)
|
|
86
|
+
return undefined;
|
|
87
|
+
const issues = result.error.issues.map((i) => ` - ${i.path.join('.')}: ${i.message}`).join('\n');
|
|
88
|
+
throw new Error(`Invalid frontmcp.config:\n${issues}`);
|
|
89
|
+
}
|
|
90
|
+
return result.data;
|
|
91
|
+
}
|
|
39
92
|
/**
|
|
40
93
|
* Load raw config without validation.
|
|
41
94
|
*/
|
|
@@ -49,15 +102,43 @@ async function loadRawConfig(cwd) {
|
|
|
49
102
|
return JSON.parse(content);
|
|
50
103
|
}
|
|
51
104
|
if (filename.endsWith('.ts')) {
|
|
52
|
-
//
|
|
105
|
+
// #365 — When the project is `"type": "commonjs"` (the default),
|
|
106
|
+
// `require()` can't load .ts without a hook and `await import()` emits
|
|
107
|
+
// Node's `Failed to load the ES module … Make sure to set "type": "module"`
|
|
108
|
+
// warning to stderr regardless of whether type-stripping eventually
|
|
109
|
+
// succeeds — that warning by itself looked to retesters like a hard
|
|
110
|
+
// load failure even when the build proceeded. Round 2: when the host
|
|
111
|
+
// project is CJS, skip Node's `await import()` entirely and go
|
|
112
|
+
// straight to esbuild. For ESM projects we still try the runtime
|
|
113
|
+
// paths first (faster, no transpile cost). Either way, a failure on
|
|
114
|
+
// every path throws the combined error — never silent defaults.
|
|
115
|
+
const isCjsProject = await isCommonJsProject(cwd);
|
|
116
|
+
let requireErr;
|
|
53
117
|
try {
|
|
54
118
|
const mod = require(configPath);
|
|
55
119
|
return mod.default ?? mod;
|
|
56
120
|
}
|
|
57
|
-
catch {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
121
|
+
catch (e) {
|
|
122
|
+
requireErr = e;
|
|
123
|
+
}
|
|
124
|
+
if (!isCjsProject) {
|
|
125
|
+
try {
|
|
126
|
+
const mod = await import(configPath);
|
|
127
|
+
return mod.default ?? mod;
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Fall through to esbuild.
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
return await loadTsConfigViaEsbuild(configPath);
|
|
135
|
+
}
|
|
136
|
+
catch (esbuildErr) {
|
|
137
|
+
throw new Error(`Failed to load ${filename}.\n` +
|
|
138
|
+
` require() error: ${requireErr?.message ?? '(skipped)'}\n` +
|
|
139
|
+
` esbuild error: ${esbuildErr.message}\n` +
|
|
140
|
+
`Hint: ensure the file exports a default config (e.g., ` +
|
|
141
|
+
`\`export default defineConfig({...})\`) and that all imports resolve.`);
|
|
61
142
|
}
|
|
62
143
|
}
|
|
63
144
|
// JS/MJS/CJS
|
|
@@ -71,6 +152,72 @@ async function loadRawConfig(cwd) {
|
|
|
71
152
|
// Fallback: derive from package.json
|
|
72
153
|
return deriveFromPackageJson(cwd);
|
|
73
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Read the host project's `package.json.type` to decide whether `await import()`
|
|
157
|
+
* of a `.ts` file is worth attempting. Returns true when the project is
|
|
158
|
+
* declared `"type": "commonjs"` or omits the field entirely (Node's default).
|
|
159
|
+
*
|
|
160
|
+
* Read errors (no package.json, malformed JSON) are treated as "CJS" — that's
|
|
161
|
+
* the safer default for the loader because it routes us through esbuild
|
|
162
|
+
* transpilation rather than relying on Node's experimental TS handling.
|
|
163
|
+
*
|
|
164
|
+
* Routed through `@frontmcp/utils` per repo convention so this module
|
|
165
|
+
* doesn't reach into `node:fs` for an ad-hoc package.json read.
|
|
166
|
+
*/
|
|
167
|
+
async function isCommonJsProject(cwd) {
|
|
168
|
+
try {
|
|
169
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
170
|
+
const contents = await (0, utils_1.readFile)(pkgPath);
|
|
171
|
+
const pkg = JSON.parse(contents);
|
|
172
|
+
return pkg.type !== 'module';
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Transpile a TypeScript config file with esbuild (CJS target) and eval the
|
|
180
|
+
* result via Module-via-vm. Used as a last-resort path when neither `require()`
|
|
181
|
+
* (no ts-node hook) nor `await import()` (project is `"type": "commonjs"`)
|
|
182
|
+
* can load the file directly.
|
|
183
|
+
*
|
|
184
|
+
* Uses `esbuild.build({ bundle: true, packages: 'external' })` rather than
|
|
185
|
+
* `transformSync` so a config that imports a sibling helper TS file
|
|
186
|
+
* (`import { foo } from './helpers'`) gets the helper inlined into the
|
|
187
|
+
* compiled output. Without bundling, the resulting CJS would emit
|
|
188
|
+
* `require('./helpers')` which Node can't resolve under `"type": "commonjs"`.
|
|
189
|
+
*
|
|
190
|
+
* `packages: 'external'` keeps node_modules dependencies as runtime
|
|
191
|
+
* `require()` calls so `import { defineConfig } from 'frontmcp'` still
|
|
192
|
+
* resolves against the project's installed copy of the SDK.
|
|
193
|
+
*/
|
|
194
|
+
async function loadTsConfigViaEsbuild(configPath) {
|
|
195
|
+
const esbuild = require('esbuild');
|
|
196
|
+
const built = await esbuild.build({
|
|
197
|
+
entryPoints: [configPath],
|
|
198
|
+
bundle: true,
|
|
199
|
+
write: false,
|
|
200
|
+
platform: 'node',
|
|
201
|
+
format: 'cjs',
|
|
202
|
+
target: 'es2022',
|
|
203
|
+
packages: 'external',
|
|
204
|
+
sourcemap: 'inline',
|
|
205
|
+
logLevel: 'silent',
|
|
206
|
+
});
|
|
207
|
+
if (!built.outputFiles || built.outputFiles.length === 0) {
|
|
208
|
+
throw new Error('esbuild produced no output for ' + configPath);
|
|
209
|
+
}
|
|
210
|
+
const code = built.outputFiles[0].text;
|
|
211
|
+
const Module = require('module');
|
|
212
|
+
const m = new Module(configPath, module);
|
|
213
|
+
// Make the loaded module's `require` resolve relative to the config dir
|
|
214
|
+
// so user `import { defineConfig } from 'frontmcp'` keeps working.
|
|
215
|
+
m.filename = configPath;
|
|
216
|
+
m.paths = Module._nodeModulePaths(path.dirname(configPath));
|
|
217
|
+
m._compile(code, configPath);
|
|
218
|
+
const exported = m.exports;
|
|
219
|
+
return exported?.default ?? exported;
|
|
220
|
+
}
|
|
74
221
|
/**
|
|
75
222
|
* Derive minimal config from package.json.
|
|
76
223
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmcp-config.loader.js","sourceRoot":"","sources":["../../../src/config/frontmcp-config.loader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA2BH,gDAGC;AAgED,wCAOC;AAKD,wCAEC;AAKD,oDAEC;;AAjHD,+CAAyB;AACzB,mDAA6B;AAE7B,qEAA2F;AAG3F,MAAM,gBAAgB,GAAG;IACvB,oBAAoB;IACpB,oBAAoB;IACpB,sBAAsB;IACtB,qBAAqB;IACrB,qBAAqB;CACtB,CAAC;AAEF;;;;;;;;;;GAUG;AACI,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAClD,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,aAAa,CAAC,GAAW;IACtC,KAAK,MAAM,QAAQ,IAAI,gBAAgB,EAAE,CAAC;QACxC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,SAAS;QAEzC,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,O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config from package.json.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { frontmcpConfigSchema, type FrontMcpConfigParsed } from './frontmcp-config.schema';\nimport type { DeploymentTarget, FrontMcpConfig } from './frontmcp-config.types';\n\nconst CONFIG_FILENAMES = [\n 'frontmcp.config.ts',\n 'frontmcp.config.js',\n 'frontmcp.config.json',\n 'frontmcp.config.mjs',\n 'frontmcp.config.cjs',\n];\n\n/**\n * Load and validate a frontmcp.config file from the given directory.\n *\n * Resolution order:\n * 1. frontmcp.config.ts\n * 2. frontmcp.config.js\n * 3. frontmcp.config.json\n * 4. frontmcp.config.mjs\n * 5. frontmcp.config.cjs\n * 6. Derive from package.json (minimal config with 'node' target)\n */\nexport async function loadFrontMcpConfig(cwd: string): Promise<FrontMcpConfigParsed> {\n const raw = await loadRawConfig(cwd);\n return validateConfig(raw);\n}\n\n/**\n * Load raw config without validation.\n */\nasync function loadRawConfig(cwd: string): Promise<unknown> {\n for (const filename of CONFIG_FILENAMES) {\n const configPath = path.join(cwd, filename);\n if (!fs.existsSync(configPath)) continue;\n\n if (filename.endsWith('.json')) {\n const content = fs.readFileSync(configPath, 'utf-8');\n return JSON.parse(content);\n }\n\n if (filename.endsWith('.ts')) {\n // TypeScript config — try tsx or ts-node for runtime loading\n try {\n const mod = require(configPath);\n return mod.default ?? mod;\n } catch {\n // If require fails (no ts-node), try dynamic import\n const mod = await import(configPath);\n return mod.default ?? mod;\n }\n }\n\n // JS/MJS/CJS\n if (filename.endsWith('.mjs')) {\n const mod = await import(configPath);\n return mod.default ?? mod;\n }\n\n const mod = require(configPath);\n return mod.default ?? mod;\n }\n\n // Fallback: derive from package.json\n return deriveFromPackageJson(cwd);\n}\n\n/**\n * Derive minimal config from package.json.\n */\nfunction deriveFromPackageJson(cwd: string): FrontMcpConfig {\n const pkgPath = path.join(cwd, 'package.json');\n if (!fs.existsSync(pkgPath)) {\n throw new Error(\n 'No frontmcp.config found and no package.json. Create a frontmcp.config.ts to configure build targets.',\n );\n }\n\n const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));\n return {\n name: pkg.name?.replace(/^@[^/]+\\//, '') || path.basename(cwd),\n version: pkg.version || '1.0.0',\n entry: pkg.main,\n deployments: [{ target: 'node' }],\n };\n}\n\n/**\n * Validate raw config against the Zod schema.\n */\nexport function validateConfig(raw: unknown): FrontMcpConfigParsed {\n const result = frontmcpConfigSchema.safeParse(raw);\n if (!result.success) {\n const issues = result.error.issues.map((i) => ` - ${i.path.join('.')}: ${i.message}`).join('\\n');\n throw new Error(`Invalid frontmcp.config:\\n${issues}`);\n }\n return result.data;\n}\n\n/**\n * Find a deployment target by type.\n */\nexport function findDeployment(config: FrontMcpConfigParsed, target: string): DeploymentTarget | undefined {\n return config.deployments.find((d) => d.target === target);\n}\n\n/**\n * Get all deployment target types from the config.\n */\nexport function getDeploymentTargets(config: FrontMcpConfigParsed): string[] {\n return config.deployments.map((d) => d.target);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"frontmcp-config.loader.js","sourceRoot":"","sources":["../../../src/config/frontmcp-config.loader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA6BH,gDAGC;AAqBD,sDA8BC;AAkKD,wCAOC;AAKD,wCAEC;AAKD,oDAEC;;AAxQD,+CAAyB;AACzB,mDAA6B;AAE7B,2CAA2C;AAE3C,qEAA2F;AAG3F,MAAM,gBAAgB,GAAG;IACvB,oBAAoB;IACpB,oBAAoB;IACpB,sBAAsB;IACtB,qBAAqB;IACrB,qBAAqB;CACtB,CAAC;AAEF;;;;;;;;;;GAUG;AACI,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAClD,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,UAAU,qBAAqB,CAAC,GAAW;IACrD,IAAI,GAAY,CAAC;IACjB,IAAI,C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EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/**\n * FrontMCP Config Loader\n *\n * Loads `frontmcp.config.(json|js|ts|mjs|cjs)` from a directory.\n * Falls back to deriving minimal config from package.json.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { readFile } from '@frontmcp/utils';\n\nimport { frontmcpConfigSchema, type FrontMcpConfigParsed } from './frontmcp-config.schema';\nimport type { DeploymentTarget, FrontMcpConfig } from './frontmcp-config.types';\n\nconst CONFIG_FILENAMES = [\n 'frontmcp.config.ts',\n 'frontmcp.config.js',\n 'frontmcp.config.json',\n 'frontmcp.config.mjs',\n 'frontmcp.config.cjs',\n];\n\n/**\n * Load and validate a frontmcp.config file from the given directory.\n *\n * Resolution order:\n * 1. frontmcp.config.ts\n * 2. frontmcp.config.js\n * 3. frontmcp.config.json\n * 4. frontmcp.config.mjs\n * 5. frontmcp.config.cjs\n * 6. Derive from package.json (minimal config with 'node' target)\n */\nexport async function loadFrontMcpConfig(cwd: string): Promise<FrontMcpConfigParsed> {\n const raw = await loadRawConfig(cwd);\n return validateConfig(raw);\n}\n\n/**\n * Variant that load-errors propagate (parse failures in `frontmcp.config.ts`,\n * missing dependencies, etc.) but schema-validation errors return `undefined`.\n *\n * Used by `runBuild` to support both shapes: the new top-level\n * `frontmcpConfigSchema` (with `deployments`) and the older exec-only shape\n * (top-level `cli`, `sea`, `esbuild`) that `loadExecConfig` consumes\n * directly. A user with the old shape should still get a successful build\n * — the exec-loader picks the file up from disk by itself.\n *\n * Returns `undefined` when:\n * - no config file is present (caller falls back to CLI flags), or\n * - the file loads but doesn't match the new schema (legacy shape).\n *\n * Throws when:\n * - the file exists but can't be parsed (TS syntax error, ESM/CJS mismatch\n * that even esbuild can't recover from, etc.) — i.e., #365 silent-default\n * regressions.\n */\nexport async function tryLoadFrontMcpConfig(cwd: string): Promise<FrontMcpConfigParsed | undefined> {\n let raw: unknown;\n try {\n raw = await loadRawConfig(cwd);\n } catch (err) {\n // Distinguish \"no config and no package.json\" from real load failures.\n // `deriveFromPackageJson` throws this exact message — treat it as \"no config\".\n if ((err as Error).message?.startsWith('No frontmcp.config found')) {\n return undefined;\n }\n throw err;\n }\n const result = frontmcpConfigSchema.safeParse(raw);\n if (!result.success) {\n // Distinguish two failure shapes:\n // 1. Legacy exec-only config — top-level `cli` / `sea` / `esbuild`,\n // no `deployments` key. Return undefined so `loadExecConfig` picks\n // it up directly. Pre-v1.1 fixtures live in this branch.\n // 2. Anything else — looks like the user attempted a v1.1 config and\n // got it wrong (typo'd `deployments`, invalid `target`, etc.).\n // Throw so we don't silently fall back to defaults — that was the\n // silent-corruption mode #365 was trying to eliminate.\n const obj = typeof raw === 'object' && raw !== null ? (raw as Record<string, unknown>) : undefined;\n const isLegacyExecOnlyShape =\n !!obj && !('deployments' in obj) && ('cli' in obj || 'sea' in obj || 'esbuild' in obj);\n if (isLegacyExecOnlyShape) return undefined;\n const issues = result.error.issues.map((i) => ` - ${i.path.join('.')}: ${i.message}`).join('\\n');\n throw new Error(`Invalid frontmcp.config:\\n${issues}`);\n }\n return result.data;\n}\n\n/**\n * Load raw config without validation.\n */\nasync function loadRawConfig(cwd: string): Promise<unknown> {\n for (const filename of CONFIG_FILENAMES) {\n const configPath = path.join(cwd, filename);\n if (!fs.existsSync(configPath)) continue;\n\n if (filename.endsWith('.json')) {\n const content = fs.readFileSync(configPath, 'utf-8');\n return JSON.parse(content);\n }\n\n if (filename.endsWith('.ts')) {\n // #365 — When the project is `\"type\": \"commonjs\"` (the default),\n // `require()` can't load .ts without a hook and `await import()` emits\n // Node's `Failed to load the ES module … Make sure to set \"type\": \"module\"`\n // warning to stderr regardless of whether type-stripping eventually\n // succeeds — that warning by itself looked to retesters like a hard\n // load failure even when the build proceeded. Round 2: when the host\n // project is CJS, skip Node's `await import()` entirely and go\n // straight to esbuild. For ESM projects we still try the runtime\n // paths first (faster, no transpile cost). Either way, a failure on\n // every path throws the combined error — never silent defaults.\n const isCjsProject = await isCommonJsProject(cwd);\n let requireErr: Error | undefined;\n try {\n const mod = require(configPath);\n return mod.default ?? mod;\n } catch (e) {\n requireErr = e as Error;\n }\n if (!isCjsProject) {\n try {\n const mod = await import(configPath);\n return mod.default ?? mod;\n } catch {\n // Fall through to esbuild.\n }\n }\n try {\n return await loadTsConfigViaEsbuild(configPath);\n } catch (esbuildErr) {\n throw new Error(\n `Failed to load ${filename}.\\n` +\n ` require() error: ${requireErr?.message ?? '(skipped)'}\\n` +\n ` esbuild error: ${(esbuildErr as Error).message}\\n` +\n `Hint: ensure the file exports a default config (e.g., ` +\n `\\`export default defineConfig({...})\\`) and that all imports resolve.`,\n );\n }\n }\n\n // JS/MJS/CJS\n if (filename.endsWith('.mjs')) {\n const mod = await import(configPath);\n return mod.default ?? mod;\n }\n\n const mod = require(configPath);\n return mod.default ?? mod;\n }\n\n // Fallback: derive from package.json\n return deriveFromPackageJson(cwd);\n}\n\n/**\n * Read the host project's `package.json.type` to decide whether `await import()`\n * of a `.ts` file is worth attempting. Returns true when the project is\n * declared `\"type\": \"commonjs\"` or omits the field entirely (Node's default).\n *\n * Read errors (no package.json, malformed JSON) are treated as \"CJS\" — that's\n * the safer default for the loader because it routes us through esbuild\n * transpilation rather than relying on Node's experimental TS handling.\n *\n * Routed through `@frontmcp/utils` per repo convention so this module\n * doesn't reach into `node:fs` for an ad-hoc package.json read.\n */\nasync function isCommonJsProject(cwd: string): Promise<boolean> {\n try {\n const pkgPath = path.join(cwd, 'package.json');\n const contents = await readFile(pkgPath);\n const pkg = JSON.parse(contents) as { type?: string };\n return pkg.type !== 'module';\n } catch {\n return true;\n }\n}\n\n/**\n * Transpile a TypeScript config file with esbuild (CJS target) and eval the\n * result via Module-via-vm. Used as a last-resort path when neither `require()`\n * (no ts-node hook) nor `await import()` (project is `\"type\": \"commonjs\"`)\n * can load the file directly.\n *\n * Uses `esbuild.build({ bundle: true, packages: 'external' })` rather than\n * `transformSync` so a config that imports a sibling helper TS file\n * (`import { foo } from './helpers'`) gets the helper inlined into the\n * compiled output. Without bundling, the resulting CJS would emit\n * `require('./helpers')` which Node can't resolve under `\"type\": \"commonjs\"`.\n *\n * `packages: 'external'` keeps node_modules dependencies as runtime\n * `require()` calls so `import { defineConfig } from 'frontmcp'` still\n * resolves against the project's installed copy of the SDK.\n */\nasync function loadTsConfigViaEsbuild(configPath: string): Promise<unknown> {\n const esbuild = require('esbuild') as typeof import('esbuild');\n const built = await esbuild.build({\n entryPoints: [configPath],\n bundle: true,\n write: false,\n platform: 'node',\n format: 'cjs',\n target: 'es2022',\n packages: 'external',\n sourcemap: 'inline',\n logLevel: 'silent',\n });\n if (!built.outputFiles || built.outputFiles.length === 0) {\n throw new Error('esbuild produced no output for ' + configPath);\n }\n const code = built.outputFiles[0].text;\n\n const Module = require('module') as typeof import('module');\n const m = new Module(configPath, module);\n // Make the loaded module's `require` resolve relative to the config dir\n // so user `import { defineConfig } from 'frontmcp'` keeps working.\n m.filename = configPath;\n m.paths = (Module as unknown as { _nodeModulePaths(p: string): string[] })._nodeModulePaths(path.dirname(configPath));\n\n (m as any)._compile(code, configPath);\n\n const exported = (m as any).exports as { default?: unknown };\n return exported?.default ?? exported;\n}\n\n/**\n * Derive minimal config from package.json.\n */\nfunction deriveFromPackageJson(cwd: string): FrontMcpConfig {\n const pkgPath = path.join(cwd, 'package.json');\n if (!fs.existsSync(pkgPath)) {\n throw new Error(\n 'No frontmcp.config found and no package.json. Create a frontmcp.config.ts to configure build targets.',\n );\n }\n\n const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));\n return {\n name: pkg.name?.replace(/^@[^/]+\\//, '') || path.basename(cwd),\n version: pkg.version || '1.0.0',\n entry: pkg.main,\n deployments: [{ target: 'node' }],\n };\n}\n\n/**\n * Validate raw config against the Zod schema.\n */\nexport function validateConfig(raw: unknown): FrontMcpConfigParsed {\n const result = frontmcpConfigSchema.safeParse(raw);\n if (!result.success) {\n const issues = result.error.issues.map((i) => ` - ${i.path.join('.')}: ${i.message}`).join('\\n');\n throw new Error(`Invalid frontmcp.config:\\n${issues}`);\n }\n return result.data;\n}\n\n/**\n * Find a deployment target by type.\n */\nexport function findDeployment(config: FrontMcpConfigParsed, target: string): DeploymentTarget | undefined {\n return config.deployments.find((d) => d.target === target);\n}\n\n/**\n * Get all deployment target types from the config.\n */\nexport function getDeploymentTargets(config: FrontMcpConfigParsed): string[] {\n return config.deployments.map((d) => d.target);\n}\n"]}
|
package/src/config/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { defineConfig } from './define-config';
|
|
2
|
-
export { loadFrontMcpConfig, validateConfig, findDeployment, getDeploymentTargets } from './frontmcp-config.loader';
|
|
2
|
+
export { loadFrontMcpConfig, tryLoadFrontMcpConfig, validateConfig, findDeployment, getDeploymentTargets, } from './frontmcp-config.loader';
|
|
3
3
|
export { frontmcpConfigSchema } from './frontmcp-config.schema';
|
|
4
4
|
export type { FrontMcpConfigParsed } from './frontmcp-config.schema';
|
|
5
5
|
export type { FrontMcpConfig, ServerDefaults, DeploymentTarget, DeploymentTargetType } from './frontmcp-config.types';
|
package/src/config/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.frontmcpConfigSchema = exports.getDeploymentTargets = exports.findDeployment = exports.validateConfig = exports.loadFrontMcpConfig = exports.defineConfig = void 0;
|
|
3
|
+
exports.frontmcpConfigSchema = exports.getDeploymentTargets = exports.findDeployment = exports.validateConfig = exports.tryLoadFrontMcpConfig = exports.loadFrontMcpConfig = exports.defineConfig = void 0;
|
|
4
4
|
var define_config_1 = require("./define-config");
|
|
5
5
|
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return define_config_1.defineConfig; } });
|
|
6
6
|
var frontmcp_config_loader_1 = require("./frontmcp-config.loader");
|
|
7
7
|
Object.defineProperty(exports, "loadFrontMcpConfig", { enumerable: true, get: function () { return frontmcp_config_loader_1.loadFrontMcpConfig; } });
|
|
8
|
+
Object.defineProperty(exports, "tryLoadFrontMcpConfig", { enumerable: true, get: function () { return frontmcp_config_loader_1.tryLoadFrontMcpConfig; } });
|
|
8
9
|
Object.defineProperty(exports, "validateConfig", { enumerable: true, get: function () { return frontmcp_config_loader_1.validateConfig; } });
|
|
9
10
|
Object.defineProperty(exports, "findDeployment", { enumerable: true, get: function () { return frontmcp_config_loader_1.findDeployment; } });
|
|
10
11
|
Object.defineProperty(exports, "getDeploymentTargets", { enumerable: true, get: function () { return frontmcp_config_loader_1.getDeploymentTargets; } });
|
package/src/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,mEAMkC;AALhC,4HAAA,kBAAkB,OAAA;AAClB,+HAAA,qBAAqB,OAAA;AACrB,wHAAA,cAAc,OAAA;AACd,wHAAA,cAAc,OAAA;AACd,8HAAA,oBAAoB,OAAA;AAEtB,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA","sourcesContent":["export { defineConfig } from './define-config';\nexport {\n loadFrontMcpConfig,\n tryLoadFrontMcpConfig,\n validateConfig,\n findDeployment,\n getDeploymentTargets,\n} from './frontmcp-config.loader';\nexport { frontmcpConfigSchema } from './frontmcp-config.schema';\nexport type { FrontMcpConfigParsed } from './frontmcp-config.schema';\nexport type { FrontMcpConfig, ServerDefaults, DeploymentTarget, DeploymentTargetType } from './frontmcp-config.types';\n"]}
|