Skip to content

Commit

Permalink
Merge 31c11df into 2c8c006
Browse files Browse the repository at this point in the history
  • Loading branch information
zarakay committed Aug 18, 2016
2 parents 2c8c006 + 31c11df commit ae8d50f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/typescript/rails/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def compile(ts_path, source, context=nil, *options)
end
s = replace_relative_references(ts_path, source)
begin
::TypeScript::Node.compile(s, *default_options, *options)
extension = File.extname(ts_path)
::TypeScript::Node.compile(s, extension, *default_options, *options)
rescue Exception => e
raise "Typescript error in file '#{ts_path}':\n#{e.message}"
end
Expand Down
3 changes: 2 additions & 1 deletion lib/typescript/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class Typescript::Rails::Railtie < ::Rails::Railtie

if Sprockets.respond_to?(:register_engine)
Sprockets.register_engine '.ts', Typescript::Rails::Template, silence_deprecation: true
Sprockets.register_engine '.tsx', Typescript::Rails::Template, silence_deprecation: true
end

if Sprockets.respond_to?(:register_transformer)
Sprockets.register_mime_type 'text/typescript', extensions: ['.ts']
Sprockets.register_mime_type 'text/typescript', extensions: ['.ts', '.tsx']
Sprockets.register_transformer 'text/typescript', 'application/javascript', Typescript::Rails::Transformer
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/typescript/rails/template_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ def call(template)

ActiveSupport.on_load(:action_view) do
ActionView::Template.register_template_handler :ts, Typescript::Rails::TemplateHandler
ActionView::Template.register_template_handler :tsx, Typescript::Rails::TemplateHandler
end

0 comments on commit ae8d50f

Please sign in to comment.