Skip to content

Instantly share code, notes, and snippets.

@hmdne
hmdne / tree_shake.rb
Last active November 21, 2019 03:46 — forked from jgaskins/tree_shake.rb
Tree-shaking for compiled output from the Opal compiler
#!/usr/bin/env ruby
require 'set'
def get_stubs code
code
.scan(/\.add_stubs\(.*?\)/)
.map { |call| call.scan(/['"]\$(#{$method_re})['"]/) }
.flatten
.to_set
end