Skip to content

Commit

Permalink
fix: scripts cannot be resolved when used as module
Browse files Browse the repository at this point in the history
  • Loading branch information
stfsy committed Dec 4, 2023
1 parent cb6b5e3 commit a262bf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { readFileSync } = require('fs')
const fn = readFileSync('./lib/script-handler-runner.js', 'utf-8')
const fn = readFileSync(require.resolve('./script-handler-runner.js'), 'utf-8')
const { createTransferableReference, copyValueFromReference, callFunctionWithArguments, runWithIsolatedContext } = require('./isolate/isolate.js')
const { compileAndRunScript } = require('./isolate/script-runner.js')
const { wrapScript } = require('./isolate/wrap-user-provided-adapter-fn-script.js')
Expand Down
9 changes: 4 additions & 5 deletions lib/isolate/helper-scripts.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
'use strict'

const { readFileSync } = require('fs')
const { resolve } = require('path')

const objectHelpersPath = resolve('./lib/isolate/scripts/is-object-helpers.js')
const objectHelpersPath = require.resolve('./scripts/is-object-helpers.js')
const isObjectHelpers = readFileSync(objectHelpersPath, 'utf-8')

const base64Path = resolve('./lib/isolate/scripts/base64.js')
const base64Path = require.resolve('./scripts/base64.js')
const base64 = readFileSync(base64Path, 'utf-8')

const freezeGlobalsPath = resolve('./lib/isolate/built-ins/freeze-globals.js')
const freezeGlobalsPath = require.resolve('./built-ins/freeze-globals.js')
const freezeGlobals = readFileSync(freezeGlobalsPath, 'utf-8')

const overrideGlobalsPath = resolve('./lib/isolate/scripts/override-globals.js')
const overrideGlobalsPath = require.resolve('./scripts/override-globals.js')
const overrideGlobals = readFileSync(overrideGlobalsPath, 'utf-8')

const { compileAndRunScript } = require('./script-runner.js')
Expand Down

0 comments on commit a262bf2

Please sign in to comment.