Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
fix: stub module.exports
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Dec 17, 2021
1 parent 88aaf3e commit f3b7ee9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/peeky-runner/src/runtime/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,16 @@ async function rawRequest (id: string, realPath: string, ctx: ExecutionContext):

const url = pathToFileURL(realPath).href

const exports = {}
const exports: any = {}
const moduleProxy = {
set exports (value) {
exportAll(exports, value)
exports.default = value
},
get exports () {
return exports.default
},
}

const context = {
// Vite SSR transforms
Expand All @@ -253,6 +262,7 @@ async function rawRequest (id: string, realPath: string, ctx: ExecutionContext):
// CJS compatibility
require: createRequire(url),
exports,
module: moduleProxy,
__filename: realPath,
__dirname: dirname(realPath),
// Peeky globals
Expand Down

0 comments on commit f3b7ee9

Please sign in to comment.