Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Remove AMD define for
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdh committed Mar 10, 2018
1 parent 031e6ca commit 6d3b612
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions lib/muon/module_system/commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,29 @@ const commonjs = function (fn, exports, modulePath, __global__) {
moduleDir = modulePath
}

define(['console'], (console) => {
const requireProxy = (moduleName) => {
// handle relative require paths
moduleName = moduleName.startsWith('.') && modulePath ?
path.append(moduleDir, moduleName) : moduleName
const workerConsole = console

if (!path.require(moduleName))
throw new ModuleNotFoundError(moduleName)
const requireProxy = (moduleName) => {
// handle relative require paths
moduleName = moduleName.startsWith('.') && modulePath ?
path.append(moduleDir, moduleName) : moduleName

// handle module.exports = mymodule
const module = require(moduleName)
return module.binding || module
}
if (!path.require(moduleName))
throw new ModuleNotFoundError(moduleName)

try {
fn.apply(__global__, [requireProxy, moduleProxy, console])
} catch (e) {
if (__global__.onerror) {
__global__.onerror(e)
}
throw e
// handle module.exports = mymodule
const module = require(moduleName)
return module.binding || module
}

try {
fn.apply(__global__, [requireProxy, moduleProxy, workerConsole])
} catch (e) {
if (__global__.onerror) {
__global__.onerror(e)
}
})
throw e
}
}

exports.$set('require', commonjs)

0 comments on commit 6d3b612

Please sign in to comment.