Fix ts-node and other runners
This commit is contained in:
parent
0bf94bcd7b
commit
9ed6502681
|
@ -98,6 +98,7 @@ const environment = {
|
|||
JS_RUNNER_MEMORY_LIMIT:
|
||||
parseIntSafe(process.env.JS_RUNNER_MEMORY_LIMIT) || 64,
|
||||
LOG_JS_ERRORS: process.env.LOG_JS_ERRORS,
|
||||
isBundled: process.env.BUNDLED,
|
||||
}
|
||||
|
||||
// clean up any environment variable edge cases
|
||||
|
|
|
@ -8,20 +8,21 @@ export const enum BundleType {
|
|||
}
|
||||
|
||||
const bundleSourceCode = {
|
||||
[BundleType.HELPERS]: "../bundles/index-helpers.ivm.bundle.js",
|
||||
[BundleType.BSON]: "../bundles/bson.ivm.bundle.js",
|
||||
[BundleType.HELPERS]: "./index-helpers.ivm.bundle.js",
|
||||
[BundleType.BSON]: "./bson.ivm.bundle.js",
|
||||
}
|
||||
|
||||
export function loadBundle(type: BundleType) {
|
||||
if (environment.isJest()) {
|
||||
if (!environment.isBundled) {
|
||||
return fs.readFileSync(require.resolve(bundleSourceCode[type]), "utf-8")
|
||||
}
|
||||
|
||||
// If we are running from a built version, esbuild is configured to inject .ivm.bundle.js files as text
|
||||
switch (type) {
|
||||
case BundleType.HELPERS:
|
||||
return require("../bundles/index-helpers.ivm.bundle.js")
|
||||
return require("./index-helpers.ivm.bundle.js")
|
||||
case BundleType.BSON:
|
||||
return require("../bundles/bson.ivm.bundle.js")
|
||||
return require("./bson.ivm.bundle.js")
|
||||
default:
|
||||
utils.unreachable(type)
|
||||
}
|
||||
|
|
|
@ -63,6 +63,9 @@ function runBuild(entry, outfile) {
|
|||
"graphql/*",
|
||||
"bson",
|
||||
],
|
||||
define: {
|
||||
"process.env.BUNDLED": '"true"',
|
||||
},
|
||||
}
|
||||
|
||||
build({
|
||||
|
|
Loading…
Reference in New Issue