Skip to content

Commit c62c5cd

Browse files
committed
update vitepress config
1 parent 8ac9b2a commit c62c5cd

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

docs/.vitepress/build-system/build.mts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ build(
1515
),
1616
path.join(dirname, './shim/@typescript-eslint/parser.mjs'),
1717
[
18-
'stream',
19-
'node:stream',
20-
'os',
21-
'node:os',
2218
'util',
2319
'node:util',
2420
'path',
@@ -70,16 +66,22 @@ function bundle(entryPoint: string, externals: string[]) {
7066
}
7167

7268
function transform(code: string, injects: string[]) {
69+
const normalizeInjects = [
70+
...new Set(injects.map((inject) => inject.replace(/^node:/u, '')))
71+
]
7372
const newCode = code.replace(/"[a-z]+" = "[a-z]+";/u, '')
7473
return `
75-
${injects
74+
${normalizeInjects
7675
.map(
7776
(inject) =>
7877
`import $inject_${inject.replace(/[\-:]/gu, '_')}$ from '${inject}';`
7978
)
8079
.join('\n')}
8180
const $_injects_$ = {${injects
82-
.map((inject) => `"${inject}":$inject_${inject.replace(/[\-:]/gu, '_')}$`)
81+
.map(
82+
(inject) =>
83+
`"${inject}":$inject_${inject.replace(/^node:/u, '').replace(/[\-:]/gu, '_')}$`
84+
)
8385
.join(',\n')}};
8486
function require(module, ...args) {
8587
return $_injects_$[module] || {}

docs/.vitepress/config.mts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,16 @@ export default async () => {
162162

163163
tslib: path.join(dirname, '../../node_modules/tslib/tslib.es6.js'),
164164
globby: path.join(dirname, './build-system/shim/empty.mjs'),
165-
'fast-glob': path.join(dirname, './build-system/shim/empty.mjs'),
166-
'node:fs': 'fs',
167-
'node:path': 'path',
168-
'node:util': 'util'
165+
'fast-glob': path.join(dirname, './build-system/shim/empty.mjs')
169166
}
170167
},
171168
define: {
172169
'require.cache': '{}'
170+
},
171+
build: {
172+
rollupOptions: {
173+
external: ['module']
174+
}
173175
}
174176
},
175177

0 commit comments

Comments
 (0)