Skip to content

Commit 9303928

Browse files
committedNov 25, 2014
Handle dependencies at sprockets processor layer
1 parent 2eee7f2 commit 9303928

File tree

4 files changed

+5
-14
lines changed

4 files changed

+5
-14
lines changed
 

‎lib/opal/builder.rb

-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ def process_require(filename, options)
6666
path = path_reader.expand(filename).to_s
6767
asset = find_asset filename
6868

69-
path_reader.depend_on filename
70-
7169
process_requires asset, path, options
7270

7371
@assets << asset

‎lib/opal/path_reader.rb

-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ def stat(path)
1818
nil
1919
end
2020

21-
def depend_on(path)
22-
nil
23-
end
24-
2521
def expand(path)
2622
file_finder.find(path)
2723
end

‎lib/opal/sprockets/path_reader.rb

-6
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@ def initialize(env, context)
99

1010
def read path
1111
if path.end_with? '.js'
12-
context.depend_on_asset(path)
1312
env[path].to_s
1413
else
15-
context.depend_on(path)
1614
File.read(expand(path))
1715
end
1816
rescue ::Sprockets::FileNotFound
1917
nil
2018
end
2119

22-
def depend_on(path)
23-
context.depend_on path
24-
end
25-
2620
def stat path
2721
File.stat expand(path)
2822
rescue Errno::ENOENT

‎lib/opal/sprockets/processor.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,16 @@ def evaluate(context, locals, &block)
6868
return Opal.compile data unless context.is_a? ::Sprockets::Context
6969

7070
path = context.logical_path
71-
prerequired = []
7271

7372
builder = self.class.new_builder(context)
74-
builder.build_require(path, :prerequired => prerequired)
73+
builder.build_require(path)
7574

7675
result = builder.to_s + "\nOpal.require(#{path.inspect});"
7776

77+
builder.processed.each do |dependency_path|
78+
context.depend_on dependency_path
79+
end
80+
7881
if self.class.source_map_enabled
7982
register_source_map(context.logical_path, builder.source_map.to_s)
8083
"#{result}\n//# sourceMappingURL=#{File.basename(context.logical_path)}.map\n"

0 commit comments

Comments
 (0)
Please sign in to comment.