Skip to content

Commit 7eaf6d9

Browse files
fix: custom node module handling and types
1 parent 28ffcd0 commit 7eaf6d9

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

package.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,10 @@
1717
"package",
1818
"library"
1919
],
20-
"files": [
21-
"dist"
22-
],
20+
"files": ["dist"],
2321
"tshy": {
24-
"exclude": [
25-
"src/**/*.test.ts",
26-
"vendor"
27-
],
28-
"dialects": [
29-
"esm",
30-
"commonjs"
31-
],
22+
"exclude": ["src/**/*.test.ts", "vendor"],
23+
"dialects": ["esm", "commonjs"],
3224
"exports": {
3325
"./package.json": "./package.json",
3426
".": "./src/index.ts"
@@ -46,7 +38,8 @@
4638
"postpublish": "npx jsr publish",
4739
"example:basic": "bun example/basic/server.ts",
4840
"example:server": "bun example/server/server.ts",
49-
"example:tests": "bun example/run-tests/index.ts"
41+
"example:tests": "bun example/run-tests/index.ts",
42+
"example:module": "bun example/custom-module/index.ts"
5043
},
5144
"author": {
5245
"name": "Sebastian Wessel",

src/getModuleLoader.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ import type { RuntimeOptions } from './types/RuntimeOptions.js'
1414
export const getModuleLoader = (options: RuntimeOptions) => {
1515
//const __dirname = dirname(fileURLToPath(import.meta.url))
1616

17-
const customVol = options?.nodeModules ? Volume.fromNestedJSON(options?.nodeModules) : {}
18-
1917
const modules: Record<string, any> = {
2018
'/': {
2119
node_modules: {
22-
...customVol,
20+
...options?.nodeModules,
2321
path: {
2422
'index.js': pathModule,
2523
},

src/types/RuntimeOptions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DirectoryJSON } from 'memfs'
1+
import type { NestedDirectoryJSON } from 'memfs'
22

33
export type RuntimeOptions = {
44
/**
@@ -10,12 +10,12 @@ export type RuntimeOptions = {
1010
* Mount a virtual file system
1111
* @link https://github.com/streamich/memfs
1212
*/
13-
mountFs?: DirectoryJSON
13+
mountFs?: NestedDirectoryJSON
1414
/**
1515
* Mount custom node_modules in a virtual file system
1616
* @link https://github.com/streamich/memfs
1717
*/
18-
nodeModules?: DirectoryJSON
18+
nodeModules?: NestedDirectoryJSON
1919
/**
2020
* Enable file capabilities
2121
* If enabled, the package node:fs becomes available

0 commit comments

Comments
 (0)