@memberjunction/code-execution 3.4.0 → 4.1.0

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/src/WorkerPool.ts CHANGED
@@ -14,6 +14,10 @@
14
14
 
15
15
  import { fork, ChildProcess } from 'child_process';
16
16
  import * as path from 'path';
17
+ import { fileURLToPath } from 'node:url';
18
+
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = path.dirname(__filename);
17
21
  import { CodeExecutionParams, CodeExecutionResult } from './types';
18
22
  import { LogError, LogStatus } from '@memberjunction/core';
19
23
 
@@ -9,6 +9,14 @@
9
9
  * SECURITY NOTE: Only add libraries here that are safe for untrusted code execution.
10
10
  */
11
11
 
12
+ import fs from 'fs';
13
+ import path from 'path';
14
+ import { fileURLToPath } from 'url';
15
+
16
+ // Get __dirname equivalent in ESM
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = path.dirname(__filename);
19
+
12
20
  /**
13
21
  * Allowed module names
14
22
  */
@@ -381,12 +389,6 @@ function getValidatorSource(): string {
381
389
  * We bundle the actual mathjs library for full functionality
382
390
  */
383
391
  function getMathjsSource(): string {
384
- // Load bundled library source at compile time
385
- // eslint-disable-next-line @typescript-eslint/no-var-requires
386
- const fs = require('fs');
387
- // eslint-disable-next-line @typescript-eslint/no-var-requires
388
- const path = require('path');
389
-
390
392
  const libPath = path.join(__dirname, 'bundled-libs', 'mathjs.js');
391
393
  const source = fs.readFileSync(libPath, 'utf8');
392
394
 
@@ -403,12 +405,6 @@ function getMathjsSource(): string {
403
405
  * We bundle the actual papaparse library
404
406
  */
405
407
  function getPapaparseSource(): string {
406
- // Load bundled library source at compile time
407
- // eslint-disable-next-line @typescript-eslint/no-var-requires
408
- const fs = require('fs');
409
- // eslint-disable-next-line @typescript-eslint/no-var-requires
410
- const path = require('path');
411
-
412
408
  const libPath = path.join(__dirname, 'bundled-libs', 'papaparse.js');
413
409
  const source = fs.readFileSync(libPath, 'utf8');
414
410
 
@@ -425,12 +421,6 @@ function getPapaparseSource(): string {
425
421
  * We bundle the actual jstat library
426
422
  */
427
423
  function getJstatSource(): string {
428
- // Load bundled library source at compile time
429
- // eslint-disable-next-line @typescript-eslint/no-var-requires
430
- const fs = require('fs');
431
- // eslint-disable-next-line @typescript-eslint/no-var-requires
432
- const path = require('path');
433
-
434
424
  const libPath = path.join(__dirname, 'bundled-libs', 'jstat.js');
435
425
  const source = fs.readFileSync(libPath, 'utf8');
436
426
 
package/tsconfig.json CHANGED
@@ -1,25 +1,9 @@
1
1
  {
2
+ "extends": "../../../tsconfig.server.json",
2
3
  "compilerOptions": {
3
- "experimentalDecorators": true,
4
- "emitDecoratorMetadata": true,
5
- "module": "commonjs",
6
- "esModuleInterop": true,
7
- "target": "ES2022",
8
- "lib": ["ES2022"],
9
- "skipLibCheck": true,
10
- "declaration": true,
11
- "declarationMap": true,
12
- "moduleResolution": "node",
13
- "sourceMap": true,
14
- "outDir": "./dist",
15
- "rootDir": "./src"
4
+ "outDir": "dist",
5
+ "rootDir": "src"
16
6
  },
17
- "include": [
18
- "src/**/*"
19
- ],
20
- "exclude": [
21
- "node_modules",
22
- "dist",
23
- "**/*.spec.ts"
24
- ]
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules"]
25
9
  }