Skip to content

Use sourcemap inside of code executed by eval() #284

Open

Description

@holtwick

Currently, I use esbuild to compile code and dynamically transpile and execute user JS using eval(), like this:

try {
    if (code) {
      code = `(function(exports) {
        ${code}
        return exports;
      })({})`
      mod = eval(code)
    }
  } catch (err) {
    console.error('Exception:', err)
  }

The code contains a sourcemap.

Is there a way to use node-source-map-support to print the exception's stack using the sourcemap info?

Activity

  1. zaydek commented on Mar 8, 2021

    @zaydek

    @holtwick I just ran into this myself. I’m not sure this is a supported use-case. Anyway, I found this article you wrote: https://dev.to/holtwick/esbuild-is-fast-2cjj which helped me a lot personally. For now I’m writing a hidden file to disk in the same root directory so that requires can resolve as expected and then unlinking the same you do when processing is done.

    If you want to exchange notes, feel free to HMU https://twitter.com/username_ZAYDEK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions