@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.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { templatemarkutil } from '@accordproject/markdown-template';
|
|
|
14
14
|
import { existsSync, mkdirSync, rmSync } from 'fs';
|
|
15
15
|
import * as lzstring from 'lz-string';
|
|
16
16
|
import child_process from 'child_process';
|
|
17
|
+
import path from 'path';
|
|
17
18
|
|
|
18
19
|
function booleanDrafter(value) {
|
|
19
20
|
if (value) {
|
|
@@ -318,7 +319,7 @@ class TypeScriptToJavaScriptCompiler {
|
|
|
318
319
|
this.typescriptUrl = typescriptUrl;
|
|
319
320
|
}
|
|
320
321
|
if (typeof window === "undefined") {
|
|
321
|
-
this.ts = await import('typescript');
|
|
322
|
+
this.ts = (await import('typescript')).default;
|
|
322
323
|
if (!this.ts) {
|
|
323
324
|
throw new Error("Failed to load typescript module");
|
|
324
325
|
}
|
|
@@ -346,6 +347,9 @@ ${typescript}
|
|
|
346
347
|
const options = {
|
|
347
348
|
fsMap: this.fsMap,
|
|
348
349
|
tsModule: this.ts,
|
|
350
|
+
defaultCompilerOptions: {
|
|
351
|
+
target: ES2020_TARGET
|
|
352
|
+
},
|
|
349
353
|
lzstringModule: lzstring,
|
|
350
354
|
defaultOptions: {
|
|
351
355
|
showEmit: true,
|
|
@@ -522,13 +526,22 @@ class JavaScriptEvaluator {
|
|
|
522
526
|
});
|
|
523
527
|
}
|
|
524
528
|
}
|
|
529
|
+
getWorkerPath() {
|
|
530
|
+
try {
|
|
531
|
+
const thisPath = require.resolve("@accordproject/template-engine");
|
|
532
|
+
return path.join(thisPath, "..", "worker.js");
|
|
533
|
+
} catch (err) {
|
|
534
|
+
return path.join(__dirname, "..", "dist", "worker.js");
|
|
535
|
+
}
|
|
536
|
+
}
|
|
525
537
|
doWork(work, options) {
|
|
526
538
|
return new Promise((resolve, reject) => {
|
|
527
539
|
const start = (/* @__PURE__ */ new Date()).getTime();
|
|
528
540
|
if (!child_process.fork) {
|
|
529
541
|
reject({ message: "Cannot use evalChildProcess because child_process.fork is not defined." });
|
|
530
542
|
}
|
|
531
|
-
const
|
|
543
|
+
const workerPath = this.getWorkerPath();
|
|
544
|
+
const worker = child_process.fork(workerPath, { timeout: options.timeout, env: {} });
|
|
532
545
|
if (!worker.pid) {
|
|
533
546
|
throw new Error("Failed to fork child process");
|
|
534
547
|
}
|