Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for generating source map #6

Closed
jirutka opened this issue Apr 14, 2019 · 2 comments · Fixed by #10
Closed

Add support for generating source map #6

jirutka opened this issue Apr 14, 2019 · 2 comments · Fixed by #10

Comments

@jirutka
Copy link

jirutka commented Apr 14, 2019

The Ruby version of Opal supports source maps:

require 'opal'

builder = Opal::Builder.new
builder.append_paths 'lib'
builder.build 'path/to/entrypoint'

code = builder.to_s
source_map = builder.source_map

opal-node-compiler does not expose source map and accessing it directly results in error:

const { Builder: OpalBuilder } = require('opal-compiler')

const builder = OpalBuilder.create()
builder.appendPaths('lib')

const code = builder.build(modulePath).toString()
const sourceMap = builder.$source_map()
SourceMap: uninitialized constant Opal::SourceMap
    at Function.$$const_missing (node_modules/opal-runtime/src/opal.js:3052:52)
    at const_missing (node_modules/opal-runtime/src/opal.js:224:32)
    at Opal.const_get_qualified (node_modules/opal-runtime/src/opal.js:271:38)
    at constructor.$$source_map (node_modules/opal-compiler/src/opal-builder.js:1988:20)
@ggrossetie
Copy link
Owner

I think we need to explicitly require the SourceMap module:

https://github.com/opal/opal/blob/cba2fea2cea7c461bf22ab30a491064113c78a78/lib/opal/builder.rb#L124

@ggrossetie
Copy link
Owner

It should be fixed in #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants