Skip to content

Fix JSXTransformer when therubyracer is used by execjs #16

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

Merged
merged 2 commits into from
Dec 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ end
appraise "rails-4.0" do
gem 'rails', '~> 4.0'
end

appraise "rails-4.0-with-therubyracer" do
gem 'rails', '~> 4.0'
gem 'therubyracer', '0.12.0', :platform => :mri
end
6 changes: 5 additions & 1 deletion lib/react/jsx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ module React
module JSX
def self.context
# TODO: create React::Source::contents_for
contents = File.read(React::Source.bundled_path_for('JSXTransformer.js'))
contents =
# If execjs uses therubyracer, there is no 'global'. Make sure
# we have it so JSX script can work properly.
'var global = global || this;' +
File.read(React::Source.bundled_path_for('JSXTransformer.js'))
@context ||= ExecJS.compile(contents)
end

Expand Down
6 changes: 6 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

Rails.backtrace_cleaner.remove_silencers!

# Remove cached files
Rails.root.join('tmp').tap do |tmp|
tmp.rmtree
tmp.mkpath
end

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

Expand Down