Skip to content

Commit 5cff57d

Browse files
committed
feat: update configuration files to use path resolution and add node polyfills
1 parent c733b79 commit 5cff57d

5 files changed

Lines changed: 115 additions & 3 deletions

File tree

apps/docs/source.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { defineDocs, defineConfig, frontmatterSchema } from 'fumadocs-mdx/config';
22
import { z } from 'zod';
3+
import { fileURLToPath } from 'node:url';
4+
import path from 'node:path';
5+
6+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
37

48
export const docs = defineDocs({
5-
dir: '../../content/docs',
9+
dir: path.resolve(currentDir, '../../content/docs'),
610
});
711

812
const blogSchema = frontmatterSchema.extend({
@@ -12,7 +16,7 @@ const blogSchema = frontmatterSchema.extend({
1216
});
1317

1418
export const blog = defineDocs({
15-
dir: '../../content/blog',
19+
dir: path.resolve(currentDir, '../../content/blog'),
1620
docs: {
1721
schema: blogSchema,
1822
},
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {};
2+
export class FilesystemLoader {}
3+
export class NodeMetadataManager {}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
export class EventEmitter {
2+
on() { return this; }
3+
off() { return this; }
4+
emit() { return true; }
5+
once() { return this; }
6+
addListener() { return this; }
7+
removeListener() { return this; }
8+
removeAllListeners() { return this; }
9+
}
10+
export default { EventEmitter };
11+
12+
export class Stream extends EventEmitter {
13+
pipe() { return this; }
14+
}
15+
export class Readable extends Stream {}
16+
export class Writable extends Stream {}
17+
export class Transform extends Stream {}
18+
19+
export class StringDecoder {
20+
write() { return ''; }
21+
end() { return ''; }
22+
}
23+
24+
export const promises = {
25+
readFile: async () => '',
26+
writeFile: async () => {},
27+
stat: async () => ({ isDirectory: () => false, isFile: () => false }),
28+
mkdir: async () => {},
29+
rm: async () => {},
30+
};
31+
32+
export const readFileSync = () => '';
33+
export const writeFileSync = () => {};
34+
export const statSync = () => ({ isDirectory: () => false, isFile: () => false, isSymbolicLink: () => false });
35+
export const lstatSync = () => ({ isDirectory: () => false, isFile: () => false, isSymbolicLink: () => false });
36+
export const existsSync = () => false;
37+
export const join = (...args) => args.join('/');
38+
export const resolve = (...args) => args.join('/');
39+
export const dirname = (path) => path;
40+
export const basename = (path) => path;
41+
export const extname = (path) => '';
42+
export const sep = '/';
43+
export const relative = () => '';
44+
45+
export const posix = {};
46+
export const win32 = {};
47+
48+
export const fileURLToPath = () => '';
49+
export const pathToFileURL = () => '';
50+
51+
export const readdir = () => {};
52+
export const readdirSync = () => [];
53+
export const readlink = () => {};
54+
export const readlinkSync = () => '';
55+
export const realpath = () => {};
56+
export const realpathSync = () => '';
57+
realpathSync.native = () => '';
58+
59+
export const constants = {};
60+
export const lstat = () => {};
61+
export const stat = () => {};
62+
export const access = () => {};
63+
export const accessSync = () => {};
64+
export const mkdir = () => {};
65+
export const mkdirSync = () => {};
66+
export const rmdir = () => {};
67+
export const rmdirSync = () => {};
68+
export const unlink = () => {};
69+
export const unlinkSync = () => {};
70+
export const copyFile = () => {};
71+
export const copyFileSync = () => {};
72+
export const createReadStream = () => new Readable();
73+
export const createWriteStream = () => new Writable();
74+
export const watch = () => new EventEmitter();
75+
76+
export const readFile = async () => '';
77+
export const writeFile = async () => {};
78+
export const rename = async () => {};
79+
export const createHash = () => ({ update: () => ({ digest: () => '' }) });

examples/app-react-crud/vite.config.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
3+
import path from 'path';
34

45
// https://vitejs.dev/config/
56
export default defineConfig({
7+
resolve: {
8+
alias: {
9+
'node:fs/promises': path.resolve(__dirname, './mocks/node-polyfills.ts'),
10+
'node:fs': path.resolve(__dirname, './mocks/node-polyfills.ts'),
11+
'node:events': path.resolve(__dirname, './mocks/node-polyfills.ts'),
12+
'node:stream': path.resolve(__dirname, './mocks/node-polyfills.ts'),
13+
'node:string_decoder': path.resolve(__dirname, './mocks/node-polyfills.ts'),
14+
'node:path': path.resolve(__dirname, './mocks/node-polyfills.ts'),
15+
'node:url': path.resolve(__dirname, './mocks/node-polyfills.ts'),
16+
'node:util': path.resolve(__dirname, './mocks/node-polyfills.ts'),
17+
'node:os': path.resolve(__dirname, './mocks/node-polyfills.ts'),
18+
'node:crypto': path.resolve(__dirname, './mocks/node-polyfills.ts'),
19+
'events': path.resolve(__dirname, './mocks/node-polyfills.ts'),
20+
'stream': path.resolve(__dirname, './mocks/node-polyfills.ts'),
21+
'string_decoder': path.resolve(__dirname, './mocks/node-polyfills.ts'),
22+
'path': path.resolve(__dirname, './mocks/node-polyfills.ts'),
23+
'fs/promises': path.resolve(__dirname, './mocks/node-polyfills.ts'),
24+
'fs': path.resolve(__dirname, './mocks/node-polyfills.ts'),
25+
'util': path.resolve(__dirname, './mocks/node-polyfills.ts'),
26+
'os': path.resolve(__dirname, './mocks/node-polyfills.ts'),
27+
'crypto': path.resolve(__dirname, './mocks/node-polyfills.ts'),
28+
'url': path.resolve(__dirname, './mocks/node-polyfills.ts'),
29+
}
30+
},
631
plugins: [react()],
732
server: {
833
port: 3000,
@@ -21,6 +46,7 @@ export default defineConfig({
2146
build: {
2247
commonjsOptions: {
2348
include: [/node_modules/, /packages/],
49+
exclude: [/\.node$/, /rollup/, /fsevents/],
2450
transformMixedEsModules: true
2551
},
2652
rollupOptions: {

packages/runtime/src/http-dispatcher.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('HttpDispatcher', () => {
5757

5858
it('should fallback to broker call if protocol is missing saveMetaItem', async () => {
5959
// Mock protocol without saveMetaItem
60-
kernel.context.getService = () => ({});
60+
(kernel as any).context.getService = () => ({});
6161
// Mock broker success
6262
mockBroker.call.mockResolvedValue({ success: true, fromBroker: true });
6363

0 commit comments

Comments
 (0)