Created
February 8, 2017 19:42
-
-
Save brodock/f8862a94e3494d2cc20689b4f8bd6dfa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'therubyracer' | |
require 'commonjs' | |
webpack_path = `which webpack`.chomp | |
webpack_content = File.open(webpack_path).read.sub("#!/usr/bin/env node\n", '') | |
ctx = V8::Context.new | |
env = CommonJS::Environment.new(ctx, path: '/usr/local/lib/node_modules') | |
ctx['require'] = lambda { |this, module_id| env.require(module_id) } | |
# trying to get webpack "cli" to execute under therubyracer: | |
puts ctx.eval(webpack_content) | |
# the issue is that while I was able to inject require, it doesn find any npm module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment