Skip to content

Commit

Permalink
Use Opal::Compiler as main compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 23, 2013
1 parent 3c83fd9 commit bf5c4af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lib/opal/sprockets/erb.rb
@@ -1,5 +1,5 @@
require 'opal'
require 'opal/parser'
require 'opal/compiler'
require 'sprockets'

module Opal
Expand All @@ -16,11 +16,10 @@ def initialize_engine
end

def prepare
# ...
end

def evaluate(scope, locals, &block)
Opal::ERB.parse data, scope.logical_path.sub(/^templates\//, '')
Opal::ERB.compile data, scope.logical_path.sub(/^templates\//, '')
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/opal/sprockets/processor.rb
Expand Up @@ -69,16 +69,16 @@ def evaluate(context, locals, &block)
:source_file => context.pathname.to_s
}

parser = Opal::RequireParser.new
result = parser.parse data, options
compiler = Opal::DependencyCompiler.new
result = compiler.compile data, options

parser.requires.each do |r|
compiler.requires.each do |r|
path = find_opal_require context.environment, r
context.require_asset path
end

if options[:source_map_enabled]
$OPAL_SOURCE_MAPS[context.pathname] = Opal::SourceMap.new(parser.fragments, "file://#{context.pathname.to_s}").to_s
$OPAL_SOURCE_MAPS[context.pathname] = Opal::SourceMap.new(compiler.fragments, "file://#{context.pathname.to_s}").to_s
"#{result}\n//@ sourceMappingURL=/__opal_source_maps__/#{context.logical_path}.js.map\n"
else
result
Expand Down

0 comments on commit bf5c4af

Please sign in to comment.