@memberjunction/server-bootstrap 6.1.0-edge.4 → 6.1.0-edge.6
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/README.md +3 -1
- package/dist/generated/mj-class-registrations.d.ts +1 -5
- package/dist/generated/mj-class-registrations.d.ts.map +1 -1
- package/dist/generated/mj-class-registrations.js +71 -14
- package/dist/generated/mj-class-registrations.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +127 -128
- package/dist/index.js.map +1 -1
- package/package.json +118 -117
- package/dist/host-import.d.ts +0 -37
- package/dist/host-import.d.ts.map +0 -1
- package/dist/host-import.js +0 -103
- package/dist/host-import.js.map +0 -1
package/dist/host-import.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* True when the error is a module-RESOLUTION failure (the module could not be found or
|
|
3
|
-
* reached), as opposed to a module that was found but threw while loading — the latter is
|
|
4
|
-
* a real error that must surface. ESM raises ERR_MODULE_NOT_FOUND, CommonJS resolution
|
|
5
|
-
* (createRequire) raises MODULE_NOT_FOUND, and an exports-map mismatch raises
|
|
6
|
-
* ERR_PACKAGE_PATH_NOT_EXPORTED. Some ESM loader shims (ts-node's, notably — the loader
|
|
7
|
-
* MJAPI runs under) throw resolution failures as PLAIN Errors with no code at all, so
|
|
8
|
-
* when there is no code, recognize Node's own resolver message instead.
|
|
9
|
-
*
|
|
10
|
-
* ⚠ Under ts-node's shim the coded branch never fires (the shim strips custom error
|
|
11
|
-
* properties crossing the module-hooks thread), so the message branch is LOAD-BEARING
|
|
12
|
-
* there: if a future Node rewords its resolver messages, this predicate must be updated
|
|
13
|
-
* or the pnpm fallback silently stops working under ts-node hosts.
|
|
14
|
-
*
|
|
15
|
-
* Keep in sync with `IsModuleResolutionFailure` in @memberjunction/open-app-engine's
|
|
16
|
-
* `src/install/migration-runner.ts` — same heuristic, duplicated because the two
|
|
17
|
-
* packages cannot depend on each other and cross-package re-exports are disallowed.
|
|
18
|
-
*/
|
|
19
|
-
export declare function isResolutionFailure(error: unknown): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Imports a runtime-configured package from the HOST application's context.
|
|
22
|
-
*
|
|
23
|
-
* Resolution and evaluation are handled separately on the fallback path: an anchor that
|
|
24
|
-
* cannot SEE the package means "try the next anchor", but once an anchor resolves it,
|
|
25
|
-
* any failure from loading the module (a missing transitive dependency, a throw in its
|
|
26
|
-
* top-level code) is the module's own problem and is surfaced as-is — never masked by
|
|
27
|
-
* the original "cannot find package" error.
|
|
28
|
-
*
|
|
29
|
-
* Note on the resolver: `createRequire().resolve` runs under CommonJS conditions, so a
|
|
30
|
-
* package whose exports map declares ONLY an `"import"` condition cannot be resolved by
|
|
31
|
-
* the fallback (surfaced with an actionable error). On a dual CJS/ESM package it selects
|
|
32
|
-
* the CJS entry, so `import()` of that file would load a second physical module instance
|
|
33
|
-
* alongside any ESM copy already in the process — fine for MJ-shaped single-condition
|
|
34
|
-
* packages, but keep it in mind before widening this mechanism.
|
|
35
|
-
*/
|
|
36
|
-
export declare function importFromHost(pkgName: string, configFilePath?: string): Promise<Record<string, unknown>>;
|
|
37
|
-
//# sourceMappingURL=host-import.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host-import.d.ts","sourceRoot":"","sources":["../src/host-import.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM3D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA6C/G"}
|
package/dist/host-import.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host-anchored dynamic import for runtime-configured packages.
|
|
3
|
-
*
|
|
4
|
-
* A bare `import(pkgName)` resolves from THIS package (server-bootstrap), which cannot
|
|
5
|
-
* declare packages whose names are only known at runtime — mj.config.cjs supplies them.
|
|
6
|
-
* npm's hoisted node_modules let that bare import resolve by accident; pnpm's strict
|
|
7
|
-
* per-package layout does not, because the packages are declared by (and linked into) the
|
|
8
|
-
* HOST application, e.g. MJAPI. `importFromHost` tries the bare import first (identical
|
|
9
|
-
* behavior to before on npm layouts) and, when the package cannot be resolved, retries
|
|
10
|
-
* from each host anchor — the working directory, the mj.config.cjs that named the
|
|
11
|
-
* package, and the process entrypoint. (Dynamic import is justified here as runtime
|
|
12
|
-
* plugin discovery: the names come from configuration, not code.)
|
|
13
|
-
*/
|
|
14
|
-
import { createRequire } from 'node:module';
|
|
15
|
-
import { pathToFileURL } from 'node:url';
|
|
16
|
-
import path from 'node:path';
|
|
17
|
-
/**
|
|
18
|
-
* True when the error is a module-RESOLUTION failure (the module could not be found or
|
|
19
|
-
* reached), as opposed to a module that was found but threw while loading — the latter is
|
|
20
|
-
* a real error that must surface. ESM raises ERR_MODULE_NOT_FOUND, CommonJS resolution
|
|
21
|
-
* (createRequire) raises MODULE_NOT_FOUND, and an exports-map mismatch raises
|
|
22
|
-
* ERR_PACKAGE_PATH_NOT_EXPORTED. Some ESM loader shims (ts-node's, notably — the loader
|
|
23
|
-
* MJAPI runs under) throw resolution failures as PLAIN Errors with no code at all, so
|
|
24
|
-
* when there is no code, recognize Node's own resolver message instead.
|
|
25
|
-
*
|
|
26
|
-
* ⚠ Under ts-node's shim the coded branch never fires (the shim strips custom error
|
|
27
|
-
* properties crossing the module-hooks thread), so the message branch is LOAD-BEARING
|
|
28
|
-
* there: if a future Node rewords its resolver messages, this predicate must be updated
|
|
29
|
-
* or the pnpm fallback silently stops working under ts-node hosts.
|
|
30
|
-
*
|
|
31
|
-
* Keep in sync with `IsModuleResolutionFailure` in @memberjunction/open-app-engine's
|
|
32
|
-
* `src/install/migration-runner.ts` — same heuristic, duplicated because the two
|
|
33
|
-
* packages cannot depend on each other and cross-package re-exports are disallowed.
|
|
34
|
-
*/
|
|
35
|
-
export function isResolutionFailure(error) {
|
|
36
|
-
const { code, message } = error ?? {};
|
|
37
|
-
if (code === 'ERR_MODULE_NOT_FOUND' || code === 'MODULE_NOT_FOUND' || code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
return code === undefined && typeof message === 'string' && /^Cannot find (package|module) /.test(message);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Imports a runtime-configured package from the HOST application's context.
|
|
44
|
-
*
|
|
45
|
-
* Resolution and evaluation are handled separately on the fallback path: an anchor that
|
|
46
|
-
* cannot SEE the package means "try the next anchor", but once an anchor resolves it,
|
|
47
|
-
* any failure from loading the module (a missing transitive dependency, a throw in its
|
|
48
|
-
* top-level code) is the module's own problem and is surfaced as-is — never masked by
|
|
49
|
-
* the original "cannot find package" error.
|
|
50
|
-
*
|
|
51
|
-
* Note on the resolver: `createRequire().resolve` runs under CommonJS conditions, so a
|
|
52
|
-
* package whose exports map declares ONLY an `"import"` condition cannot be resolved by
|
|
53
|
-
* the fallback (surfaced with an actionable error). On a dual CJS/ESM package it selects
|
|
54
|
-
* the CJS entry, so `import()` of that file would load a second physical module instance
|
|
55
|
-
* alongside any ESM copy already in the process — fine for MJ-shaped single-condition
|
|
56
|
-
* packages, but keep it in mind before widening this mechanism.
|
|
57
|
-
*/
|
|
58
|
-
export async function importFromHost(pkgName, configFilePath) {
|
|
59
|
-
try {
|
|
60
|
-
return (await import(pkgName));
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
if (!isResolutionFailure(error)) {
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
// Anchor priority: the mj.config.cjs that NAMED the package is the authoritative host,
|
|
67
|
-
// so it is consulted first — cwd can be a different checkout entirely (an operator
|
|
68
|
-
// launching instance A's server from instance B's directory would otherwise silently
|
|
69
|
-
// load B's copy). cwd and the process entrypoint are fallbacks for hosts whose config
|
|
70
|
-
// lives outside the tree that carries the packages (e.g. a workspace-root config with
|
|
71
|
-
// the packages linked into the app directory).
|
|
72
|
-
const anchors = [
|
|
73
|
-
configFilePath,
|
|
74
|
-
path.join(process.cwd(), 'package.json'),
|
|
75
|
-
process.argv[1],
|
|
76
|
-
].filter((anchor) => typeof anchor === 'string' && anchor.length > 0);
|
|
77
|
-
let sawExportsMapMismatch = false;
|
|
78
|
-
for (const anchor of anchors) {
|
|
79
|
-
let resolved;
|
|
80
|
-
try {
|
|
81
|
-
resolved = createRequire(anchor).resolve(pkgName);
|
|
82
|
-
}
|
|
83
|
-
catch (resolveError) {
|
|
84
|
-
if (resolveError?.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
85
|
-
sawExportsMapMismatch = true;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (!isResolutionFailure(resolveError)) {
|
|
89
|
-
throw resolveError;
|
|
90
|
-
}
|
|
91
|
-
continue; // this anchor can't see the package — try the next
|
|
92
|
-
}
|
|
93
|
-
// Resolved. Anything that fails from here is the module's own problem — surface it.
|
|
94
|
-
return (await import(pathToFileURL(resolved).href));
|
|
95
|
-
}
|
|
96
|
-
if (sawExportsMapMismatch) {
|
|
97
|
-
throw new Error(`Package '${pkgName}' is reachable from the host, but its exports map has no CJS-resolvable condition ` +
|
|
98
|
-
`(add a "default" or "require" condition to its package.json exports), so the host-anchored fallback cannot load it.`, { cause: error });
|
|
99
|
-
}
|
|
100
|
-
throw error; // no anchor resolved it — surface the original bare-import failure
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=host-import.js.map
|
package/dist/host-import.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host-import.js","sourceRoot":"","sources":["../src/host-import.ts"],"names":[],"mappings":"AAAA;;;;;;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