@accordproject/template-engine 2.5.4 → 2.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var markdownTemplate = require('@accordproject/markdown-template');
|
|
|
16
16
|
var fs = require('fs');
|
|
17
17
|
var lzstring = require('lz-string');
|
|
18
18
|
var child_process = require('child_process');
|
|
19
|
+
var path = require('path');
|
|
19
20
|
|
|
20
21
|
function _interopNamespaceDefault(e) {
|
|
21
22
|
var n = Object.create(null);
|
|
@@ -339,7 +340,7 @@ class TypeScriptToJavaScriptCompiler {
|
|
|
339
340
|
this.typescriptUrl = typescriptUrl;
|
|
340
341
|
}
|
|
341
342
|
if (typeof window === "undefined") {
|
|
342
|
-
this.ts = await import('typescript');
|
|
343
|
+
this.ts = (await import('typescript')).default;
|
|
343
344
|
if (!this.ts) {
|
|
344
345
|
throw new Error("Failed to load typescript module");
|
|
345
346
|
}
|
|
@@ -367,6 +368,9 @@ ${typescript}
|
|
|
367
368
|
const options = {
|
|
368
369
|
fsMap: this.fsMap,
|
|
369
370
|
tsModule: this.ts,
|
|
371
|
+
defaultCompilerOptions: {
|
|
372
|
+
target: ES2020_TARGET
|
|
373
|
+
},
|
|
370
374
|
lzstringModule: lzstring__namespace,
|
|
371
375
|
defaultOptions: {
|
|
372
376
|
showEmit: true,
|
|
@@ -543,13 +547,22 @@ class JavaScriptEvaluator {
|
|
|
543
547
|
});
|
|
544
548
|
}
|
|
545
549
|
}
|
|
550
|
+
getWorkerPath() {
|
|
551
|
+
try {
|
|
552
|
+
const thisPath = require.resolve("@accordproject/template-engine");
|
|
553
|
+
return path.join(thisPath, "..", "worker.js");
|
|
554
|
+
} catch (err) {
|
|
555
|
+
return path.join(__dirname, "..", "dist", "worker.js");
|
|
556
|
+
}
|
|
557
|
+
}
|
|
546
558
|
doWork(work, options) {
|
|
547
559
|
return new Promise((resolve, reject) => {
|
|
548
560
|
const start = (/* @__PURE__ */ new Date()).getTime();
|
|
549
561
|
if (!child_process.fork) {
|
|
550
562
|
reject({ message: "Cannot use evalChildProcess because child_process.fork is not defined." });
|
|
551
563
|
}
|
|
552
|
-
const
|
|
564
|
+
const workerPath = this.getWorkerPath();
|
|
565
|
+
const worker = child_process.fork(workerPath, { timeout: options.timeout, env: {} });
|
|
553
566
|
if (!worker.pid) {
|
|
554
567
|
throw new Error("Failed to fork child process");
|
|
555
568
|
}
|