@appshell/loader 1.0.0-alpha.14 → 1.0.0-alpha.16
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/CHANGELOG.md +7 -0
- package/README.md +19 -21
- package/__tests__/remoteLoader.spec.ts +75 -79
- package/__tests__/resolvers.spec.ts +10 -49
- package/dist/main.js +1 -1
- package/dist/types/config/src/context.d.ts +3 -3
- package/dist/types/config/src/credentials.d.ts +0 -1
- package/dist/types/config/src/credentials.d.ts.map +1 -1
- package/dist/types/config/src/index.d.ts +2 -6
- package/dist/types/config/src/index.d.ts.map +1 -1
- package/dist/types/config/src/publish.d.ts +3 -3
- package/dist/types/config/src/publish.d.ts.map +1 -1
- package/dist/types/config/src/types.d.ts +9 -14
- package/dist/types/config/src/types.d.ts.map +1 -1
- package/dist/types/config/src/utils/index.d.ts +0 -3
- package/dist/types/config/src/utils/index.d.ts.map +1 -1
- package/dist/types/config/src/validators/index.d.ts +0 -2
- package/dist/types/config/src/validators/index.d.ts.map +1 -1
- package/dist/types/loader/src/remoteLoader.d.ts +2 -3
- package/dist/types/loader/src/remoteLoader.d.ts.map +1 -1
- package/dist/types/loader/src/resolvers.d.ts +4 -11
- package/dist/types/loader/src/resolvers.d.ts.map +1 -1
- package/dist/types/runtime/src/errors.d.ts +26 -0
- package/dist/types/runtime/src/errors.d.ts.map +1 -0
- package/dist/types/runtime/src/index.d.ts +4 -0
- package/dist/types/runtime/src/index.d.ts.map +1 -0
- package/dist/types/runtime/src/store.d.ts +26 -0
- package/dist/types/runtime/src/store.d.ts.map +1 -0
- package/dist/types/runtime/src/types.d.ts +10 -0
- package/dist/types/runtime/src/types.d.ts.map +1 -0
- package/package.json +7 -3
- package/src/remoteLoader.ts +11 -18
- package/src/resolvers.ts +7 -64
- package/webpack.config.js +5 -0
- package/dist/types/config/src/deregister.d.ts +0 -3
- package/dist/types/config/src/deregister.d.ts.map +0 -1
- package/dist/types/config/src/generate.env.d.ts +0 -3
- package/dist/types/config/src/generate.env.d.ts.map +0 -1
- package/dist/types/config/src/generate.global-config.d.ts +0 -10
- package/dist/types/config/src/generate.global-config.d.ts.map +0 -1
- package/dist/types/config/src/register.d.ts +0 -4
- package/dist/types/config/src/register.d.ts.map +0 -1
- package/dist/types/config/src/utils/isValidUrl.d.ts +0 -3
- package/dist/types/config/src/utils/isValidUrl.d.ts.map +0 -1
- package/dist/types/config/src/utils/loadJson.d.ts +0 -10
- package/dist/types/config/src/utils/loadJson.d.ts.map +0 -1
- package/dist/types/config/src/utils/merge.d.ts +0 -4
- package/dist/types/config/src/utils/merge.d.ts.map +0 -1
- package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts +0 -4
- package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts.map +0 -1
- package/dist/types/config/src/validators/AppshellManifestValidator.d.ts +0 -4
- package/dist/types/config/src/validators/AppshellManifestValidator.d.ts.map +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { AppshellComposition
|
|
1
|
+
import type { AppshellComposition } from '@appshell/config';
|
|
2
2
|
import { type RemoteResolver } from './resolvers';
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
5
|
-
[key: string]: unknown;
|
|
6
5
|
__appshell_config__?: AppshellComposition;
|
|
7
6
|
}
|
|
8
7
|
}
|
|
@@ -11,6 +10,6 @@ export type RemoteLoaderOptions = {
|
|
|
11
10
|
/** Replaces the resolver chain outright; a seam for tests and embedders. */
|
|
12
11
|
resolver?: RemoteResolver;
|
|
13
12
|
};
|
|
14
|
-
declare const _default: (
|
|
13
|
+
declare const _default: (options?: RemoteLoaderOptions) => <TComponent>(key: string) => Promise<readonly [Awaited<TComponent>, import("@appshell/config").ResolvedRemote]>;
|
|
15
14
|
export default _default;
|
|
16
15
|
//# sourceMappingURL=remoteLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteLoader.d.ts","sourceRoot":"","sources":["../../../../src/remoteLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"remoteLoader.d.ts","sourceRoot":"","sources":["../../../../src/remoteLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAoD,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAEpG,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;KAC3C;CACF;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;mCAEuB,mBAAmB,MAQ5B,UAAU,OAAO,MAAM;AARvC,wBA2CE"}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import type { AppshellComposition,
|
|
1
|
+
import type { AppshellComposition, ResolvedRemote } from '@appshell/config';
|
|
2
2
|
export type RemoteResolution = {
|
|
3
3
|
remote: ResolvedRemote;
|
|
4
|
-
/** Already merged with the
|
|
5
|
-
|
|
6
|
-
/** Back-compat payload for `ManifestProvider`; synthesized when the source was a composition. */
|
|
7
|
-
manifest: AppshellManifest;
|
|
4
|
+
/** Already merged with the application's overrides — nothing left for the browser to layer on. */
|
|
5
|
+
vars: Record<string, string | number | undefined>;
|
|
8
6
|
};
|
|
9
7
|
export type RemoteResolver = (key: string) => Promise<RemoteResolution | undefined>;
|
|
10
8
|
/** The registry inlined the composition into the page, so no network call is needed. */
|
|
11
9
|
export declare const inlineResolver: (composition?: AppshellComposition) => RemoteResolver;
|
|
12
|
-
/** Fetch-on-miss: covers
|
|
10
|
+
/** Fetch-on-miss: covers a package activated after this page was served. */
|
|
13
11
|
export declare const registryResolver: (composition?: AppshellComposition, origin?: string) => RemoteResolver;
|
|
14
|
-
/**
|
|
15
|
-
* Pre-registry hosts: follow `index[key]` to the app's own manifest. The override
|
|
16
|
-
* merge stays here because in this mode no server has done it.
|
|
17
|
-
*/
|
|
18
|
-
export declare const legacyManifestResolver: (config: AppshellGlobalConfig) => RemoteResolver;
|
|
19
12
|
export declare const chainResolvers: (...resolvers: RemoteResolver[]) => RemoteResolver;
|
|
20
13
|
//# sourceMappingURL=resolvers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../../src/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../../src/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE5E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,kGAAkG;IAClG,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;AAEpF,wFAAwF;AACxF,eAAO,MAAM,cAAc,iBACV,mBAAmB,KAAG,cASpC,CAAC;AAEJ,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,iBACZ,mBAAmB,sBAAgB,cAcjD,CAAC;AAEJ,eAAO,MAAM,cAAc,iBACV,cAAc,EAAE,KAAG,cAUjC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A package asked for vars that were never delivered.
|
|
3
|
+
*
|
|
4
|
+
* Almost always one of three things: the package was loaded outside `remoteLoader`
|
|
5
|
+
* (a test, a storybook, a direct import), the host and the package resolved separate
|
|
6
|
+
* copies of `@appshell/runtime` because one of them failed to declare it as a
|
|
7
|
+
* singleton, or the scope compiled into the package is not the scope the registry
|
|
8
|
+
* knows it by.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MissingVarsError extends Error {
|
|
11
|
+
readonly scope: string;
|
|
12
|
+
constructor(scope: string, known: string[]);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Something tried to replace vars that were already delivered for a scope.
|
|
16
|
+
*
|
|
17
|
+
* The first write wins and is final. Within one page load a scope has exactly one
|
|
18
|
+
* vars object — both resolvers read it from the same `composition.vars[scope]` — so a
|
|
19
|
+
* differing second write is a bug or a package reaching for a scope that is not its own,
|
|
20
|
+
* and neither should be applied quietly.
|
|
21
|
+
*/
|
|
22
|
+
export declare class VarsConflictError extends Error {
|
|
23
|
+
readonly scope: string;
|
|
24
|
+
constructor(scope: string);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../runtime/src/errors.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;CAc3C;AAED;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,KAAK,EAAE,MAAM;CAS1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../runtime/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAChE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Vars } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Delivers a scope's vars. Called by `@appshell/loader` immediately before the remote
|
|
4
|
+
* is loaded, so they are in place before the package's modules evaluate.
|
|
5
|
+
*
|
|
6
|
+
* The first write for a scope wins and is frozen. Re-delivering the identical vars is a
|
|
7
|
+
* no-op — the same remote can be mounted more than once — but replacing them throws.
|
|
8
|
+
* That is what keeps one package from overwriting another's: by the time any package
|
|
9
|
+
* evaluates, the host has already written for it.
|
|
10
|
+
*
|
|
11
|
+
* It does not make a scope's vars *private*. Any code on the page can still read another
|
|
12
|
+
* scope by name, and nothing short of a separate realm would change that.
|
|
13
|
+
*/
|
|
14
|
+
export declare const setVars: (scope: string, vars: Vars) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Reads a scope's vars, throwing rather than handing back an empty object — a package
|
|
17
|
+
* that silently renders with no configuration is the failure this replaced.
|
|
18
|
+
*
|
|
19
|
+
* Prefer `getVars()` from `@appshell/vars`, which supplies the scope for you.
|
|
20
|
+
*/
|
|
21
|
+
export declare const readVars: <TVars extends Vars = Vars>(scope: string) => TVars;
|
|
22
|
+
/** Whether a scope has been delivered, for callers that want to branch instead of catch. */
|
|
23
|
+
export declare const hasVars: (scope: string) => boolean;
|
|
24
|
+
/** Test seam. Not part of the contract a package should build on. */
|
|
25
|
+
export declare const resetVars: () => void;
|
|
26
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../runtime/src/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAepC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,UAAW,MAAM,QAAQ,IAAI,KAAG,IAYnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,SAAS,IAAI,gBAAgB,MAAM,KAAG,KAQnE,CAAC;AAEF,4FAA4F;AAC5F,eAAO,MAAM,OAAO,UAAW,MAAM,KAAG,OAA+B,CAAC;AAExE,qEAAqE;AACrE,eAAO,MAAM,SAAS,QAAO,IAE5B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A package's runtime configuration, already merged by the registry — a package's
|
|
3
|
+
* declared vars, then the application's `overrides.vars`.
|
|
4
|
+
*
|
|
5
|
+
* Structurally identical to `AppshellComposition['vars'][scope]` in `@appshell/config`,
|
|
6
|
+
* but declared here rather than imported. This package is a shared singleton loaded
|
|
7
|
+
* into every micro-frontend on the page, so it carries no dependencies at all.
|
|
8
|
+
*/
|
|
9
|
+
export type Vars = Record<string, string | number | undefined>;
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../runtime/src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appshell/loader",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.16",
|
|
4
4
|
"description": "Utility for loading Appshell components",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/loader/src/index.d.ts",
|
|
7
|
-
"repository":
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/appshellhq/appshell.git"
|
|
10
|
+
},
|
|
8
11
|
"author": "Robert Hamilton <rh@navaris.com>",
|
|
9
12
|
"publishConfig": {
|
|
10
13
|
"access": "public",
|
|
@@ -25,7 +28,8 @@
|
|
|
25
28
|
],
|
|
26
29
|
"license": "MIT",
|
|
27
30
|
"dependencies": {
|
|
31
|
+
"@appshell/runtime": "^1.0.0-alpha.16",
|
|
28
32
|
"@module-federation/enhanced": "^2.8.2"
|
|
29
33
|
},
|
|
30
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "68bf9eb95a85e8ea8ab51384e8f050d090b0f5b5"
|
|
31
35
|
}
|
package/src/remoteLoader.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
|
-
import type { AppshellComposition
|
|
2
|
+
import type { AppshellComposition } from '@appshell/config';
|
|
3
|
+
import { setVars } from '@appshell/runtime';
|
|
3
4
|
import loadAppshellComponent from './loadAppshellComponent';
|
|
4
|
-
import {
|
|
5
|
-
chainResolvers,
|
|
6
|
-
inlineResolver,
|
|
7
|
-
legacyManifestResolver,
|
|
8
|
-
registryResolver,
|
|
9
|
-
type RemoteResolver,
|
|
10
|
-
} from './resolvers';
|
|
5
|
+
import { chainResolvers, inlineResolver, registryResolver, type RemoteResolver } from './resolvers';
|
|
11
6
|
|
|
12
7
|
declare global {
|
|
13
8
|
interface Window {
|
|
14
|
-
[key: string]: unknown;
|
|
15
9
|
__appshell_config__?: AppshellComposition;
|
|
16
10
|
}
|
|
17
11
|
}
|
|
@@ -22,17 +16,13 @@ export type RemoteLoaderOptions = {
|
|
|
22
16
|
resolver?: RemoteResolver;
|
|
23
17
|
};
|
|
24
18
|
|
|
25
|
-
export default (
|
|
19
|
+
export default (options: RemoteLoaderOptions = {}) => {
|
|
26
20
|
const composition =
|
|
27
21
|
options.composition ?? (typeof window === 'undefined' ? undefined : window.__appshell_config__);
|
|
28
22
|
|
|
29
23
|
const resolve =
|
|
30
24
|
options.resolver ??
|
|
31
|
-
chainResolvers(
|
|
32
|
-
inlineResolver(composition),
|
|
33
|
-
registryResolver(composition),
|
|
34
|
-
legacyManifestResolver(config),
|
|
35
|
-
);
|
|
25
|
+
chainResolvers(inlineResolver(composition), registryResolver(composition));
|
|
36
26
|
|
|
37
27
|
return async <TComponent>(key: string) => {
|
|
38
28
|
const failed = (err: unknown) =>
|
|
@@ -49,10 +39,13 @@ export default (config: AppshellGlobalConfig, options: RemoteLoaderOptions = {})
|
|
|
49
39
|
throw new Error(`Remote resource not found in registry. Expected: ${key}`);
|
|
50
40
|
}
|
|
51
41
|
|
|
52
|
-
const { remote,
|
|
42
|
+
const { remote, vars } = resolution;
|
|
53
43
|
|
|
54
44
|
try {
|
|
55
|
-
|
|
45
|
+
// Before the remote loads, so a package that validates its vars while its modules
|
|
46
|
+
// evaluate still finds them. `@appshell/runtime` is a shared singleton, so this is
|
|
47
|
+
// the same store the package reads through `getVars()`.
|
|
48
|
+
setVars(remote.scope, vars);
|
|
56
49
|
|
|
57
50
|
const Component = await loadAppshellComponent<TComponent>(
|
|
58
51
|
remote.scope,
|
|
@@ -61,7 +54,7 @@ export default (config: AppshellGlobalConfig, options: RemoteLoaderOptions = {})
|
|
|
61
54
|
remote.shareScope,
|
|
62
55
|
);
|
|
63
56
|
|
|
64
|
-
return [Component,
|
|
57
|
+
return [Component, remote] as const;
|
|
65
58
|
} catch (err) {
|
|
66
59
|
throw failed(err);
|
|
67
60
|
}
|
package/src/resolvers.ts
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AppshellComposition,
|
|
3
|
-
AppshellGlobalConfig,
|
|
4
|
-
AppshellManifest,
|
|
5
|
-
ResolvedRemote,
|
|
6
|
-
} from '@appshell/config';
|
|
1
|
+
import type { AppshellComposition, ResolvedRemote } from '@appshell/config';
|
|
7
2
|
|
|
8
3
|
export type RemoteResolution = {
|
|
9
4
|
remote: ResolvedRemote;
|
|
10
|
-
/** Already merged with the
|
|
11
|
-
|
|
12
|
-
/** Back-compat payload for `ManifestProvider`; synthesized when the source was a composition. */
|
|
13
|
-
manifest: AppshellManifest;
|
|
5
|
+
/** Already merged with the application's overrides — nothing left for the browser to layer on. */
|
|
6
|
+
vars: Record<string, string | number | undefined>;
|
|
14
7
|
};
|
|
15
8
|
|
|
16
9
|
export type RemoteResolver = (key: string) => Promise<RemoteResolution | undefined>;
|
|
17
10
|
|
|
18
|
-
const manifestOf = (composition: AppshellComposition, remotes: AppshellManifest['remotes']) => ({
|
|
19
|
-
remotes,
|
|
20
|
-
environment: composition.environment,
|
|
21
|
-
modules: {},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
11
|
/** The registry inlined the composition into the page, so no network call is needed. */
|
|
25
12
|
export const inlineResolver =
|
|
26
13
|
(composition?: AppshellComposition): RemoteResolver =>
|
|
@@ -30,18 +17,17 @@ export const inlineResolver =
|
|
|
30
17
|
|
|
31
18
|
return {
|
|
32
19
|
remote,
|
|
33
|
-
|
|
34
|
-
manifest: manifestOf(composition, composition.remotes),
|
|
20
|
+
vars: composition.vars[remote.scope] ?? {},
|
|
35
21
|
};
|
|
36
22
|
};
|
|
37
23
|
|
|
38
|
-
/** Fetch-on-miss: covers
|
|
24
|
+
/** Fetch-on-miss: covers a package activated after this page was served. */
|
|
39
25
|
export const registryResolver =
|
|
40
26
|
(composition?: AppshellComposition, origin = ''): RemoteResolver =>
|
|
41
27
|
async (key) => {
|
|
42
28
|
if (!composition) return undefined;
|
|
43
29
|
|
|
44
|
-
const url = `${origin}/v1/
|
|
30
|
+
const url = `${origin}/v1/applications/${composition.applicationId}/remotes/${key}`;
|
|
45
31
|
const response = await fetch(url, { credentials: 'include' });
|
|
46
32
|
if (!response.ok) return undefined;
|
|
47
33
|
|
|
@@ -49,53 +35,10 @@ export const registryResolver =
|
|
|
49
35
|
|
|
50
36
|
return {
|
|
51
37
|
remote,
|
|
52
|
-
|
|
53
|
-
manifest: manifestOf(composition, { [key]: remote }),
|
|
38
|
+
vars: composition.vars[remote.scope] ?? {},
|
|
54
39
|
};
|
|
55
40
|
};
|
|
56
41
|
|
|
57
|
-
/**
|
|
58
|
-
* Pre-registry hosts: follow `index[key]` to the app's own manifest. The override
|
|
59
|
-
* merge stays here because in this mode no server has done it.
|
|
60
|
-
*/
|
|
61
|
-
export const legacyManifestResolver = (config: AppshellGlobalConfig): RemoteResolver => {
|
|
62
|
-
const cache = new Map<string, Promise<AppshellManifest>>();
|
|
63
|
-
|
|
64
|
-
const fetchManifest = (url: string) => {
|
|
65
|
-
const cached = cache.get(url);
|
|
66
|
-
if (cached) return cached;
|
|
67
|
-
|
|
68
|
-
const pending = fetch(url, { credentials: 'include' }).then(async (response) => {
|
|
69
|
-
if (!response.ok) {
|
|
70
|
-
throw new Error(`Failed to get manifest from ${url}. ${await response.text()}`);
|
|
71
|
-
}
|
|
72
|
-
return response.json() as Promise<AppshellManifest>;
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
cache.set(url, pending);
|
|
76
|
-
|
|
77
|
-
return pending;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
return async (key) => {
|
|
81
|
-
const manifestUrl = config.index?.[key];
|
|
82
|
-
if (!manifestUrl) return undefined;
|
|
83
|
-
|
|
84
|
-
const manifest = await fetchManifest(manifestUrl);
|
|
85
|
-
const remote = manifest?.remotes[key];
|
|
86
|
-
if (!remote) return undefined;
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
remote,
|
|
90
|
-
environment: {
|
|
91
|
-
...(manifest.environment[remote.scope] ?? {}),
|
|
92
|
-
...(config.overrides?.environment?.[remote.scope] ?? {}),
|
|
93
|
-
},
|
|
94
|
-
manifest,
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
|
|
99
42
|
export const chainResolvers =
|
|
100
43
|
(...resolvers: RemoteResolver[]): RemoteResolver =>
|
|
101
44
|
async (key) => {
|
package/webpack.config.js
CHANGED
|
@@ -17,6 +17,11 @@ module.exports = (env, { mode }) => {
|
|
|
17
17
|
extensions: ['.js', '.ts'],
|
|
18
18
|
plugins: [new TsconfigPathsPlugin()],
|
|
19
19
|
},
|
|
20
|
+
// Externalised, not bundled: `@appshell/runtime` is a shared singleton, and a copy
|
|
21
|
+
// inlined here would be a second store that no package ever reads from.
|
|
22
|
+
externals: {
|
|
23
|
+
'@appshell/runtime': '@appshell/runtime',
|
|
24
|
+
},
|
|
20
25
|
module: {
|
|
21
26
|
rules: [
|
|
22
27
|
{
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deregister.d.ts","sourceRoot":"","sources":["../../../../../config/src/deregister.ts"],"names":[],"mappings":"qCAoGkC,MAAM,YAAY,MAAM;AAA1D,wBAeE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.env.d.ts","sourceRoot":"","sources":["../../../../../config/src/generate.env.ts"],"names":[],"mappings":";AAGA,wBAuBK"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AppshellGlobalConfig } from './types';
|
|
2
|
-
type GenerateGlobalConfigOptions = {
|
|
3
|
-
insecure: boolean;
|
|
4
|
-
apiKey?: string;
|
|
5
|
-
apiKeyHeader?: string;
|
|
6
|
-
proxyUrl?: string;
|
|
7
|
-
};
|
|
8
|
-
declare const _default: (registries: string[], options?: GenerateGlobalConfigOptions) => Promise<AppshellGlobalConfig>;
|
|
9
|
-
export default _default;
|
|
10
|
-
//# sourceMappingURL=generate.global-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.global-config.d.ts","sourceRoot":"","sources":["../../../../../config/src/generate.global-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAK/C,KAAK,2BAA2B,GAAG;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;qCAGY,MAAM,EAAE,YACX,2BAA2B,KACnC,OAAO,CAAC,oBAAoB,CAAC;AAHhC,wBA8CE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../../config/src/register.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,gBAAgB,EAAmB,MAAM,SAAS,CAAC;mCAetE,gBAAgB,qBACP,MAAM;AAF3B,wBA2CE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isValidUrl.d.ts","sourceRoot":"","sources":["../../../../../../config/src/utils/isValidUrl.ts"],"names":[],"mappings":"oCAA2B,MAAM;AAAjC,wBAME"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type LoadJsonOptions = {
|
|
2
|
-
insecure: boolean;
|
|
3
|
-
target: string | RegExp;
|
|
4
|
-
apiKey?: string;
|
|
5
|
-
apiKeyHeader?: string;
|
|
6
|
-
proxyUrl?: string;
|
|
7
|
-
};
|
|
8
|
-
declare const _default: <T = Record<string, unknown>>(jsonPathOrUrl: string, options?: LoadJsonOptions) => Promise<T[]>;
|
|
9
|
-
export default _default;
|
|
10
|
-
//# sourceMappingURL=loadJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadJson.d.ts","sourceRoot":"","sources":["../../../../../../config/src/utils/loadJson.ts"],"names":[],"mappings":"AAOA,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;yBAsDoB,CAAC,2CACN,MAAM,YACZ,eAAe,KAOvB,OAAO,CAAC,CAAC,EAAE,CAAC;AATf,wBAqBE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../../../../config/src/utils/merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;yBAU3B,OAAO,aAAa,eAAe,gBAAgB,OAAO,EAAE;AAA5E,wBAiBE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppshellGlobalConfigValidator.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/AppshellGlobalConfigValidator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,eAAe,EAAE,MAAM,UAAU,CAAC;wBAO5D,eAAe;AALpB,wBAKqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppshellManifestValidator.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/AppshellManifestValidator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,eAAe,EAAgB,MAAM,UAAU,CAAC;wBA0EtE,eAAe;AAtBpB,wBAsBqB"}
|