@nerest/nerest 1.7.3 → 1.8.0
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/build/configs/development.ts +6 -2
- package/build/configs/production.ts +7 -3
- package/build/configs/shared.ts +1 -0
- package/build/configs/vite-logger.development.ts +2 -2
- package/build/excludes/index.ts +1 -1
- package/build/index.ts +9 -2
- package/dist/build/configs/development.js +6 -2
- package/dist/build/configs/production.js +7 -3
- package/dist/build/configs/shared.d.ts +1 -0
- package/dist/build/configs/vite-logger.development.js +2 -2
- package/dist/build/excludes/index.d.ts +1 -1
- package/dist/build/excludes/index.js +1 -1
- package/dist/build/index.js +8 -3
- package/dist/server/development.js +7 -2
- package/dist/server/loaders/apps.d.ts +1 -1
- package/dist/server/loaders/apps.js +1 -5
- package/dist/server/loaders/directories.d.ts +1 -0
- package/dist/server/loaders/directories.js +8 -0
- package/package.json +18 -18
- package/server/development.ts +11 -5
- package/server/loaders/apps.ts +5 -6
- package/server/loaders/directories.ts +9 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InlineConfig } from 'vite';
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
|
+
import path from 'path';
|
|
3
4
|
|
|
4
5
|
import type { BuildArgs } from './shared.js';
|
|
5
6
|
import { viteConfigShared } from './shared.js';
|
|
@@ -15,8 +16,11 @@ export async function viteConfigDevelopmentClient(
|
|
|
15
16
|
manifest: true,
|
|
16
17
|
modulePreload: false,
|
|
17
18
|
watch: {},
|
|
18
|
-
|
|
19
|
-
input:
|
|
19
|
+
rolldownOptions: {
|
|
20
|
+
input: [
|
|
21
|
+
'/node_modules/@nerest/nerest/client/index.ts',
|
|
22
|
+
...args.appDirectories.map((dir) => path.join(dir, 'index.tsx')),
|
|
23
|
+
],
|
|
20
24
|
output: {
|
|
21
25
|
dir: 'build/client/assets',
|
|
22
26
|
entryFileNames: `[name].js`,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InlineConfig } from 'vite';
|
|
2
2
|
import { viteExternalsPlugin } from 'vite-plugin-externals';
|
|
3
3
|
import react from '@vitejs/plugin-react';
|
|
4
|
+
import path from 'path';
|
|
4
5
|
|
|
5
6
|
import type { BuildArgs } from './shared.js';
|
|
6
7
|
import { viteConfigShared } from './shared.js';
|
|
@@ -15,8 +16,11 @@ export async function viteConfigProductionClient(
|
|
|
15
16
|
// Manifest is needed to report used assets in SSR handles
|
|
16
17
|
manifest: true,
|
|
17
18
|
modulePreload: false,
|
|
18
|
-
|
|
19
|
-
input:
|
|
19
|
+
rolldownOptions: {
|
|
20
|
+
input: [
|
|
21
|
+
'/node_modules/@nerest/nerest/client/index.ts',
|
|
22
|
+
...args.appDirectories.map((dir) => path.join(dir, 'index.tsx')),
|
|
23
|
+
],
|
|
20
24
|
output: {
|
|
21
25
|
dir: 'build/client/assets',
|
|
22
26
|
entryFileNames: `[name].js`,
|
|
@@ -47,7 +51,7 @@ export async function viteConfigProductionServer(
|
|
|
47
51
|
modulePreload: false,
|
|
48
52
|
// This is an important setting for producing a server build
|
|
49
53
|
ssr: true,
|
|
50
|
-
|
|
54
|
+
rolldownOptions: {
|
|
51
55
|
input: '/node_modules/@nerest/nerest/server/production.ts',
|
|
52
56
|
output: {
|
|
53
57
|
dir: 'build',
|
package/build/configs/shared.ts
CHANGED
|
@@ -17,8 +17,8 @@ export default logger;
|
|
|
17
17
|
const ignoredErrors = [
|
|
18
18
|
// Hook files are optional, but in development vite logs an error even though
|
|
19
19
|
// we suppress the exception. Silence these logs manually.
|
|
20
|
-
['
|
|
21
|
-
['
|
|
20
|
+
['Error when evaluating SSR module', 'props.ts'],
|
|
21
|
+
['Error when evaluating SSR module', 'runtime.ts'],
|
|
22
22
|
];
|
|
23
23
|
|
|
24
24
|
function isIgnoredError(msg: string) {
|
package/build/excludes/index.ts
CHANGED
package/build/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { build } from 'vite';
|
|
|
5
5
|
|
|
6
6
|
import { loadBuildConfig } from '../server/loaders/build.js';
|
|
7
7
|
import { loadApps } from '../server/loaders/apps.js';
|
|
8
|
+
import { loadAppDirectories } from '../server/loaders/directories.js';
|
|
8
9
|
import type { Project } from '../server/loaders/project.js';
|
|
9
10
|
import { loadProject } from '../server/loaders/project.js';
|
|
10
11
|
import {
|
|
@@ -22,19 +23,23 @@ export async function buildMicroFrontend() {
|
|
|
22
23
|
// Read project meta info from package.json
|
|
23
24
|
const project = await loadProject(root);
|
|
24
25
|
|
|
26
|
+
// Load app directories following the `apps/{name}` convention
|
|
27
|
+
const appDirectories = await loadAppDirectories(root);
|
|
28
|
+
|
|
25
29
|
// Build client
|
|
26
30
|
const clientViteConfig = await viteConfigProductionClient({
|
|
27
31
|
root,
|
|
28
32
|
base: staticPath,
|
|
29
33
|
buildConfig,
|
|
30
34
|
project,
|
|
35
|
+
appDirectories,
|
|
31
36
|
});
|
|
32
37
|
console.log('Producing production client build...');
|
|
33
38
|
await build(clientViteConfig);
|
|
34
39
|
|
|
35
40
|
// Create nerest-manifest.json that production server reads on startup
|
|
36
41
|
console.log('Producing Nerest manifest file...');
|
|
37
|
-
await createNerestManifest(root, staticPath, project);
|
|
42
|
+
await createNerestManifest(root, appDirectories, staticPath, project);
|
|
38
43
|
|
|
39
44
|
// Build server
|
|
40
45
|
const serverViteConfig = await viteConfigProductionServer({
|
|
@@ -42,6 +47,7 @@ export async function buildMicroFrontend() {
|
|
|
42
47
|
base: staticPath,
|
|
43
48
|
buildConfig,
|
|
44
49
|
project,
|
|
50
|
+
appDirectories,
|
|
45
51
|
});
|
|
46
52
|
console.log('Producing production server build...');
|
|
47
53
|
await build(serverViteConfig);
|
|
@@ -49,10 +55,11 @@ export async function buildMicroFrontend() {
|
|
|
49
55
|
|
|
50
56
|
async function createNerestManifest(
|
|
51
57
|
root: string,
|
|
58
|
+
appDirectories: string[],
|
|
52
59
|
staticPath: string,
|
|
53
60
|
project: Project
|
|
54
61
|
) {
|
|
55
|
-
const apps = await loadApps(root, staticPath);
|
|
62
|
+
const apps = await loadApps(root, appDirectories, staticPath);
|
|
56
63
|
await fs.writeFile(
|
|
57
64
|
path.join(root, 'build/nerest-manifest.json'),
|
|
58
65
|
JSON.stringify({ project, apps }),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import react from '@vitejs/plugin-react';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
import { viteConfigShared } from './shared.js';
|
|
3
4
|
import logger from './vite-logger.development.js';
|
|
4
5
|
export async function viteConfigDevelopmentClient(args) {
|
|
@@ -9,8 +10,11 @@ export async function viteConfigDevelopmentClient(args) {
|
|
|
9
10
|
manifest: true,
|
|
10
11
|
modulePreload: false,
|
|
11
12
|
watch: {},
|
|
12
|
-
|
|
13
|
-
input:
|
|
13
|
+
rolldownOptions: {
|
|
14
|
+
input: [
|
|
15
|
+
'/node_modules/@nerest/nerest/client/index.ts',
|
|
16
|
+
...args.appDirectories.map((dir) => path.join(dir, 'index.tsx')),
|
|
17
|
+
],
|
|
14
18
|
output: {
|
|
15
19
|
dir: 'build/client/assets',
|
|
16
20
|
entryFileNames: `[name].js`,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { viteExternalsPlugin } from 'vite-plugin-externals';
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
|
+
import path from 'path';
|
|
3
4
|
import { viteConfigShared } from './shared.js';
|
|
4
5
|
import { excludes } from '../excludes/index.js';
|
|
5
6
|
export async function viteConfigProductionClient(args) {
|
|
@@ -9,8 +10,11 @@ export async function viteConfigProductionClient(args) {
|
|
|
9
10
|
// Manifest is needed to report used assets in SSR handles
|
|
10
11
|
manifest: true,
|
|
11
12
|
modulePreload: false,
|
|
12
|
-
|
|
13
|
-
input:
|
|
13
|
+
rolldownOptions: {
|
|
14
|
+
input: [
|
|
15
|
+
'/node_modules/@nerest/nerest/client/index.ts',
|
|
16
|
+
...args.appDirectories.map((dir) => path.join(dir, 'index.tsx')),
|
|
17
|
+
],
|
|
14
18
|
output: {
|
|
15
19
|
dir: 'build/client/assets',
|
|
16
20
|
entryFileNames: `[name].js`,
|
|
@@ -38,7 +42,7 @@ export async function viteConfigProductionServer(args) {
|
|
|
38
42
|
modulePreload: false,
|
|
39
43
|
// This is an important setting for producing a server build
|
|
40
44
|
ssr: true,
|
|
41
|
-
|
|
45
|
+
rolldownOptions: {
|
|
42
46
|
input: '/node_modules/@nerest/nerest/server/production.ts',
|
|
43
47
|
output: {
|
|
44
48
|
dir: 'build',
|
|
@@ -13,8 +13,8 @@ export default logger;
|
|
|
13
13
|
const ignoredErrors = [
|
|
14
14
|
// Hook files are optional, but in development vite logs an error even though
|
|
15
15
|
// we suppress the exception. Silence these logs manually.
|
|
16
|
-
['
|
|
17
|
-
['
|
|
16
|
+
['Error when evaluating SSR module', 'props.ts'],
|
|
17
|
+
['Error when evaluating SSR module', 'runtime.ts'],
|
|
18
18
|
];
|
|
19
19
|
function isIgnoredError(msg) {
|
|
20
20
|
for (const markers of ignoredErrors) {
|
package/dist/build/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import fs from 'fs/promises';
|
|
|
3
3
|
import { build } from 'vite';
|
|
4
4
|
import { loadBuildConfig } from '../server/loaders/build.js';
|
|
5
5
|
import { loadApps } from '../server/loaders/apps.js';
|
|
6
|
+
import { loadAppDirectories } from '../server/loaders/directories.js';
|
|
6
7
|
import { loadProject } from '../server/loaders/project.js';
|
|
7
8
|
import { viteConfigProductionClient, viteConfigProductionServer, } from './configs/production.js';
|
|
8
9
|
export async function buildMicroFrontend() {
|
|
@@ -12,30 +13,34 @@ export async function buildMicroFrontend() {
|
|
|
12
13
|
const buildConfig = await loadBuildConfig(root);
|
|
13
14
|
// Read project meta info from package.json
|
|
14
15
|
const project = await loadProject(root);
|
|
16
|
+
// Load app directories following the `apps/{name}` convention
|
|
17
|
+
const appDirectories = await loadAppDirectories(root);
|
|
15
18
|
// Build client
|
|
16
19
|
const clientViteConfig = await viteConfigProductionClient({
|
|
17
20
|
root,
|
|
18
21
|
base: staticPath,
|
|
19
22
|
buildConfig,
|
|
20
23
|
project,
|
|
24
|
+
appDirectories,
|
|
21
25
|
});
|
|
22
26
|
console.log('Producing production client build...');
|
|
23
27
|
await build(clientViteConfig);
|
|
24
28
|
// Create nerest-manifest.json that production server reads on startup
|
|
25
29
|
console.log('Producing Nerest manifest file...');
|
|
26
|
-
await createNerestManifest(root, staticPath, project);
|
|
30
|
+
await createNerestManifest(root, appDirectories, staticPath, project);
|
|
27
31
|
// Build server
|
|
28
32
|
const serverViteConfig = await viteConfigProductionServer({
|
|
29
33
|
root,
|
|
30
34
|
base: staticPath,
|
|
31
35
|
buildConfig,
|
|
32
36
|
project,
|
|
37
|
+
appDirectories,
|
|
33
38
|
});
|
|
34
39
|
console.log('Producing production server build...');
|
|
35
40
|
await build(serverViteConfig);
|
|
36
41
|
}
|
|
37
|
-
async function createNerestManifest(root, staticPath, project) {
|
|
38
|
-
const apps = await loadApps(root, staticPath);
|
|
42
|
+
async function createNerestManifest(root, appDirectories, staticPath, project) {
|
|
43
|
+
const apps = await loadApps(root, appDirectories, staticPath);
|
|
39
44
|
await fs.writeFile(path.join(root, 'build/nerest-manifest.json'), JSON.stringify({ project, apps }), 'utf-8');
|
|
40
45
|
}
|
|
41
46
|
function prepareStaticPath() {
|
|
@@ -7,6 +7,7 @@ import { createServer } from './shared.js';
|
|
|
7
7
|
import { viteConfigDevelopmentClient, viteConfigDevelopmentServer, } from '../build/configs/development.js';
|
|
8
8
|
import { loadBuildConfig } from './loaders/build.js';
|
|
9
9
|
import { loadApps } from './loaders/apps.js';
|
|
10
|
+
import { loadAppDirectories } from './loaders/directories.js';
|
|
10
11
|
import { loadProject } from './loaders/project.js';
|
|
11
12
|
export async function runDevelopmentServer(port) {
|
|
12
13
|
const root = process.cwd();
|
|
@@ -20,12 +21,15 @@ export async function runDevelopmentServer(port) {
|
|
|
20
21
|
const buildConfig = await loadBuildConfig(root);
|
|
21
22
|
// Load project meta details
|
|
22
23
|
const project = await loadProject(root);
|
|
24
|
+
// Load app directories following the `apps/{name}` convention
|
|
25
|
+
const appDirectories = await loadAppDirectories(root);
|
|
23
26
|
// Build the clientside assets and watch for changes
|
|
24
27
|
await startClientBuildWatcher(await viteConfigDevelopmentClient({
|
|
25
28
|
root,
|
|
26
29
|
base: staticPath,
|
|
27
30
|
buildConfig,
|
|
28
31
|
project,
|
|
32
|
+
appDirectories,
|
|
29
33
|
}));
|
|
30
34
|
// Start vite server that will be rendering SSR components
|
|
31
35
|
const viteSsr = await createViteServer(await viteConfigDevelopmentServer({
|
|
@@ -33,9 +37,10 @@ export async function runDevelopmentServer(port) {
|
|
|
33
37
|
base: staticPath,
|
|
34
38
|
buildConfig,
|
|
35
39
|
project,
|
|
40
|
+
appDirectories,
|
|
36
41
|
}));
|
|
37
42
|
// Load app entries following the `apps/{name}/index.tsx` convention
|
|
38
|
-
const apps = await loadApps(root, staticPath);
|
|
43
|
+
const apps = await loadApps(root, appDirectories, staticPath);
|
|
39
44
|
const app = await createServer({
|
|
40
45
|
root,
|
|
41
46
|
project,
|
|
@@ -71,7 +76,7 @@ async function startClientBuildWatcher(config) {
|
|
|
71
76
|
const watcher = (await build(config));
|
|
72
77
|
return new Promise((resolve) => {
|
|
73
78
|
// We need to have a built manifest.json to provide assets
|
|
74
|
-
// links in SSR. We will wait for
|
|
79
|
+
// links in SSR. We will wait for rolldown to report when it
|
|
75
80
|
// has finished the build
|
|
76
81
|
const listener = (ev) => {
|
|
77
82
|
if (ev.code === 'END') {
|
|
@@ -8,6 +8,6 @@ export type AppEntry = {
|
|
|
8
8
|
examples: Record<string, unknown>;
|
|
9
9
|
schema: JSONSchema | null;
|
|
10
10
|
};
|
|
11
|
-
export declare function loadApps(root: string, deployedStaticPath: string): Promise<{
|
|
11
|
+
export declare function loadApps(root: string, appDirs: string[], deployedStaticPath: string): Promise<{
|
|
12
12
|
[k: string]: AppEntry;
|
|
13
13
|
}>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import fg from 'fast-glob';
|
|
3
2
|
import { loadAppAssets } from './assets.js';
|
|
4
3
|
import { loadAppExamples } from './examples.js';
|
|
5
4
|
import { loadAppSchema } from './schema.js';
|
|
@@ -7,11 +6,8 @@ import { loadViteManifest } from './manifest.js';
|
|
|
7
6
|
// Build the record of the available apps by convention
|
|
8
7
|
// apps -> /apps/{name}/index.tsx
|
|
9
8
|
// examples -> /apps/{name}/examples/{example}.json
|
|
10
|
-
export async function loadApps(root, deployedStaticPath) {
|
|
9
|
+
export async function loadApps(root, appDirs, deployedStaticPath) {
|
|
11
10
|
const manifest = await loadViteManifest(root);
|
|
12
|
-
const appBase = path.join(root, 'apps');
|
|
13
|
-
const appPattern = `${fg.convertPathToPattern(appBase)}/*`;
|
|
14
|
-
const appDirs = await fg.glob(appPattern, { onlyDirectories: true });
|
|
15
11
|
const apps = [];
|
|
16
12
|
for (const appDir of appDirs) {
|
|
17
13
|
apps.push(await loadApp(appDir, manifest, deployedStaticPath));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadAppDirectories(root: string): Promise<string[]>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fg from 'fast-glob';
|
|
3
|
+
// Load app directories following the `apps/{name}` convention
|
|
4
|
+
export async function loadAppDirectories(root) {
|
|
5
|
+
const appBase = path.join(root, 'apps');
|
|
6
|
+
const appPattern = `${fg.convertPathToPattern(appBase)}/*`;
|
|
7
|
+
return fg.glob(appPattern, { onlyDirectories: true });
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nerest/nerest",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "React micro frontend framework",
|
|
5
5
|
"homepage": "https://github.com/nerestjs/nerest",
|
|
6
6
|
"repository": {
|
|
@@ -49,39 +49,39 @@
|
|
|
49
49
|
]
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@apidevtools/json-schema-ref-parser": "^15.3.
|
|
53
|
-
"@fastify/middie": "^9.
|
|
54
|
-
"@fastify/static": "^9.
|
|
52
|
+
"@apidevtools/json-schema-ref-parser": "^15.3.5",
|
|
53
|
+
"@fastify/middie": "^9.3.1",
|
|
54
|
+
"@fastify/static": "^9.1.0",
|
|
55
55
|
"@fastify/swagger": "^9.7.0",
|
|
56
56
|
"@fastify/swagger-ui": "^5.2.5",
|
|
57
|
-
"@vitejs/plugin-react": "^
|
|
57
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
58
58
|
"ajv": "^8.18.0",
|
|
59
59
|
"ajv-formats": "^3.0.1",
|
|
60
|
-
"dotenv": "^17.
|
|
60
|
+
"dotenv": "^17.4.1",
|
|
61
61
|
"fast-glob": "^3.3.3",
|
|
62
62
|
"fast-uri": "^3.1.0",
|
|
63
|
-
"fastify": "^5.
|
|
63
|
+
"fastify": "^5.8.4",
|
|
64
64
|
"fastify-graceful-shutdown": "^5.0.0",
|
|
65
65
|
"json-schema-to-typescript": "^15.0.4",
|
|
66
|
-
"vite": "^
|
|
66
|
+
"vite": "^8.0.7",
|
|
67
67
|
"vite-plugin-externals": "^0.6.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@commitlint/cli": "^20.
|
|
71
|
-
"@commitlint/config-conventional": "^20.
|
|
72
|
-
"@playwright/test": "^1.
|
|
73
|
-
"@tinkoff/eslint-config": "^5.0
|
|
74
|
-
"@tinkoff/eslint-config-react": "^5.0
|
|
70
|
+
"@commitlint/cli": "^20.5.0",
|
|
71
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
72
|
+
"@playwright/test": "^1.59.1",
|
|
73
|
+
"@tinkoff/eslint-config": "^5.2.0",
|
|
74
|
+
"@tinkoff/eslint-config-react": "^5.2.0",
|
|
75
75
|
"@tinkoff/prettier-config": "^5.0.0",
|
|
76
76
|
"@types/react": "^19.2.14",
|
|
77
77
|
"@types/react-dom": "^19.2.3",
|
|
78
|
-
"lint-staged": "^16.
|
|
79
|
-
"react": "^19.2.
|
|
80
|
-
"react-dom": "^19.2.
|
|
78
|
+
"lint-staged": "^16.4.0",
|
|
79
|
+
"react": "^19.2.5",
|
|
80
|
+
"react-dom": "^19.2.5",
|
|
81
81
|
"simple-git-hooks": "^2.13.1",
|
|
82
82
|
"sort-package-json": "^3.6.1",
|
|
83
|
-
"typescript": "^
|
|
84
|
-
"vitest": "^4.
|
|
83
|
+
"typescript": "^6.0.2",
|
|
84
|
+
"vitest": "^4.1.4"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"react": "^18.0.0 || ^19.0.0",
|
package/server/development.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { build, createServer as createViteServer } from 'vite';
|
|
4
4
|
import type { InlineConfig } from 'vite';
|
|
5
|
-
import type {
|
|
5
|
+
import type { RolldownWatcher, RolldownWatcherEvent } from 'rolldown';
|
|
6
6
|
import fastifyStatic from '@fastify/static';
|
|
7
7
|
import fastifyMiddie from '@fastify/middie';
|
|
8
8
|
import { createServer } from './shared.js';
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from '../build/configs/development.js';
|
|
13
13
|
import { loadBuildConfig } from './loaders/build.js';
|
|
14
14
|
import { loadApps } from './loaders/apps.js';
|
|
15
|
+
import { loadAppDirectories } from './loaders/directories.js';
|
|
15
16
|
import { loadProject } from './loaders/project.js';
|
|
16
17
|
|
|
17
18
|
export async function runDevelopmentServer(port: number) {
|
|
@@ -30,6 +31,9 @@ export async function runDevelopmentServer(port: number) {
|
|
|
30
31
|
// Load project meta details
|
|
31
32
|
const project = await loadProject(root);
|
|
32
33
|
|
|
34
|
+
// Load app directories following the `apps/{name}` convention
|
|
35
|
+
const appDirectories = await loadAppDirectories(root);
|
|
36
|
+
|
|
33
37
|
// Build the clientside assets and watch for changes
|
|
34
38
|
await startClientBuildWatcher(
|
|
35
39
|
await viteConfigDevelopmentClient({
|
|
@@ -37,6 +41,7 @@ export async function runDevelopmentServer(port: number) {
|
|
|
37
41
|
base: staticPath,
|
|
38
42
|
buildConfig,
|
|
39
43
|
project,
|
|
44
|
+
appDirectories,
|
|
40
45
|
})
|
|
41
46
|
);
|
|
42
47
|
|
|
@@ -47,11 +52,12 @@ export async function runDevelopmentServer(port: number) {
|
|
|
47
52
|
base: staticPath,
|
|
48
53
|
buildConfig,
|
|
49
54
|
project,
|
|
55
|
+
appDirectories,
|
|
50
56
|
})
|
|
51
57
|
);
|
|
52
58
|
|
|
53
59
|
// Load app entries following the `apps/{name}/index.tsx` convention
|
|
54
|
-
const apps = await loadApps(root, staticPath);
|
|
60
|
+
const apps = await loadApps(root, appDirectories, staticPath);
|
|
55
61
|
|
|
56
62
|
const app = await createServer({
|
|
57
63
|
root,
|
|
@@ -97,12 +103,12 @@ export async function runDevelopmentServer(port: number) {
|
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
async function startClientBuildWatcher(config: InlineConfig) {
|
|
100
|
-
const watcher = (await build(config)) as
|
|
106
|
+
const watcher = (await build(config)) as RolldownWatcher;
|
|
101
107
|
return new Promise<void>((resolve) => {
|
|
102
108
|
// We need to have a built manifest.json to provide assets
|
|
103
|
-
// links in SSR. We will wait for
|
|
109
|
+
// links in SSR. We will wait for rolldown to report when it
|
|
104
110
|
// has finished the build
|
|
105
|
-
const listener = (ev:
|
|
111
|
+
const listener = (ev: RolldownWatcherEvent) => {
|
|
106
112
|
if (ev.code === 'END') {
|
|
107
113
|
watcher.off('event', listener);
|
|
108
114
|
resolve();
|
package/server/loaders/apps.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import fg from 'fast-glob';
|
|
3
2
|
import type { Manifest as ViteManifest } from 'vite';
|
|
4
3
|
import type { JSONSchema } from '@apidevtools/json-schema-ref-parser';
|
|
5
4
|
|
|
@@ -21,13 +20,13 @@ export type AppEntry = {
|
|
|
21
20
|
// Build the record of the available apps by convention
|
|
22
21
|
// apps -> /apps/{name}/index.tsx
|
|
23
22
|
// examples -> /apps/{name}/examples/{example}.json
|
|
24
|
-
export async function loadApps(
|
|
23
|
+
export async function loadApps(
|
|
24
|
+
root: string,
|
|
25
|
+
appDirs: string[],
|
|
26
|
+
deployedStaticPath: string
|
|
27
|
+
) {
|
|
25
28
|
const manifest = await loadViteManifest(root);
|
|
26
29
|
|
|
27
|
-
const appBase = path.join(root, 'apps');
|
|
28
|
-
const appPattern = `${fg.convertPathToPattern(appBase)}/*`;
|
|
29
|
-
const appDirs = await fg.glob(appPattern, { onlyDirectories: true });
|
|
30
|
-
|
|
31
30
|
const apps: Array<[name: string, entry: AppEntry]> = [];
|
|
32
31
|
for (const appDir of appDirs) {
|
|
33
32
|
apps.push(await loadApp(appDir, manifest, deployedStaticPath));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fg from 'fast-glob';
|
|
3
|
+
|
|
4
|
+
// Load app directories following the `apps/{name}` convention
|
|
5
|
+
export async function loadAppDirectories(root: string) {
|
|
6
|
+
const appBase = path.join(root, 'apps');
|
|
7
|
+
const appPattern = `${fg.convertPathToPattern(appBase)}/*`;
|
|
8
|
+
return fg.glob(appPattern, { onlyDirectories: true });
|
|
9
|
+
}
|