sprockets 3.0.0.beta.6 → 3.0.0.beta.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +171 -100
- data/lib/rake/sprocketstask.rb +2 -2
- data/lib/sprockets.rb +69 -63
- data/lib/sprockets/asset.rb +2 -61
- data/lib/sprockets/autoload_processor.rb +48 -0
- data/lib/sprockets/base.rb +4 -6
- data/lib/sprockets/bower.rb +8 -5
- data/lib/sprockets/bundle.rb +9 -13
- data/lib/sprockets/cache.rb +19 -14
- data/lib/sprockets/cache/file_store.rb +2 -1
- data/lib/sprockets/cached_environment.rb +15 -68
- data/lib/sprockets/closure_compressor.rb +17 -4
- data/lib/sprockets/coffee_script_processor.rb +26 -0
- data/lib/sprockets/coffee_script_template.rb +3 -20
- data/lib/sprockets/compressing.rb +10 -4
- data/lib/sprockets/configuration.rb +21 -37
- data/lib/sprockets/context.rb +37 -67
- data/lib/sprockets/dependencies.rb +73 -0
- data/lib/sprockets/digest_utils.rb +8 -2
- data/lib/sprockets/directive_processor.rb +122 -165
- data/lib/sprockets/eco_processor.rb +32 -0
- data/lib/sprockets/eco_template.rb +3 -26
- data/lib/sprockets/ejs_processor.rb +31 -0
- data/lib/sprockets/ejs_template.rb +3 -25
- data/lib/sprockets/encoding_utils.rb +9 -21
- data/lib/sprockets/engines.rb +25 -27
- data/lib/sprockets/environment.rb +9 -1
- data/lib/sprockets/erb_processor.rb +30 -0
- data/lib/sprockets/erb_template.rb +3 -20
- data/lib/sprockets/file_reader.rb +15 -0
- data/lib/sprockets/http_utils.rb +2 -0
- data/lib/sprockets/jst_processor.rb +9 -2
- data/lib/sprockets/legacy.rb +212 -3
- data/lib/sprockets/legacy_tilt_processor.rb +1 -1
- data/lib/sprockets/loader.rb +95 -89
- data/lib/sprockets/manifest.rb +23 -59
- data/lib/sprockets/mime.rb +28 -41
- data/lib/sprockets/path_dependency_utils.rb +76 -0
- data/lib/sprockets/path_utils.rb +21 -1
- data/lib/sprockets/paths.rb +23 -8
- data/lib/sprockets/processing.rb +102 -91
- data/lib/sprockets/processor_utils.rb +97 -0
- data/lib/sprockets/resolve.rb +110 -97
- data/lib/sprockets/sass_cache_store.rb +2 -2
- data/lib/sprockets/sass_compressor.rb +17 -4
- data/lib/sprockets/sass_functions.rb +2 -2
- data/lib/sprockets/sass_importer.rb +2 -2
- data/lib/sprockets/sass_processor.rb +305 -0
- data/lib/sprockets/sass_template.rb +4 -286
- data/lib/sprockets/server.rb +1 -13
- data/lib/sprockets/transformers.rb +62 -25
- data/lib/sprockets/uglifier_compressor.rb +17 -4
- data/lib/sprockets/uri_utils.rb +190 -0
- data/lib/sprockets/utils.rb +87 -6
- data/lib/sprockets/version.rb +1 -1
- data/lib/sprockets/yui_compressor.rb +17 -4
- metadata +14 -5
- data/lib/sprockets/asset_uri.rb +0 -80
- data/lib/sprockets/lazy_processor.rb +0 -15
data/lib/rake/sprocketstask.rb
CHANGED
@@ -127,9 +127,9 @@ module Rake
|
|
127
127
|
task :clobber => ["clobber_#{name}"]
|
128
128
|
|
129
129
|
desc name == :assets ? "Clean old assets" : "Clean old #{name} assets"
|
130
|
-
task "clean_#{name}"
|
130
|
+
task "clean_#{name}" do
|
131
131
|
with_logger do
|
132
|
-
manifest.clean(
|
132
|
+
manifest.clean(keep)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
data/lib/sprockets.rb
CHANGED
@@ -10,23 +10,13 @@ module Sprockets
|
|
10
10
|
|
11
11
|
# Processing
|
12
12
|
autoload :Bundle, 'sprockets/bundle'
|
13
|
-
autoload :ClosureCompressor, 'sprockets/closure_compressor'
|
14
13
|
autoload :CoffeeScriptTemplate, 'sprockets/coffee_script_template'
|
15
14
|
autoload :Context, 'sprockets/context'
|
16
15
|
autoload :DirectiveProcessor, 'sprockets/directive_processor'
|
17
|
-
autoload :
|
18
|
-
autoload :EjsTemplate, 'sprockets/ejs_template'
|
19
|
-
autoload :ERBTemplate, 'sprockets/erb_template'
|
20
|
-
autoload :JstProcessor, 'sprockets/jst_processor'
|
21
|
-
autoload :SassCompressor, 'sprockets/sass_compressor'
|
22
|
-
autoload :SassTemplate, 'sprockets/sass_template'
|
23
|
-
autoload :ScssTemplate, 'sprockets/sass_template'
|
24
|
-
autoload :UglifierCompressor, 'sprockets/uglifier_compressor'
|
25
|
-
autoload :YUICompressor, 'sprockets/yui_compressor'
|
16
|
+
autoload :FileReader, 'sprockets/file_reader'
|
26
17
|
|
27
18
|
# Internal utilities
|
28
19
|
autoload :ArgumentError, 'sprockets/errors'
|
29
|
-
autoload :AssetURI, 'sprockets/asset_uri'
|
30
20
|
autoload :Cache, 'sprockets/cache'
|
31
21
|
autoload :ContentTypeMismatch, 'sprockets/errors'
|
32
22
|
autoload :DigestUtils, 'sprockets/digest_utils'
|
@@ -34,48 +24,52 @@ module Sprockets
|
|
34
24
|
autoload :Error, 'sprockets/errors'
|
35
25
|
autoload :FileNotFound, 'sprockets/errors'
|
36
26
|
autoload :HTTPUtils, 'sprockets/http_utils'
|
37
|
-
autoload :LazyProcessor, 'sprockets/lazy_processor'
|
38
27
|
autoload :PathUtils, 'sprockets/path_utils'
|
39
28
|
autoload :Utils, 'sprockets/utils'
|
40
29
|
|
30
|
+
require 'sprockets/processor_utils'
|
31
|
+
extend ProcessorUtils
|
32
|
+
|
41
33
|
# Extend Sprockets module to provide global registry
|
42
34
|
require 'sprockets/configuration'
|
43
35
|
require 'sprockets/context'
|
36
|
+
require 'digest/sha2'
|
44
37
|
extend Configuration
|
45
38
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
39
|
+
self.config = {
|
40
|
+
bundle_processors: Hash.new { |h, k| [].freeze }.freeze,
|
41
|
+
bundle_reducers: Hash.new { |h, k| {}.freeze }.freeze,
|
42
|
+
compressors: Hash.new { |h, k| {}.freeze }.freeze,
|
43
|
+
dependencies: Set.new.freeze,
|
44
|
+
dependency_resolvers: {}.freeze,
|
45
|
+
digest_class: Digest::SHA256,
|
46
|
+
engine_mime_types: {}.freeze,
|
47
|
+
engines: {}.freeze,
|
48
|
+
mime_exts: {}.freeze,
|
49
|
+
mime_types: {}.freeze,
|
50
|
+
paths: [].freeze,
|
51
|
+
postprocessors: Hash.new { |h, k| [].freeze }.freeze,
|
52
|
+
preprocessors: Hash.new { |h, k| [].freeze }.freeze,
|
53
|
+
registered_transformers: Hash.new { |h, k| {}.freeze }.freeze,
|
54
|
+
root: File.expand_path('..', __FILE__).freeze,
|
55
|
+
transformers: Hash.new { |h, k| {}.freeze }.freeze,
|
56
|
+
version: ""
|
57
|
+
}.freeze
|
58
|
+
|
59
|
+
@context_class = Context
|
66
60
|
|
67
61
|
require 'logger'
|
68
62
|
@logger = Logger.new($stderr)
|
69
63
|
@logger.level = Logger::FATAL
|
70
64
|
|
71
65
|
# Common asset text types
|
72
|
-
register_mime_type 'application/javascript', extensions: ['.js'], charset:
|
73
|
-
register_mime_type 'application/json', extensions: ['.json'], charset:
|
66
|
+
register_mime_type 'application/javascript', extensions: ['.js'], charset: :unicode
|
67
|
+
register_mime_type 'application/json', extensions: ['.json'], charset: :unicode
|
74
68
|
register_mime_type 'application/xml', extensions: ['.xml']
|
75
|
-
register_mime_type 'text/css', extensions: ['.css'], charset:
|
76
|
-
register_mime_type 'text/html', extensions: ['.html', '.htm'], charset:
|
69
|
+
register_mime_type 'text/css', extensions: ['.css'], charset: :css
|
70
|
+
register_mime_type 'text/html', extensions: ['.html', '.htm'], charset: :html
|
77
71
|
register_mime_type 'text/plain', extensions: ['.txt', '.text']
|
78
|
-
register_mime_type 'text/yaml', extensions: ['.yml', '.yaml'], charset:
|
72
|
+
register_mime_type 'text/yaml', extensions: ['.yml', '.yaml'], charset: :unicode
|
79
73
|
|
80
74
|
# Common image types
|
81
75
|
register_mime_type 'image/x-icon', extensions: ['.ico']
|
@@ -103,14 +97,13 @@ module Sprockets
|
|
103
97
|
register_mime_type 'application/x-font-ttf', extensions: ['.ttf']
|
104
98
|
register_mime_type 'application/font-woff', extensions: ['.woff']
|
105
99
|
|
106
|
-
# HTTP content encodings
|
107
|
-
register_encoding :deflate, EncodingUtils::DEFLATE
|
108
|
-
register_encoding :gzip, EncodingUtils::GZIP
|
109
|
-
register_encoding :base64, EncodingUtils::BASE64
|
110
|
-
|
111
100
|
require 'sprockets/directive_processor'
|
112
|
-
register_preprocessor 'text/css', DirectiveProcessor
|
113
|
-
|
101
|
+
register_preprocessor 'text/css', DirectiveProcessor.new(
|
102
|
+
comments: ["//", ["/*", "*/"]]
|
103
|
+
)
|
104
|
+
register_preprocessor 'application/javascript', DirectiveProcessor.new(
|
105
|
+
comments: ["//", ["/*", "*/"]] + ["#", ["###", "###"]]
|
106
|
+
)
|
114
107
|
|
115
108
|
require 'sprockets/bundle'
|
116
109
|
register_bundle_processor 'application/javascript', Bundle
|
@@ -120,31 +113,44 @@ module Sprockets
|
|
120
113
|
register_bundle_metadata_reducer 'application/javascript', :data, Utils.method(:concat_javascript_sources)
|
121
114
|
register_bundle_metadata_reducer '*/*', :links, :+
|
122
115
|
|
123
|
-
register_compressor 'text/css', :sass,
|
124
|
-
register_compressor 'text/css', :scss,
|
125
|
-
register_compressor 'text/css', :yui,
|
126
|
-
register_compressor 'application/javascript', :closure,
|
127
|
-
register_compressor 'application/javascript', :uglifier,
|
128
|
-
register_compressor 'application/javascript', :uglify,
|
129
|
-
register_compressor 'application/javascript', :yui,
|
116
|
+
register_compressor 'text/css', :sass, autoload_processor(:SassCompressor, 'sprockets/sass_compressor')
|
117
|
+
register_compressor 'text/css', :scss, autoload_processor(:SassCompressor, 'sprockets/sass_compressor')
|
118
|
+
register_compressor 'text/css', :yui, autoload_processor(:YUICompressor, 'sprockets/yui_compressor')
|
119
|
+
register_compressor 'application/javascript', :closure, autoload_processor(:ClosureCompressor, 'sprockets/closure_compressor')
|
120
|
+
register_compressor 'application/javascript', :uglifier, autoload_processor(:UglifierCompressor, 'sprockets/uglifier_compressor')
|
121
|
+
register_compressor 'application/javascript', :uglify, autoload_processor(:UglifierCompressor, 'sprockets/uglifier_compressor')
|
122
|
+
register_compressor 'application/javascript', :yui, autoload_processor(:YUICompressor, 'sprockets/yui_compressor')
|
130
123
|
|
131
124
|
# Mmm, CoffeeScript
|
132
|
-
|
133
|
-
register_engine '.coffee', LazyProcessor.new { CoffeeScriptTemplate }, mime_type: 'application/javascript'
|
125
|
+
register_engine '.coffee', autoload_processor(:CoffeeScriptProcessor, 'sprockets/coffee_script_processor'), mime_type: 'application/javascript'
|
134
126
|
|
135
127
|
# JST engines
|
136
|
-
|
137
|
-
|
138
|
-
register_engine '.
|
139
|
-
register_engine '.eco', LazyProcessor.new { EcoTemplate }, mime_type: 'application/javascript'
|
140
|
-
register_engine '.ejs', LazyProcessor.new { EjsTemplate }, mime_type: 'application/javascript'
|
128
|
+
register_engine '.jst', autoload_processor(:JstProcessor, 'sprockets/jst_processor'), mime_type: 'application/javascript'
|
129
|
+
register_engine '.eco', autoload_processor(:EcoProcessor, 'sprockets/eco_processor'), mime_type: 'application/javascript'
|
130
|
+
register_engine '.ejs', autoload_processor(:EjsProcessor, 'sprockets/ejs_processor'), mime_type: 'application/javascript'
|
141
131
|
|
142
132
|
# CSS engines
|
143
|
-
|
144
|
-
|
145
|
-
register_engine '.sass', LazyProcessor.new { SassTemplate }, mime_type: 'text/css'
|
146
|
-
register_engine '.scss', LazyProcessor.new { ScssTemplate }, mime_type: 'text/css'
|
133
|
+
register_engine '.sass', autoload_processor(:SassProcessor, 'sprockets/sass_processor'), mime_type: 'text/css'
|
134
|
+
register_engine '.scss', autoload_processor(:ScssProcessor, 'sprockets/sass_processor'), mime_type: 'text/css'
|
147
135
|
|
148
136
|
# Other
|
149
|
-
register_engine '.erb',
|
137
|
+
register_engine '.erb', autoload_processor(:ERBProcessor, 'sprockets/erb_processor'), mime_type: 'text/plain'
|
138
|
+
|
139
|
+
register_dependency_resolver 'environment-version' do |env|
|
140
|
+
env.version
|
141
|
+
end
|
142
|
+
register_dependency_resolver 'environment-paths' do |env|
|
143
|
+
env.paths
|
144
|
+
end
|
145
|
+
register_dependency_resolver 'file-digest' do |env, str|
|
146
|
+
env.file_digest(env.parse_file_digest_uri(str))
|
147
|
+
end
|
148
|
+
register_dependency_resolver 'processors' do |env, str|
|
149
|
+
env.resolve_processors_cache_key_uri(str)
|
150
|
+
end
|
151
|
+
|
152
|
+
depend_on 'environment-version'
|
153
|
+
depend_on 'environment-paths'
|
150
154
|
end
|
155
|
+
|
156
|
+
require 'sprockets/legacy'
|
data/lib/sprockets/asset.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
require 'base64'
|
2
1
|
require 'fileutils'
|
3
|
-
require '
|
2
|
+
require 'sprockets/digest_utils'
|
4
3
|
|
5
4
|
module Sprockets
|
6
5
|
class Asset
|
@@ -49,13 +48,6 @@ module Sprockets
|
|
49
48
|
# Public: Returns String path of asset.
|
50
49
|
attr_reader :filename
|
51
50
|
|
52
|
-
# Deprecated: Use #filename instead.
|
53
|
-
#
|
54
|
-
# Returns Pathname.
|
55
|
-
def pathname
|
56
|
-
@pathname ||= Pathname.new(filename)
|
57
|
-
end
|
58
|
-
|
59
51
|
# Internal: Unique asset object ID.
|
60
52
|
#
|
61
53
|
# Returns a String.
|
@@ -97,36 +89,6 @@ module Sprockets
|
|
97
89
|
metadata[:included]
|
98
90
|
end
|
99
91
|
|
100
|
-
# Deprecated: Expand asset into an `Array` of parts.
|
101
|
-
#
|
102
|
-
# Appending all of an assets body parts together should give you
|
103
|
-
# the asset's contents as a whole.
|
104
|
-
#
|
105
|
-
# This allows you to link to individual files for debugging
|
106
|
-
# purposes.
|
107
|
-
#
|
108
|
-
# Use Asset#included instead. Keeping a full copy of the bundle's processed
|
109
|
-
# assets in memory (and in cache) is expensive and redundant. The common use
|
110
|
-
# case is to relink to the assets anyway.
|
111
|
-
#
|
112
|
-
# Returns Array of Assets.
|
113
|
-
def to_a
|
114
|
-
if metadata[:included]
|
115
|
-
metadata[:included].map { |uri| @environment.load(uri) }
|
116
|
-
else
|
117
|
-
[self]
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# Deprecated: Get all required Assets.
|
122
|
-
#
|
123
|
-
# See Asset#to_a
|
124
|
-
#
|
125
|
-
# Returns Array of Assets.
|
126
|
-
def dependencies
|
127
|
-
to_a.reject { |a| a.filename.eql?(self.filename) }
|
128
|
-
end
|
129
|
-
|
130
92
|
# Public: Return `String` of concatenated source.
|
131
93
|
#
|
132
94
|
# Returns String.
|
@@ -146,15 +108,6 @@ module Sprockets
|
|
146
108
|
source
|
147
109
|
end
|
148
110
|
|
149
|
-
# Public: HTTP encoding for Asset, "deflate", "gzip", etc.
|
150
|
-
#
|
151
|
-
# Note: This is not the Ruby Encoding of the source. See Asset#charset.
|
152
|
-
#
|
153
|
-
# Returns a String or nil if encoding is "identity".
|
154
|
-
def encoding
|
155
|
-
metadata[:encoding]
|
156
|
-
end
|
157
|
-
|
158
111
|
# Public: Get charset of source.
|
159
112
|
#
|
160
113
|
# Returns a String charset name or nil if binary.
|
@@ -168,15 +121,6 @@ module Sprockets
|
|
168
121
|
end
|
169
122
|
alias_method :bytesize, :length
|
170
123
|
|
171
|
-
# Deprecated: Returns Time of the last time the source was modified.
|
172
|
-
#
|
173
|
-
# Time resolution is normalized to the nearest second.
|
174
|
-
#
|
175
|
-
# Returns Time.
|
176
|
-
def mtime
|
177
|
-
Time.at(@mtime)
|
178
|
-
end
|
179
|
-
|
180
124
|
# Public: Returns String hexdigest of source.
|
181
125
|
def hexdigest
|
182
126
|
DigestUtils.pack_hexdigest(metadata[:digest])
|
@@ -231,10 +175,7 @@ module Sprockets
|
|
231
175
|
#
|
232
176
|
# Returns String.
|
233
177
|
def inspect
|
234
|
-
"#<#{self.class}:#{
|
235
|
-
"filename=#{filename.inspect}, " +
|
236
|
-
"digest=#{digest.inspect}" +
|
237
|
-
">"
|
178
|
+
"#<#{self.class}:#{object_id.to_s(16)} #{uri.inspect}>"
|
238
179
|
end
|
239
180
|
|
240
181
|
# Public: Implements Object#hash so Assets can be used as a Hash key or
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Sprockets
|
2
|
+
# Internal: Used for lazy loading processors.
|
3
|
+
#
|
4
|
+
# Libraries should not use lazily loaded processors. They are only needed
|
5
|
+
# internally by Sprockets since it has optionally dependencies such as
|
6
|
+
# CoffeeScript that may not be available in the gem environment.
|
7
|
+
class AutoloadProcessor
|
8
|
+
# Initialize AutoloadProcessor wrapper
|
9
|
+
#
|
10
|
+
# See ProcessorUtils.autoload_processor for constructor method.
|
11
|
+
#
|
12
|
+
# mod - Parent Module of processor class/module
|
13
|
+
# name - Symbol name of processor class/module
|
14
|
+
def initialize(mod, name)
|
15
|
+
@mod = mod
|
16
|
+
@name = name.to_sym
|
17
|
+
end
|
18
|
+
|
19
|
+
# Full name of module.
|
20
|
+
#
|
21
|
+
# Returns String.
|
22
|
+
def name
|
23
|
+
"#{@mod}::#{@name}"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Check if target constant is already loaded.
|
27
|
+
#
|
28
|
+
# Returns Boolean.
|
29
|
+
def const_loaded?
|
30
|
+
@mod.autoload?(@name)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Delegate to processor#cache_key
|
34
|
+
def cache_key
|
35
|
+
load_processor.cache_key if load_processor.respond_to?(:cache_key)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Delegate to processor#call
|
39
|
+
def call(*args)
|
40
|
+
load_processor.call(*args)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def load_processor
|
45
|
+
@processor ||= @mod.const_get(@name)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/sprockets/base.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
require 'sprockets/asset_uri'
|
2
1
|
require 'sprockets/asset'
|
3
2
|
require 'sprockets/bower'
|
4
3
|
require 'sprockets/cache'
|
5
4
|
require 'sprockets/configuration'
|
6
5
|
require 'sprockets/digest_utils'
|
7
6
|
require 'sprockets/errors'
|
8
|
-
require 'sprockets/http_utils'
|
9
|
-
require 'sprockets/legacy'
|
10
7
|
require 'sprockets/loader'
|
11
8
|
require 'sprockets/path_digest_utils'
|
9
|
+
require 'sprockets/path_dependency_utils'
|
12
10
|
require 'sprockets/path_utils'
|
13
11
|
require 'sprockets/resolve'
|
14
12
|
require 'sprockets/server'
|
@@ -16,12 +14,11 @@ require 'sprockets/server'
|
|
16
14
|
module Sprockets
|
17
15
|
# `Base` class for `Environment` and `Cached`.
|
18
16
|
class Base
|
19
|
-
include
|
17
|
+
include PathUtils, PathDependencyUtils, PathDigestUtils, DigestUtils
|
20
18
|
include Configuration
|
21
19
|
include Server
|
22
20
|
include Resolve, Loader
|
23
21
|
include Bower
|
24
|
-
include Legacy
|
25
22
|
|
26
23
|
# Get persistent cache store
|
27
24
|
attr_reader :cache
|
@@ -61,7 +58,8 @@ module Sprockets
|
|
61
58
|
|
62
59
|
# Find asset by logical path or expanded path.
|
63
60
|
def find_asset(path, options = {})
|
64
|
-
|
61
|
+
uri, _ = resolve(path, options.merge(compat: false))
|
62
|
+
if uri
|
65
63
|
load(uri)
|
66
64
|
end
|
67
65
|
end
|
data/lib/sprockets/bower.rb
CHANGED
@@ -12,9 +12,9 @@ module Sprockets
|
|
12
12
|
# load_path - String environment path
|
13
13
|
# logical_path - String path relative to base
|
14
14
|
#
|
15
|
-
# Returns
|
16
|
-
def resolve_alternates(load_path, logical_path
|
17
|
-
super
|
15
|
+
# Returns candiate filenames.
|
16
|
+
def resolve_alternates(load_path, logical_path)
|
17
|
+
candidates, deps = super
|
18
18
|
|
19
19
|
# bower.json can only be nested one level deep
|
20
20
|
if !logical_path.index('/')
|
@@ -26,12 +26,15 @@ module Sprockets
|
|
26
26
|
filename = filenames.detect { |fn| self.file?(fn) }
|
27
27
|
|
28
28
|
if filename
|
29
|
-
|
29
|
+
deps << build_file_digest_uri(filename)
|
30
|
+
read_bower_main(dirname, filename) do |path|
|
31
|
+
candidates << path
|
32
|
+
end
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
34
|
-
|
37
|
+
return candidates, deps
|
35
38
|
end
|
36
39
|
|
37
40
|
# Internal: Read bower.json's main directive.
|
data/lib/sprockets/bundle.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'set'
|
2
|
+
require 'sprockets/utils'
|
2
3
|
|
3
4
|
module Sprockets
|
4
5
|
# Internal: Bundle processor takes a single file asset and prepends all the
|
@@ -15,25 +16,20 @@ module Sprockets
|
|
15
16
|
env = input[:environment]
|
16
17
|
type = input[:content_type]
|
17
18
|
|
18
|
-
|
19
|
-
processed_uri = AssetURI.build(input[:filename], type: type, skip_bundle: true)
|
19
|
+
processed_uri = env.build_asset_uri(input[:filename], type: type, skip_bundle: true)
|
20
20
|
|
21
|
-
|
22
|
-
h[uri] = env.load(uri)
|
23
|
-
end
|
24
|
-
|
25
|
-
find_required = proc { |uri| cache[uri].metadata[:required] }
|
21
|
+
find_required = proc { |uri| env.load(uri).metadata[:required] }
|
26
22
|
required = Utils.dfs(processed_uri, &find_required)
|
27
|
-
stubbed = Utils.dfs(
|
23
|
+
stubbed = Utils.dfs(env.load(processed_uri).metadata[:stubbed], &find_required)
|
28
24
|
required.subtract(stubbed)
|
29
|
-
assets = required.map { |uri|
|
25
|
+
assets = required.map { |uri| env.load(uri) }
|
30
26
|
|
31
|
-
|
27
|
+
dependencies = Set.new(input[:metadata][:dependencies])
|
32
28
|
(required + stubbed).each do |uri|
|
33
|
-
|
29
|
+
dependencies.merge(env.load(uri).metadata[:dependencies])
|
34
30
|
end
|
35
31
|
|
36
|
-
env.process_bundle_reducers(assets, env.
|
32
|
+
env.process_bundle_reducers(assets, env.load_bundle_reducers(type)).merge(dependencies: dependencies, included: assets.map(&:uri))
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|