isolated-function 0.1.11 → 0.1.13

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "isolated-function",
3
3
  "description": "Runs untrusted code in a Node.js v8 sandbox.",
4
4
  "homepage": "https://github.com/Kikobeats/isolated-function",
5
- "version": "0.1.11",
5
+ "version": "0.1.13",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js"
@@ -39,7 +39,6 @@
39
39
  "ensure-error": "~3.0.1",
40
40
  "esbuild": "~0.23.1",
41
41
  "serialize-error": "8",
42
- "serialize-javascript": "~6.0.2",
43
42
  "tinyspawn": "~1.3.2"
44
43
  },
45
44
  "devDependencies": {
@@ -10,7 +10,15 @@ const transformDependencies = require('./transform-dependencies')
10
10
  const detectDependencies = require('./detect-dependencies')
11
11
  const generateTemplate = require('../template')
12
12
 
13
- const MINIFY = process.env.ISOLATED_FUNCTIONS_MINIFY !== 'false'
13
+ const MINIFY = (() => {
14
+ return process.env.ISOLATED_FUNCTIONS_MINIFY !== 'false'
15
+ ? {}
16
+ : {
17
+ minifyWhitespace: true,
18
+ minifyIdentifiers: false,
19
+ minifySyntax: true
20
+ }
21
+ })()
14
22
 
15
23
  const packageManager = (() => {
16
24
  try {
@@ -47,7 +55,7 @@ module.exports = async (snippet, tmpdir = tmpdirDefault) => {
47
55
  const result = await esbuild.build({
48
56
  entryPoints: [tmp.filepath],
49
57
  bundle: true,
50
- minify: MINIFY,
58
+ ...MINIFY,
51
59
  write: false,
52
60
  platform: 'node'
53
61
  })
package/src/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  const { deserializeError } = require('serialize-error')
4
- const serialize = require('serialize-javascript')
5
4
  const timeSpan = require('@kikobeats/time-span')()
6
5
  const $ = require('tinyspawn')
7
6
  const path = require('path')
@@ -37,7 +36,7 @@ module.exports = (snippet, { tmpdir, timeout, memory, throwError = true } = {})
37
36
  const cwd = path.dirname(filepath)
38
37
  const filename = path.basename(filepath)
39
38
  duration = timeSpan()
40
- const { stdout } = await $('node', [filename, serialize(args)], {
39
+ const { stdout } = await $('node', [filename, JSON.stringify(args)], {
41
40
  cwd,
42
41
  env: {
43
42
  ...process.env,
@@ -3,7 +3,8 @@
3
3
  const SERIALIZE_ERROR = require('./serialize-error')
4
4
 
5
5
  module.exports = snippet => `
6
- const args = eval(\`(\${process.argv[2]})\`);
6
+ const args = JSON.parse(process.argv[2])
7
+
7
8
  const logging = Object.create(null)
8
9
 
9
10
  for (const method of ['log', 'info', 'debug', 'warn', 'error']) {