Skip to content

Instantly share code, notes, and snippets.

@joseph-montanez
Created February 22, 2017 17:10
Show Gist options
  • Save joseph-montanez/d0a8df95f6632c92deb2e643024833d1 to your computer and use it in GitHub Desktop.
Save joseph-montanez/d0a8df95f6632c92deb2e643024833d1 to your computer and use it in GitHub Desktop.
Unable to export Opal code as a node module
require 'native'
$$[:exports] = {
:pageLoaded => 123
}
var mainPage = require('./main-page.rb.js');
console.log(mainPage.pageLoaded); # Output: undefined
console.log(mainPage.Opal.gvars.global.native.exports.pageLoaded); # Output: 123
opal -E -c main-page.rb > main-page.rb.js
node main.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment