@bleedingdev/modern-js-plugin-bff-build-extensions 3.9.0-ultramodern.5 → 3.9.0-ultramodern.7
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/cjs/client-artifacts.js +5 -17
- package/dist/cjs/compile.js +2 -1
- package/dist/cjs/generated-entries.js +7 -3
- package/dist/cjs/index.js +5 -9
- package/dist/esm/client-artifacts.mjs +5 -17
- package/dist/esm/compile.mjs +2 -1
- package/dist/esm/generated-entries.mjs +7 -3
- package/dist/esm/index.mjs +5 -9
- package/dist/esm-node/client-artifacts.mjs +5 -17
- package/dist/esm-node/compile.mjs +2 -1
- package/dist/esm-node/generated-entries.mjs +7 -3
- package/dist/esm-node/index.mjs +5 -9
- package/dist/types/client-artifacts.d.ts +0 -2
- package/package.json +15 -15
- package/src/client-artifacts.ts +7 -21
- package/src/compile.ts +3 -1
- package/src/generated-entries.ts +11 -6
- package/src/index.ts +5 -8
|
@@ -40,36 +40,24 @@ function registerBffClientArtifacts(api, metadata) {
|
|
|
40
40
|
const { generation } = context;
|
|
41
41
|
const config = api.getNormalizedConfig();
|
|
42
42
|
if ('effect' === api.getAppContext().bffRuntimeFramework) {
|
|
43
|
-
const {
|
|
43
|
+
const { resolveEffectOperationContracts, resolveEffectEntryPaths } = await import("@modern-js/plugin-bff-extensions/effect-source-loader");
|
|
44
44
|
const { sourceEffectEntry, relativeEffectEntry } = resolveEffectEntryPaths({
|
|
45
45
|
appDir: generation.appDirectory,
|
|
46
46
|
apiDir: generation.apiDirectory,
|
|
47
47
|
effectEntry: config.bff?.effect?.entry
|
|
48
48
|
});
|
|
49
49
|
if (!sourceEffectEntry) throw new Error(`Cannot resolve Effect BFF entry in ${generation.apiDirectory}.`);
|
|
50
|
-
const
|
|
50
|
+
const operationContracts = await resolveEffectOperationContracts({
|
|
51
51
|
appDir: generation.appDirectory,
|
|
52
|
-
apiDir: generation.apiDirectory,
|
|
53
52
|
resourcePath: sourceEffectEntry,
|
|
54
53
|
prefix: generation.prefix,
|
|
55
|
-
|
|
56
|
-
target: 'bundle',
|
|
57
|
-
requestId: generation.requestId,
|
|
58
|
-
requestCreator: generation.requestCreator || BFF_REQUEST_RUNTIME,
|
|
59
|
-
httpMethodDecider: generation.httpMethodDecider,
|
|
60
|
-
dataPlatformBatch: config.bff?.effect?.dataPlatform?.batch
|
|
61
|
-
});
|
|
62
|
-
if (!artifacts) throw new Error(`Effect cross-project client generation failed for ${sourceEffectEntry}.`);
|
|
63
|
-
context.additionalArtifacts.push({
|
|
64
|
-
sourcePath: utils_namespaceObject.upath.relative(generation.apiDirectory, sourceEffectEntry),
|
|
65
|
-
code: artifacts.code,
|
|
66
|
-
declaration: artifacts.declaration
|
|
54
|
+
requestId: generation.requestId
|
|
67
55
|
});
|
|
56
|
+
if (null === operationContracts) throw new Error(`Cannot resolve exported Effect HttpApi in ${sourceEffectEntry}.`);
|
|
68
57
|
metadata.set(generation, {
|
|
69
58
|
runtimeFramework: 'effect',
|
|
70
59
|
relativeEffectEntry,
|
|
71
|
-
operationContracts
|
|
72
|
-
effectArtifacts: artifacts
|
|
60
|
+
operationContracts
|
|
73
61
|
});
|
|
74
62
|
} else {
|
|
75
63
|
const router = new bff_core_namespaceObject.ApiRouter({
|
package/dist/cjs/compile.js
CHANGED
|
@@ -44,7 +44,8 @@ function registerBffCompilation(api) {
|
|
|
44
44
|
...context.outputDirectories
|
|
45
45
|
], globals);
|
|
46
46
|
if ('effect' !== api.getAppContext().bffRuntimeFramework) return;
|
|
47
|
-
|
|
47
|
+
if (api.getNormalizedConfig().bff?.isCrossProjectServer === true) return;
|
|
48
|
+
const { bundleBuiltEffectEntryForNode } = await import("@modern-js/plugin-bff-extensions/effect-source-loader");
|
|
48
49
|
await bundleBuiltEffectEntryForNode({
|
|
49
50
|
appDir: context.appDirectory,
|
|
50
51
|
apiDir: context.apiDirectory,
|
|
@@ -37,7 +37,7 @@ function registerBffGeneratedEntries(api, metadata) {
|
|
|
37
37
|
api.modifyBffGeneratedEntries(async (entries)=>{
|
|
38
38
|
const { generation } = entries;
|
|
39
39
|
const details = metadata.get(generation);
|
|
40
|
-
if (!details) throw new Error('BFF entries require completed
|
|
40
|
+
if (!details) throw new Error('BFF entries require completed operation contract collection.');
|
|
41
41
|
metadata.delete(generation);
|
|
42
42
|
const packageJson = await utils_namespaceObject.fs.readJSON(utils_namespaceObject.upath.join(generation.appDirectory, 'package.json'));
|
|
43
43
|
const runtimeSpecifier = api.getNormalizedConfig().bff?.runtimeCreateRequest || external_client_artifacts_js_namespaceObject.BFF_REQUEST_RUNTIME;
|
|
@@ -45,8 +45,8 @@ function registerBffGeneratedEntries(api, metadata) {
|
|
|
45
45
|
'@modern-js/plugin-bff-build-extensions',
|
|
46
46
|
'@modern-js/plugin-bff-extensions'
|
|
47
47
|
];
|
|
48
|
-
const emitsClient = '
|
|
49
|
-
if (runtimeSpecifier === external_client_artifacts_js_namespaceObject.BFF_REQUEST_RUNTIME || emitsClient && (generation.requestCreator || external_client_artifacts_js_namespaceObject.BFF_REQUEST_RUNTIME) === external_client_artifacts_js_namespaceObject.BFF_REQUEST_RUNTIME) dependencies.push('@modern-js/runtime-extensions');
|
|
48
|
+
const emitsClient = 'hono' === details.runtimeFramework && generation.apiFiles.length > 0;
|
|
49
|
+
if ('hono' === details.runtimeFramework && (runtimeSpecifier === external_client_artifacts_js_namespaceObject.BFF_REQUEST_RUNTIME || emitsClient && (generation.requestCreator || external_client_artifacts_js_namespaceObject.BFF_REQUEST_RUNTIME) === external_client_artifacts_js_namespaceObject.BFF_REQUEST_RUNTIME)) dependencies.push('@modern-js/runtime-extensions');
|
|
50
50
|
for (const name of dependencies){
|
|
51
51
|
const specifier = packageJson.dependencies?.[name] || packageJson.devDependencies?.[name] || utils_namespaceObject.fs.readJSONSync(require.resolve(`${name}/package.json`)).version;
|
|
52
52
|
entries.packageDependencies[name] = specifier;
|
|
@@ -71,6 +71,10 @@ function registerBffGeneratedEntries(api, metadata) {
|
|
|
71
71
|
export declare const crossProjectApiPlugin: () => CliPlugin<AppTools>;
|
|
72
72
|
`
|
|
73
73
|
};
|
|
74
|
+
if ('effect' === details.runtimeFramework) {
|
|
75
|
+
entries.runtime = null;
|
|
76
|
+
return entries;
|
|
77
|
+
}
|
|
74
78
|
const runtime = JSON.stringify(runtimeSpecifier);
|
|
75
79
|
const esmRuntime = JSON.stringify(utils_namespaceObject.upath.isAbsolute(runtimeSpecifier) ? (0, external_node_url_namespaceObject.pathToFileURL)(runtimeSpecifier).href : runtimeSpecifier);
|
|
76
80
|
entries.runtime = {
|
package/dist/cjs/index.js
CHANGED
|
@@ -90,11 +90,12 @@ const bffPlugin = ()=>({
|
|
|
90
90
|
(0, external_compile_js_namespaceObject.registerBffCompilation)(api);
|
|
91
91
|
(0, external_client_artifacts_js_namespaceObject.registerBffClientArtifacts)(api, metadata);
|
|
92
92
|
(0, external_generated_entries_js_namespaceObject.registerBffGeneratedEntries)(api, metadata);
|
|
93
|
-
api.modifyBundlerChain(async (chain, {
|
|
93
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
|
|
94
94
|
if ('effect' !== api.getAppContext().bffRuntimeFramework) return;
|
|
95
|
-
const { appDirectory, apiDirectory
|
|
95
|
+
const { appDirectory, apiDirectory } = api.getAppContext();
|
|
96
96
|
const bff = api.getNormalizedConfig().bff;
|
|
97
|
-
|
|
97
|
+
if (!utils_namespaceObject.fs.existsSync(apiDirectory) && bff?.effect?.entry === void 0) return;
|
|
98
|
+
const { resolveEffectEntryFile } = await import("@modern-js/plugin-bff-extensions/effect-source-loader");
|
|
98
99
|
const entry = resolveEffectEntryFile({
|
|
99
100
|
appDir: appDirectory,
|
|
100
101
|
apiDir: apiDirectory,
|
|
@@ -111,12 +112,7 @@ const bffPlugin = ()=>({
|
|
|
111
112
|
apiDir: apiDirectory,
|
|
112
113
|
effectEntry: entry,
|
|
113
114
|
prefix: Array.isArray(bff?.prefix) ? bff.prefix[0] : bff?.prefix || '/api',
|
|
114
|
-
|
|
115
|
-
target: isServer ? 'server' : 'client',
|
|
116
|
-
requestId: bff?.requestId,
|
|
117
|
-
requestCreator: bff?.requestCreator || external_client_artifacts_js_namespaceObject.BFF_REQUEST_RUNTIME,
|
|
118
|
-
httpMethodDecider: bff?.httpMethodDecider,
|
|
119
|
-
effectDataPlatformBatch: bff?.effect?.dataPlatform?.batch
|
|
115
|
+
requestId: bff?.requestId
|
|
120
116
|
});
|
|
121
117
|
});
|
|
122
118
|
}
|
|
@@ -7,36 +7,24 @@ function registerBffClientArtifacts(api, metadata) {
|
|
|
7
7
|
const { generation } = context;
|
|
8
8
|
const config = api.getNormalizedConfig();
|
|
9
9
|
if ('effect' === api.getAppContext().bffRuntimeFramework) {
|
|
10
|
-
const {
|
|
10
|
+
const { resolveEffectOperationContracts, resolveEffectEntryPaths } = await import("@modern-js/plugin-bff-extensions/effect-source-loader");
|
|
11
11
|
const { sourceEffectEntry, relativeEffectEntry } = resolveEffectEntryPaths({
|
|
12
12
|
appDir: generation.appDirectory,
|
|
13
13
|
apiDir: generation.apiDirectory,
|
|
14
14
|
effectEntry: config.bff?.effect?.entry
|
|
15
15
|
});
|
|
16
16
|
if (!sourceEffectEntry) throw new Error(`Cannot resolve Effect BFF entry in ${generation.apiDirectory}.`);
|
|
17
|
-
const
|
|
17
|
+
const operationContracts = await resolveEffectOperationContracts({
|
|
18
18
|
appDir: generation.appDirectory,
|
|
19
|
-
apiDir: generation.apiDirectory,
|
|
20
19
|
resourcePath: sourceEffectEntry,
|
|
21
20
|
prefix: generation.prefix,
|
|
22
|
-
|
|
23
|
-
target: 'bundle',
|
|
24
|
-
requestId: generation.requestId,
|
|
25
|
-
requestCreator: generation.requestCreator || BFF_REQUEST_RUNTIME,
|
|
26
|
-
httpMethodDecider: generation.httpMethodDecider,
|
|
27
|
-
dataPlatformBatch: config.bff?.effect?.dataPlatform?.batch
|
|
28
|
-
});
|
|
29
|
-
if (!artifacts) throw new Error(`Effect cross-project client generation failed for ${sourceEffectEntry}.`);
|
|
30
|
-
context.additionalArtifacts.push({
|
|
31
|
-
sourcePath: upath.relative(generation.apiDirectory, sourceEffectEntry),
|
|
32
|
-
code: artifacts.code,
|
|
33
|
-
declaration: artifacts.declaration
|
|
21
|
+
requestId: generation.requestId
|
|
34
22
|
});
|
|
23
|
+
if (null === operationContracts) throw new Error(`Cannot resolve exported Effect HttpApi in ${sourceEffectEntry}.`);
|
|
35
24
|
metadata.set(generation, {
|
|
36
25
|
runtimeFramework: 'effect',
|
|
37
26
|
relativeEffectEntry,
|
|
38
|
-
operationContracts
|
|
39
|
-
effectArtifacts: artifacts
|
|
27
|
+
operationContracts
|
|
40
28
|
});
|
|
41
29
|
} else {
|
|
42
30
|
const router = new ApiRouter({
|
package/dist/esm/compile.mjs
CHANGED
|
@@ -12,7 +12,8 @@ function registerBffCompilation(api) {
|
|
|
12
12
|
...context.outputDirectories
|
|
13
13
|
], globals);
|
|
14
14
|
if ('effect' !== api.getAppContext().bffRuntimeFramework) return;
|
|
15
|
-
|
|
15
|
+
if (api.getNormalizedConfig().bff?.isCrossProjectServer === true) return;
|
|
16
|
+
const { bundleBuiltEffectEntryForNode } = await import("@modern-js/plugin-bff-extensions/effect-source-loader");
|
|
16
17
|
await bundleBuiltEffectEntryForNode({
|
|
17
18
|
appDir: context.appDirectory,
|
|
18
19
|
apiDir: context.apiDirectory,
|
|
@@ -5,7 +5,7 @@ function registerBffGeneratedEntries(api, metadata) {
|
|
|
5
5
|
api.modifyBffGeneratedEntries(async (entries)=>{
|
|
6
6
|
const { generation } = entries;
|
|
7
7
|
const details = metadata.get(generation);
|
|
8
|
-
if (!details) throw new Error('BFF entries require completed
|
|
8
|
+
if (!details) throw new Error('BFF entries require completed operation contract collection.');
|
|
9
9
|
metadata.delete(generation);
|
|
10
10
|
const packageJson = await fs.readJSON(upath.join(generation.appDirectory, 'package.json'));
|
|
11
11
|
const runtimeSpecifier = api.getNormalizedConfig().bff?.runtimeCreateRequest || BFF_REQUEST_RUNTIME;
|
|
@@ -13,8 +13,8 @@ function registerBffGeneratedEntries(api, metadata) {
|
|
|
13
13
|
'@modern-js/plugin-bff-build-extensions',
|
|
14
14
|
'@modern-js/plugin-bff-extensions'
|
|
15
15
|
];
|
|
16
|
-
const emitsClient = '
|
|
17
|
-
if (runtimeSpecifier === BFF_REQUEST_RUNTIME || emitsClient && (generation.requestCreator || BFF_REQUEST_RUNTIME) === BFF_REQUEST_RUNTIME) dependencies.push('@modern-js/runtime-extensions');
|
|
16
|
+
const emitsClient = 'hono' === details.runtimeFramework && generation.apiFiles.length > 0;
|
|
17
|
+
if ('hono' === details.runtimeFramework && (runtimeSpecifier === BFF_REQUEST_RUNTIME || emitsClient && (generation.requestCreator || BFF_REQUEST_RUNTIME) === BFF_REQUEST_RUNTIME)) dependencies.push('@modern-js/runtime-extensions');
|
|
18
18
|
for (const name of dependencies){
|
|
19
19
|
const specifier = packageJson.dependencies?.[name] || packageJson.devDependencies?.[name] || fs.readJSONSync(require.resolve(`${name}/package.json`)).version;
|
|
20
20
|
entries.packageDependencies[name] = specifier;
|
|
@@ -39,6 +39,10 @@ function registerBffGeneratedEntries(api, metadata) {
|
|
|
39
39
|
export declare const crossProjectApiPlugin: () => CliPlugin<AppTools>;
|
|
40
40
|
`
|
|
41
41
|
};
|
|
42
|
+
if ('effect' === details.runtimeFramework) {
|
|
43
|
+
entries.runtime = null;
|
|
44
|
+
return entries;
|
|
45
|
+
}
|
|
42
46
|
const runtime = JSON.stringify(runtimeSpecifier);
|
|
43
47
|
const esmRuntime = JSON.stringify(upath.isAbsolute(runtimeSpecifier) ? pathToFileURL(runtimeSpecifier).href : runtimeSpecifier);
|
|
44
48
|
entries.runtime = {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -57,11 +57,12 @@ const src_bffPlugin = ()=>({
|
|
|
57
57
|
registerBffCompilation(api);
|
|
58
58
|
registerBffClientArtifacts(api, metadata);
|
|
59
59
|
registerBffGeneratedEntries(api, metadata);
|
|
60
|
-
api.modifyBundlerChain(async (chain, {
|
|
60
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
|
|
61
61
|
if ('effect' !== api.getAppContext().bffRuntimeFramework) return;
|
|
62
|
-
const { appDirectory, apiDirectory
|
|
62
|
+
const { appDirectory, apiDirectory } = api.getAppContext();
|
|
63
63
|
const bff = api.getNormalizedConfig().bff;
|
|
64
|
-
|
|
64
|
+
if (!fs.existsSync(apiDirectory) && bff?.effect?.entry === void 0) return;
|
|
65
|
+
const { resolveEffectEntryFile } = await import("@modern-js/plugin-bff-extensions/effect-source-loader");
|
|
65
66
|
const entry = resolveEffectEntryFile({
|
|
66
67
|
appDir: appDirectory,
|
|
67
68
|
apiDir: apiDirectory,
|
|
@@ -78,12 +79,7 @@ const src_bffPlugin = ()=>({
|
|
|
78
79
|
apiDir: apiDirectory,
|
|
79
80
|
effectEntry: entry,
|
|
80
81
|
prefix: Array.isArray(bff?.prefix) ? bff.prefix[0] : bff?.prefix || '/api',
|
|
81
|
-
|
|
82
|
-
target: isServer ? 'server' : 'client',
|
|
83
|
-
requestId: bff?.requestId,
|
|
84
|
-
requestCreator: bff?.requestCreator || BFF_REQUEST_RUNTIME,
|
|
85
|
-
httpMethodDecider: bff?.httpMethodDecider,
|
|
86
|
-
effectDataPlatformBatch: bff?.effect?.dataPlatform?.batch
|
|
82
|
+
requestId: bff?.requestId
|
|
87
83
|
});
|
|
88
84
|
});
|
|
89
85
|
}
|
|
@@ -8,36 +8,24 @@ function registerBffClientArtifacts(api, metadata) {
|
|
|
8
8
|
const { generation } = context;
|
|
9
9
|
const config = api.getNormalizedConfig();
|
|
10
10
|
if ('effect' === api.getAppContext().bffRuntimeFramework) {
|
|
11
|
-
const {
|
|
11
|
+
const { resolveEffectOperationContracts, resolveEffectEntryPaths } = await import("@modern-js/plugin-bff-extensions/effect-source-loader");
|
|
12
12
|
const { sourceEffectEntry, relativeEffectEntry } = resolveEffectEntryPaths({
|
|
13
13
|
appDir: generation.appDirectory,
|
|
14
14
|
apiDir: generation.apiDirectory,
|
|
15
15
|
effectEntry: config.bff?.effect?.entry
|
|
16
16
|
});
|
|
17
17
|
if (!sourceEffectEntry) throw new Error(`Cannot resolve Effect BFF entry in ${generation.apiDirectory}.`);
|
|
18
|
-
const
|
|
18
|
+
const operationContracts = await resolveEffectOperationContracts({
|
|
19
19
|
appDir: generation.appDirectory,
|
|
20
|
-
apiDir: generation.apiDirectory,
|
|
21
20
|
resourcePath: sourceEffectEntry,
|
|
22
21
|
prefix: generation.prefix,
|
|
23
|
-
|
|
24
|
-
target: 'bundle',
|
|
25
|
-
requestId: generation.requestId,
|
|
26
|
-
requestCreator: generation.requestCreator || BFF_REQUEST_RUNTIME,
|
|
27
|
-
httpMethodDecider: generation.httpMethodDecider,
|
|
28
|
-
dataPlatformBatch: config.bff?.effect?.dataPlatform?.batch
|
|
29
|
-
});
|
|
30
|
-
if (!artifacts) throw new Error(`Effect cross-project client generation failed for ${sourceEffectEntry}.`);
|
|
31
|
-
context.additionalArtifacts.push({
|
|
32
|
-
sourcePath: upath.relative(generation.apiDirectory, sourceEffectEntry),
|
|
33
|
-
code: artifacts.code,
|
|
34
|
-
declaration: artifacts.declaration
|
|
22
|
+
requestId: generation.requestId
|
|
35
23
|
});
|
|
24
|
+
if (null === operationContracts) throw new Error(`Cannot resolve exported Effect HttpApi in ${sourceEffectEntry}.`);
|
|
36
25
|
metadata.set(generation, {
|
|
37
26
|
runtimeFramework: 'effect',
|
|
38
27
|
relativeEffectEntry,
|
|
39
|
-
operationContracts
|
|
40
|
-
effectArtifacts: artifacts
|
|
28
|
+
operationContracts
|
|
41
29
|
});
|
|
42
30
|
} else {
|
|
43
31
|
const router = new ApiRouter({
|
|
@@ -13,7 +13,8 @@ function registerBffCompilation(api) {
|
|
|
13
13
|
...context.outputDirectories
|
|
14
14
|
], globals);
|
|
15
15
|
if ('effect' !== api.getAppContext().bffRuntimeFramework) return;
|
|
16
|
-
|
|
16
|
+
if (api.getNormalizedConfig().bff?.isCrossProjectServer === true) return;
|
|
17
|
+
const { bundleBuiltEffectEntryForNode } = await import("@modern-js/plugin-bff-extensions/effect-source-loader");
|
|
17
18
|
await bundleBuiltEffectEntryForNode({
|
|
18
19
|
appDir: context.appDirectory,
|
|
19
20
|
apiDir: context.apiDirectory,
|
|
@@ -7,7 +7,7 @@ function registerBffGeneratedEntries(api, metadata) {
|
|
|
7
7
|
api.modifyBffGeneratedEntries(async (entries)=>{
|
|
8
8
|
const { generation } = entries;
|
|
9
9
|
const details = metadata.get(generation);
|
|
10
|
-
if (!details) throw new Error('BFF entries require completed
|
|
10
|
+
if (!details) throw new Error('BFF entries require completed operation contract collection.');
|
|
11
11
|
metadata.delete(generation);
|
|
12
12
|
const packageJson = await fs.readJSON(upath.join(generation.appDirectory, 'package.json'));
|
|
13
13
|
const runtimeSpecifier = api.getNormalizedConfig().bff?.runtimeCreateRequest || BFF_REQUEST_RUNTIME;
|
|
@@ -15,8 +15,8 @@ function registerBffGeneratedEntries(api, metadata) {
|
|
|
15
15
|
'@modern-js/plugin-bff-build-extensions',
|
|
16
16
|
'@modern-js/plugin-bff-extensions'
|
|
17
17
|
];
|
|
18
|
-
const emitsClient = '
|
|
19
|
-
if (runtimeSpecifier === BFF_REQUEST_RUNTIME || emitsClient && (generation.requestCreator || BFF_REQUEST_RUNTIME) === BFF_REQUEST_RUNTIME) dependencies.push('@modern-js/runtime-extensions');
|
|
18
|
+
const emitsClient = 'hono' === details.runtimeFramework && generation.apiFiles.length > 0;
|
|
19
|
+
if ('hono' === details.runtimeFramework && (runtimeSpecifier === BFF_REQUEST_RUNTIME || emitsClient && (generation.requestCreator || BFF_REQUEST_RUNTIME) === BFF_REQUEST_RUNTIME)) dependencies.push('@modern-js/runtime-extensions');
|
|
20
20
|
for (const name of dependencies){
|
|
21
21
|
const specifier = packageJson.dependencies?.[name] || packageJson.devDependencies?.[name] || fs.readJSONSync(require.resolve(`${name}/package.json`)).version;
|
|
22
22
|
entries.packageDependencies[name] = specifier;
|
|
@@ -41,6 +41,10 @@ function registerBffGeneratedEntries(api, metadata) {
|
|
|
41
41
|
export declare const crossProjectApiPlugin: () => CliPlugin<AppTools>;
|
|
42
42
|
`
|
|
43
43
|
};
|
|
44
|
+
if ('effect' === details.runtimeFramework) {
|
|
45
|
+
entries.runtime = null;
|
|
46
|
+
return entries;
|
|
47
|
+
}
|
|
44
48
|
const runtime = JSON.stringify(runtimeSpecifier);
|
|
45
49
|
const esmRuntime = JSON.stringify(upath.isAbsolute(runtimeSpecifier) ? pathToFileURL(runtimeSpecifier).href : runtimeSpecifier);
|
|
46
50
|
entries.runtime = {
|
package/dist/esm-node/index.mjs
CHANGED
|
@@ -59,11 +59,12 @@ const src_bffPlugin = ()=>({
|
|
|
59
59
|
registerBffCompilation(api);
|
|
60
60
|
registerBffClientArtifacts(api, metadata);
|
|
61
61
|
registerBffGeneratedEntries(api, metadata);
|
|
62
|
-
api.modifyBundlerChain(async (chain, {
|
|
62
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
|
|
63
63
|
if ('effect' !== api.getAppContext().bffRuntimeFramework) return;
|
|
64
|
-
const { appDirectory, apiDirectory
|
|
64
|
+
const { appDirectory, apiDirectory } = api.getAppContext();
|
|
65
65
|
const bff = api.getNormalizedConfig().bff;
|
|
66
|
-
|
|
66
|
+
if (!fs.existsSync(apiDirectory) && bff?.effect?.entry === void 0) return;
|
|
67
|
+
const { resolveEffectEntryFile } = await import("@modern-js/plugin-bff-extensions/effect-source-loader");
|
|
67
68
|
const entry = resolveEffectEntryFile({
|
|
68
69
|
appDir: appDirectory,
|
|
69
70
|
apiDir: apiDirectory,
|
|
@@ -80,12 +81,7 @@ const src_bffPlugin = ()=>({
|
|
|
80
81
|
apiDir: apiDirectory,
|
|
81
82
|
effectEntry: entry,
|
|
82
83
|
prefix: Array.isArray(bff?.prefix) ? bff.prefix[0] : bff?.prefix || '/api',
|
|
83
|
-
|
|
84
|
-
target: isServer ? 'server' : 'client',
|
|
85
|
-
requestId: bff?.requestId,
|
|
86
|
-
requestCreator: bff?.requestCreator || BFF_REQUEST_RUNTIME,
|
|
87
|
-
httpMethodDecider: bff?.httpMethodDecider,
|
|
88
|
-
effectDataPlatformBatch: bff?.effect?.dataPlatform?.batch
|
|
84
|
+
requestId: bff?.requestId
|
|
89
85
|
});
|
|
90
86
|
});
|
|
91
87
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { AppTools, BffGeneration } from '@modern-js/app-tools';
|
|
2
2
|
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
3
|
-
import type { GeneratedEffectClientArtifacts } from '@modern-js/plugin-bff-extensions/client-generator';
|
|
4
3
|
import { type OperationContractMap } from '@modern-js/server-runtime-extensions/bff-policy/node';
|
|
5
4
|
export declare const BFF_REQUEST_RUNTIME = "@modern-js/runtime-extensions/request-policy";
|
|
6
5
|
export interface BffGenerationMetadata {
|
|
7
6
|
runtimeFramework: 'effect' | 'hono';
|
|
8
7
|
relativeEffectEntry: string;
|
|
9
8
|
operationContracts: OperationContractMap;
|
|
10
|
-
effectArtifacts?: GeneratedEffectClientArtifacts;
|
|
11
9
|
}
|
|
12
10
|
export declare function registerBffClientArtifacts(api: CLIPluginAPI<AppTools>, metadata: WeakMap<BffGeneration, BffGenerationMetadata>): void;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/BleedingDev/ultramodern.js/issues"
|
|
5
5
|
},
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"version": "3.9.0-ultramodern.
|
|
7
|
+
"version": "3.9.0-ultramodern.7",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
10
|
"src"
|
|
@@ -65,18 +65,18 @@
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@modern-js/bff-core": "npm:@bleedingdev/modern-js-bff-core@3.9.0-ultramodern.
|
|
69
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.
|
|
70
|
-
"@modern-js/plugin-bff": "npm:@bleedingdev/modern-js-plugin-bff@3.9.0-ultramodern.
|
|
71
|
-
"@modern-js/plugin-bff-extensions": "npm:@bleedingdev/modern-js-plugin-bff-extensions@3.9.0-ultramodern.
|
|
72
|
-
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.
|
|
73
|
-
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.
|
|
74
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.
|
|
68
|
+
"@modern-js/bff-core": "npm:@bleedingdev/modern-js-bff-core@3.9.0-ultramodern.7",
|
|
69
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.7",
|
|
70
|
+
"@modern-js/plugin-bff": "npm:@bleedingdev/modern-js-plugin-bff@3.9.0-ultramodern.7",
|
|
71
|
+
"@modern-js/plugin-bff-extensions": "npm:@bleedingdev/modern-js-plugin-bff-extensions@3.9.0-ultramodern.7",
|
|
72
|
+
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.7",
|
|
73
|
+
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.7",
|
|
74
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.7",
|
|
75
75
|
"@swc/core": "1.16.2"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@effect/opentelemetry": "4.0.0-rc.112",
|
|
79
|
-
"@modern-js/app-tools": "3.9.0-ultramodern.
|
|
79
|
+
"@modern-js/app-tools": "3.9.0-ultramodern.7",
|
|
80
80
|
"effect": "4.0.0-rc.112"
|
|
81
81
|
},
|
|
82
82
|
"peerDependenciesMeta": {
|
|
@@ -89,12 +89,12 @@
|
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@effect/opentelemetry": "4.0.0-rc.112",
|
|
92
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.
|
|
93
|
-
"@modern-js/bff-effect": "npm:@bleedingdev/modern-js-bff-effect@3.9.0-ultramodern.
|
|
94
|
-
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.
|
|
95
|
-
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.
|
|
96
|
-
"@modern-js/tsconfig": "npm:@bleedingdev/modern-js-tsconfig@3.9.0-ultramodern.
|
|
97
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.
|
|
92
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.7",
|
|
93
|
+
"@modern-js/bff-effect": "npm:@bleedingdev/modern-js-bff-effect@3.9.0-ultramodern.7",
|
|
94
|
+
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.7",
|
|
95
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.7",
|
|
96
|
+
"@modern-js/tsconfig": "npm:@bleedingdev/modern-js-tsconfig@3.9.0-ultramodern.7",
|
|
97
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.7",
|
|
98
98
|
"@rsbuild/core": "2.2.3",
|
|
99
99
|
"@rslib/core": "1.0.0",
|
|
100
100
|
"@scripts/rstest-config": "2.66.0",
|
package/src/client-artifacts.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
} from '@modern-js/app-tools';
|
|
6
6
|
import { ApiRouter } from '@modern-js/bff-core';
|
|
7
7
|
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
8
|
-
import type { GeneratedEffectClientArtifacts } from '@modern-js/plugin-bff-extensions/client-generator';
|
|
9
8
|
import {
|
|
10
9
|
buildOperationContractMap,
|
|
11
10
|
deriveOperationVersion,
|
|
@@ -20,7 +19,6 @@ export interface BffGenerationMetadata {
|
|
|
20
19
|
runtimeFramework: 'effect' | 'hono';
|
|
21
20
|
relativeEffectEntry: string;
|
|
22
21
|
operationContracts: OperationContractMap;
|
|
23
|
-
effectArtifacts?: GeneratedEffectClientArtifacts;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
export function registerBffClientArtifacts(
|
|
@@ -31,9 +29,8 @@ export function registerBffClientArtifacts(
|
|
|
31
29
|
const { generation } = context;
|
|
32
30
|
const config = api.getNormalizedConfig();
|
|
33
31
|
if (api.getAppContext().bffRuntimeFramework === 'effect') {
|
|
34
|
-
const {
|
|
35
|
-
'@modern-js/plugin-bff-extensions/
|
|
36
|
-
);
|
|
32
|
+
const { resolveEffectOperationContracts, resolveEffectEntryPaths } =
|
|
33
|
+
await import('@modern-js/plugin-bff-extensions/effect-source-loader');
|
|
37
34
|
const { sourceEffectEntry, relativeEffectEntry } =
|
|
38
35
|
resolveEffectEntryPaths({
|
|
39
36
|
appDir: generation.appDirectory,
|
|
@@ -44,32 +41,21 @@ export function registerBffClientArtifacts(
|
|
|
44
41
|
throw new Error(
|
|
45
42
|
`Cannot resolve Effect BFF entry in ${generation.apiDirectory}.`,
|
|
46
43
|
);
|
|
47
|
-
const
|
|
44
|
+
const operationContracts = await resolveEffectOperationContracts({
|
|
48
45
|
appDir: generation.appDirectory,
|
|
49
|
-
apiDir: generation.apiDirectory,
|
|
50
46
|
resourcePath: sourceEffectEntry,
|
|
51
47
|
prefix: generation.prefix,
|
|
52
|
-
port: Number(generation.port),
|
|
53
|
-
target: 'bundle',
|
|
54
48
|
requestId: generation.requestId,
|
|
55
|
-
requestCreator: generation.requestCreator || BFF_REQUEST_RUNTIME,
|
|
56
|
-
httpMethodDecider: generation.httpMethodDecider,
|
|
57
|
-
dataPlatformBatch: config.bff?.effect?.dataPlatform?.batch,
|
|
58
49
|
});
|
|
59
|
-
if (
|
|
50
|
+
if (operationContracts === null) {
|
|
60
51
|
throw new Error(
|
|
61
|
-
`
|
|
52
|
+
`Cannot resolve exported Effect HttpApi in ${sourceEffectEntry}.`,
|
|
62
53
|
);
|
|
63
|
-
|
|
64
|
-
sourcePath: path.relative(generation.apiDirectory, sourceEffectEntry),
|
|
65
|
-
code: artifacts.code,
|
|
66
|
-
declaration: artifacts.declaration,
|
|
67
|
-
});
|
|
54
|
+
}
|
|
68
55
|
metadata.set(generation, {
|
|
69
56
|
runtimeFramework: 'effect',
|
|
70
57
|
relativeEffectEntry,
|
|
71
|
-
operationContracts
|
|
72
|
-
effectArtifacts: artifacts,
|
|
58
|
+
operationContracts,
|
|
73
59
|
});
|
|
74
60
|
} else {
|
|
75
61
|
const router = new ApiRouter({
|
package/src/compile.ts
CHANGED
|
@@ -23,8 +23,10 @@ export function registerBffCompilation(api: CLIPluginAPI<AppTools>) {
|
|
|
23
23
|
serialized.delete(context);
|
|
24
24
|
await transformServerGlobalVars([...context.outputDirectories], globals);
|
|
25
25
|
if (api.getAppContext().bffRuntimeFramework !== 'effect') return;
|
|
26
|
+
// Hosted APIs use the producer's compiled entry; it is not emitted by this app.
|
|
27
|
+
if (api.getNormalizedConfig().bff?.isCrossProjectServer === true) return;
|
|
26
28
|
const { bundleBuiltEffectEntryForNode } = await import(
|
|
27
|
-
'@modern-js/plugin-bff-extensions/
|
|
29
|
+
'@modern-js/plugin-bff-extensions/effect-source-loader'
|
|
28
30
|
);
|
|
29
31
|
await bundleBuiltEffectEntryForNode({
|
|
30
32
|
appDir: context.appDirectory,
|
package/src/generated-entries.ts
CHANGED
|
@@ -21,7 +21,7 @@ export function registerBffGeneratedEntries(
|
|
|
21
21
|
const details = metadata.get(generation);
|
|
22
22
|
if (!details)
|
|
23
23
|
throw new Error(
|
|
24
|
-
'BFF entries require completed
|
|
24
|
+
'BFF entries require completed operation contract collection.',
|
|
25
25
|
);
|
|
26
26
|
metadata.delete(generation);
|
|
27
27
|
const packageJson = await fs.readJSON(
|
|
@@ -35,12 +35,13 @@ export function registerBffGeneratedEntries(
|
|
|
35
35
|
'@modern-js/plugin-bff-extensions',
|
|
36
36
|
];
|
|
37
37
|
const emitsClient =
|
|
38
|
-
details.runtimeFramework === '
|
|
38
|
+
details.runtimeFramework === 'hono' && generation.apiFiles.length > 0;
|
|
39
39
|
if (
|
|
40
|
-
|
|
41
|
-
(
|
|
42
|
-
(
|
|
43
|
-
BFF_REQUEST_RUNTIME)
|
|
40
|
+
details.runtimeFramework === 'hono' &&
|
|
41
|
+
(runtimeSpecifier === BFF_REQUEST_RUNTIME ||
|
|
42
|
+
(emitsClient &&
|
|
43
|
+
(generation.requestCreator || BFF_REQUEST_RUNTIME) ===
|
|
44
|
+
BFF_REQUEST_RUNTIME))
|
|
44
45
|
)
|
|
45
46
|
dependencies.push('@modern-js/runtime-extensions');
|
|
46
47
|
for (const name of dependencies) {
|
|
@@ -80,6 +81,10 @@ export function registerBffGeneratedEntries(
|
|
|
80
81
|
export declare const crossProjectApiPlugin: () => CliPlugin<AppTools>;
|
|
81
82
|
`,
|
|
82
83
|
};
|
|
84
|
+
if (details.runtimeFramework === 'effect') {
|
|
85
|
+
entries.runtime = null;
|
|
86
|
+
return entries;
|
|
87
|
+
}
|
|
83
88
|
const runtime = JSON.stringify(runtimeSpecifier);
|
|
84
89
|
const esmRuntime = JSON.stringify(
|
|
85
90
|
path.isAbsolute(runtimeSpecifier)
|
package/src/index.ts
CHANGED
|
@@ -79,12 +79,14 @@ export const bffPlugin = (): CliPlugin<AppTools> => ({
|
|
|
79
79
|
registerBffCompilation(api);
|
|
80
80
|
registerBffClientArtifacts(api, metadata);
|
|
81
81
|
registerBffGeneratedEntries(api, metadata);
|
|
82
|
-
api.modifyBundlerChain(async (chain, {
|
|
82
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
83
83
|
if (api.getAppContext().bffRuntimeFramework !== 'effect') return;
|
|
84
|
-
const { appDirectory, apiDirectory
|
|
84
|
+
const { appDirectory, apiDirectory } = api.getAppContext();
|
|
85
85
|
const bff = api.getNormalizedConfig().bff;
|
|
86
|
+
if (!fs.existsSync(apiDirectory) && bff?.effect?.entry === undefined)
|
|
87
|
+
return;
|
|
86
88
|
const { resolveEffectEntryFile } = await import(
|
|
87
|
-
'@modern-js/plugin-bff-extensions/
|
|
89
|
+
'@modern-js/plugin-bff-extensions/effect-source-loader'
|
|
88
90
|
);
|
|
89
91
|
const entry = resolveEffectEntryFile({
|
|
90
92
|
appDir: appDirectory,
|
|
@@ -117,12 +119,7 @@ export const bffPlugin = (): CliPlugin<AppTools> => ({
|
|
|
117
119
|
prefix: Array.isArray(bff?.prefix)
|
|
118
120
|
? bff.prefix[0]
|
|
119
121
|
: bff?.prefix || '/api',
|
|
120
|
-
port,
|
|
121
|
-
target: isServer ? 'server' : 'client',
|
|
122
122
|
requestId: bff?.requestId,
|
|
123
|
-
requestCreator: bff?.requestCreator || BFF_REQUEST_RUNTIME,
|
|
124
|
-
httpMethodDecider: bff?.httpMethodDecider,
|
|
125
|
-
effectDataPlatformBatch: bff?.effect?.dataPlatform?.batch,
|
|
126
123
|
});
|
|
127
124
|
});
|
|
128
125
|
},
|