1
0
Fork 0
mirror of synced 2024-09-28 07:11:40 +12:00

Fix ts-node and other runners

This commit is contained in:
Adria Navarro 2024-02-13 17:43:42 +01:00
parent 0bf94bcd7b
commit 9ed6502681
3 changed files with 10 additions and 5 deletions

View file

@ -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

View file

@ -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)
}

View file

@ -63,6 +63,9 @@ function runBuild(entry, outfile) {
"graphql/*",
"bson",
],
define: {
"process.env.BUNDLED": '"true"',
},
}
build({