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:
|
JS_RUNNER_MEMORY_LIMIT:
|
||||||
parseIntSafe(process.env.JS_RUNNER_MEMORY_LIMIT) || 64,
|
parseIntSafe(process.env.JS_RUNNER_MEMORY_LIMIT) || 64,
|
||||||
LOG_JS_ERRORS: process.env.LOG_JS_ERRORS,
|
LOG_JS_ERRORS: process.env.LOG_JS_ERRORS,
|
||||||
|
isBundled: process.env.BUNDLED,
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up any environment variable edge cases
|
// clean up any environment variable edge cases
|
||||||
|
|
|
@ -8,20 +8,21 @@ export const enum BundleType {
|
||||||
}
|
}
|
||||||
|
|
||||||
const bundleSourceCode = {
|
const bundleSourceCode = {
|
||||||
[BundleType.HELPERS]: "../bundles/index-helpers.ivm.bundle.js",
|
[BundleType.HELPERS]: "./index-helpers.ivm.bundle.js",
|
||||||
[BundleType.BSON]: "../bundles/bson.ivm.bundle.js",
|
[BundleType.BSON]: "./bson.ivm.bundle.js",
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadBundle(type: BundleType) {
|
export function loadBundle(type: BundleType) {
|
||||||
if (environment.isJest()) {
|
if (!environment.isBundled) {
|
||||||
return fs.readFileSync(require.resolve(bundleSourceCode[type]), "utf-8")
|
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) {
|
switch (type) {
|
||||||
case BundleType.HELPERS:
|
case BundleType.HELPERS:
|
||||||
return require("../bundles/index-helpers.ivm.bundle.js")
|
return require("./index-helpers.ivm.bundle.js")
|
||||||
case BundleType.BSON:
|
case BundleType.BSON:
|
||||||
return require("../bundles/bson.ivm.bundle.js")
|
return require("./bson.ivm.bundle.js")
|
||||||
default:
|
default:
|
||||||
utils.unreachable(type)
|
utils.unreachable(type)
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,9 @@ function runBuild(entry, outfile) {
|
||||||
"graphql/*",
|
"graphql/*",
|
||||||
"bson",
|
"bson",
|
||||||
],
|
],
|
||||||
|
define: {
|
||||||
|
"process.env.BUNDLED": '"true"',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
build({
|
build({
|
||||||
|
|
Loading…
Reference in New Issue