sprockets 4.2.2 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +13 -13
- data/lib/sprockets/asset.rb +1 -1
- data/lib/sprockets/bower.rb +1 -1
- data/lib/sprockets/compressing.rb +1 -1
- data/lib/sprockets/encoding_utils.rb +3 -1
- data/lib/sprockets/loader.rb +1 -1
- data/lib/sprockets/manifest.rb +10 -10
- data/lib/sprockets/npm.rb +1 -1
- data/lib/sprockets/path_dependency_utils.rb +1 -1
- data/lib/sprockets/utils/gzip.rb +11 -8
- data/lib/sprockets/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ed3bbcd2acf1e69863e6ffbf1906f4c21c9818de0125fab07af7233adb4b896
|
|
4
|
+
data.tar.gz: bda5afe84773146933b12ea7c9789671231afa86536f12d82dd2e6df0a951bab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6386915d85ef699768c8f59762cbb544e9a06840ccb1780df28ba6313aeb7e54e095c7d0a5567eb874c9e1613d1b01d6745cff747fcfdb53ba4856b99531df1
|
|
7
|
+
data.tar.gz: e41508e003694d4500b699dfeaa8254c462d2859a477c46e63c003cf928a01586603f4fa01adf80c9a403b0fb93dfe7f0d97bf1e118ffda6201084bca541a47a
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md
|
|
4
4
|
|
|
5
|
+
## 4.3.0
|
|
6
|
+
|
|
7
|
+
- Fixed compatibility with `json` 3+.
|
|
8
|
+
- Do not set variable `GZip#mtime` but do always set `File#mtime`. [#821](https://github.com/rails/sprockets/pull/821)
|
|
9
|
+
|
|
5
10
|
## 4.2.2
|
|
6
11
|
|
|
7
12
|
- Added missing dependency on `logger`. [#813](https://github.com/rails/sprockets/pull/813)
|
data/README.md
CHANGED
|
@@ -44,7 +44,7 @@ If you want to work on Sprockets or better understand how it works read [How Spr
|
|
|
44
44
|
|
|
45
45
|
You can interact with Sprockets primarily through directives and file extensions. This section covers how to use each of these things, and the defaults that ship with Sprockets.
|
|
46
46
|
|
|
47
|
-
Since you are likely using Sprockets through another framework (such as the [
|
|
47
|
+
Since you are likely using Sprockets through another framework (such as the [Rails asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html)), there will be configuration options you can toggle that will change behavior such as what directories or files get compiled. For that documentation you should see your framework's documentation.
|
|
48
48
|
|
|
49
49
|
#### Accessing Assets
|
|
50
50
|
|
|
@@ -119,7 +119,7 @@ Here is a list of the available directives:
|
|
|
119
119
|
- [`link_directory`](#link_directory) - Make target directory compile and be publicly available without adding contents to current
|
|
120
120
|
- [`link_tree`](#link_tree) - Make target tree compile and be publicly available without adding contents to current
|
|
121
121
|
- [`depend_on`](#depend_on) - Recompile current file if target has changed
|
|
122
|
-
- [`depend_on_directory`](#depend_on_directory) - Recompile current file if any files in target directory
|
|
122
|
+
- [`depend_on_directory`](#depend_on_directory) - Recompile current file if any files in target directory have changed
|
|
123
123
|
- [`stub`](#stub) - Ignore target file
|
|
124
124
|
|
|
125
125
|
You can see what each of these does below.
|
|
@@ -150,7 +150,7 @@ When "asking" for a compiled file, you always ask for the extension you want. Fo
|
|
|
150
150
|
asset_path("application.css")
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
Sprockets understands that `application.scss.erb` will compile down to
|
|
153
|
+
Sprockets understands that `application.scss.erb` will compile down to an `application.css`. Ask for what you need, not what you have.
|
|
154
154
|
|
|
155
155
|
If this isn't working like you expect, make sure you didn't typo an extension, and make sure the file is on a "load path" (see framework docs for adding new load paths).
|
|
156
156
|
|
|
@@ -174,7 +174,7 @@ beta.js
|
|
|
174
174
|
jquery.js
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
Then `alpha.js` will be loaded before either of the other two. This can be a problem if `alpha.js` uses jquery. For this reason it is not
|
|
177
|
+
Then `alpha.js` will be loaded before either of the other two. This can be a problem if `alpha.js` uses jquery. For this reason it is not recommended to use `require_directory` with files that are ordering dependent. You can either require individual files manually:
|
|
178
178
|
|
|
179
179
|
```js
|
|
180
180
|
//= require jquery
|
|
@@ -253,7 +253,7 @@ Directives take a path or a path to a file. Paths for directive can be relative
|
|
|
253
253
|
//= require ../foo.js
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
This would load
|
|
256
|
+
This would load a file named `foo.js` from one directory up. However this isn't required if `foo.js` is on one of Sprocket's load paths. You can simply use
|
|
257
257
|
|
|
258
258
|
```js
|
|
259
259
|
//= require foo.js
|
|
@@ -396,7 +396,7 @@ This would find a manifest file at `my_engine/app/assets/config/my_engine_manife
|
|
|
396
396
|
|
|
397
397
|
Files in subdirectories will not be linked (Compare to [link_tree](#link_tree)).
|
|
398
398
|
|
|
399
|
-
The *path* argument to `link_directory` is _not_ a logical path (it does not use the asset load paths), but is a path relative to the file the `link_directory` directive is found in, and can use `..` to
|
|
399
|
+
The *path* argument to `link_directory` is _not_ a logical path (it does not use the asset load paths), but is a path relative to the file the `link_directory` directive is found in, and can use `..` to reference parent directories. For instance, you might want:
|
|
400
400
|
|
|
401
401
|
```js
|
|
402
402
|
//= link_directory ../stylesheets
|
|
@@ -426,7 +426,7 @@ Example:
|
|
|
426
426
|
//= link_tree ./path/to/folder
|
|
427
427
|
```
|
|
428
428
|
|
|
429
|
-
Like `link_directory`, the argument is path relative to the current file, it is *not* a 'logical path'
|
|
429
|
+
Like `link_directory`, the argument is a path relative to the current file, it is *not* a 'logical path' resolved against load paths.
|
|
430
430
|
|
|
431
431
|
|
|
432
432
|
As with `link_directory`, you can also specify a second argument -- separated by a space -- so any extra files not matching the content-type specified will be ignored:
|
|
@@ -469,7 +469,7 @@ asset's cache in response to a change in multiple files in a single directory.
|
|
|
469
469
|
|
|
470
470
|
All paths are relative to your declaration and must begin with `./`
|
|
471
471
|
|
|
472
|
-
Also,
|
|
472
|
+
Also, you must include these directories in your [load path](guides/building_an_asset_processing_framework.md#the-load-path).
|
|
473
473
|
|
|
474
474
|
**Example:**
|
|
475
475
|
|
|
@@ -488,8 +488,8 @@ B
|
|
|
488
488
|
```
|
|
489
489
|
// ./file.js.erb
|
|
490
490
|
//= depend_on_directory ./data
|
|
491
|
-
var a = '
|
|
492
|
-
var b = '
|
|
491
|
+
var a = '<%= File.read("data/a.data") %>'
|
|
492
|
+
var b = '<%= File.read("data/b.data") %>'
|
|
493
493
|
```
|
|
494
494
|
|
|
495
495
|
Would produce:
|
|
@@ -514,7 +514,7 @@ Sprockets provides an ERB engine for preprocessing assets using
|
|
|
514
514
|
embedded Ruby code. Append `.erb` to a CSS or JavaScript asset's
|
|
515
515
|
filename to enable the ERB engine.
|
|
516
516
|
|
|
517
|
-
For example if you have an `app/
|
|
517
|
+
For example if you have an `app/assets/javascripts/app_name.js.erb`
|
|
518
518
|
you could have this in the template
|
|
519
519
|
|
|
520
520
|
```js
|
|
@@ -559,7 +559,7 @@ Sprockets supports both Sass syntaxes. For the original
|
|
|
559
559
|
whitespace-sensitive syntax, use the extension `.sass`. For the
|
|
560
560
|
new SCSS syntax, use the extension `.scss`.
|
|
561
561
|
|
|
562
|
-
In Rails if you have `app/
|
|
562
|
+
In Rails if you have `app/assets/stylesheets/foo.scss` it can
|
|
563
563
|
be referenced with `<%= asset_path("foo.css") %>`. When referencing
|
|
564
564
|
an asset in Rails, always specify the extension you want. Sprockets will
|
|
565
565
|
convert `foo.scss` to `foo.css`.
|
|
@@ -580,7 +580,7 @@ on your system to invoke it.
|
|
|
580
580
|
To write JavaScript assets with CoffeeScript, use the extension
|
|
581
581
|
`.coffee`.
|
|
582
582
|
|
|
583
|
-
In Rails if you have `app/
|
|
583
|
+
In Rails if you have `app/assets/javascripts/foo.coffee` it can
|
|
584
584
|
be referenced with `<%= asset_path("foo.js") %>`. When referencing
|
|
585
585
|
an asset in Rails, always specify the extension you want. Sprockets will
|
|
586
586
|
convert `foo.coffee` to `foo.js`.
|
data/lib/sprockets/asset.rb
CHANGED
data/lib/sprockets/bower.rb
CHANGED
|
@@ -106,7 +106,7 @@ module Sprockets
|
|
|
106
106
|
#
|
|
107
107
|
# environment.gzip = false
|
|
108
108
|
#
|
|
109
|
-
# To enable set to a truthy value. By default zlib
|
|
109
|
+
# To enable set to a truthy value. By default zlib will
|
|
110
110
|
# be used to gzip assets. If you have the Zopfli gem
|
|
111
111
|
# installed you can specify the zopfli algorithm to be used
|
|
112
112
|
# instead:
|
|
@@ -50,6 +50,8 @@ module Sprockets
|
|
|
50
50
|
Marshal.load(marshaled)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
GZIP_MTIME = RUBY_VERSION >= "2.7" ? 0 : 1
|
|
54
|
+
|
|
53
55
|
# Public: Use gzip to compress data.
|
|
54
56
|
#
|
|
55
57
|
# str - String data
|
|
@@ -58,7 +60,7 @@ module Sprockets
|
|
|
58
60
|
def gzip(str)
|
|
59
61
|
io = StringIO.new
|
|
60
62
|
gz = Zlib::GzipWriter.new(io, Zlib::BEST_COMPRESSION)
|
|
61
|
-
gz.mtime =
|
|
63
|
+
gz.mtime = Sprockets::EncodingUtils::GZIP_MTIME
|
|
62
64
|
gz << str
|
|
63
65
|
gz.finish
|
|
64
66
|
io.string
|
data/lib/sprockets/loader.rb
CHANGED
|
@@ -179,7 +179,7 @@ module Sprockets
|
|
|
179
179
|
processors_dep_uri = build_processors_uri(type, file_type, pipeline)
|
|
180
180
|
dependencies = config[:dependencies] + [processors_dep_uri]
|
|
181
181
|
|
|
182
|
-
# Read into memory and process if
|
|
182
|
+
# Read into memory and process if there's a processor pipeline
|
|
183
183
|
if processors.any?
|
|
184
184
|
result = call_processors(processors, {
|
|
185
185
|
environment: self,
|
data/lib/sprockets/manifest.rb
CHANGED
|
@@ -120,14 +120,14 @@ module Sprockets
|
|
|
120
120
|
return to_enum(__method__, *args) unless block_given?
|
|
121
121
|
|
|
122
122
|
environment = self.environment.cached
|
|
123
|
-
|
|
124
|
-
Concurrent::
|
|
123
|
+
futures = args.flatten.map do |path|
|
|
124
|
+
Concurrent::Promises.future_on(executor) do
|
|
125
125
|
environment.find_all_linked_assets(path).to_a
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
futures.each do |future|
|
|
130
|
+
future.value!.each(&block)
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
nil
|
|
@@ -188,15 +188,15 @@ module Sprockets
|
|
|
188
188
|
|
|
189
189
|
filenames << asset.filename
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
future = nil
|
|
192
192
|
exporters_for_asset(asset) do |exporter|
|
|
193
193
|
next if exporter.skip?(logger)
|
|
194
194
|
|
|
195
|
-
if
|
|
196
|
-
|
|
197
|
-
concurrent_exporters <<
|
|
195
|
+
if future.nil?
|
|
196
|
+
future = Concurrent::Promises.future_on(executor) { exporter.call }
|
|
197
|
+
concurrent_exporters << future
|
|
198
198
|
else
|
|
199
|
-
concurrent_exporters <<
|
|
199
|
+
concurrent_exporters << future.then { exporter.call }
|
|
200
200
|
end
|
|
201
201
|
end
|
|
202
202
|
end
|
|
@@ -315,7 +315,7 @@ module Sprockets
|
|
|
315
315
|
end
|
|
316
316
|
|
|
317
317
|
def json_decode(obj)
|
|
318
|
-
JSON.parse(obj
|
|
318
|
+
JSON.parse(obj)
|
|
319
319
|
end
|
|
320
320
|
|
|
321
321
|
def json_encode(obj)
|
data/lib/sprockets/npm.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Sprockets
|
|
|
18
18
|
# The returned dependency set can be passed to resolve_dependencies(deps)
|
|
19
19
|
# to check if the returned result is still fresh. In this case, entry always
|
|
20
20
|
# returns a single path, but multiple calls should accumulate dependencies
|
|
21
|
-
# into a single set
|
|
21
|
+
# into a single set that's saved off and checked later.
|
|
22
22
|
#
|
|
23
23
|
# resolve_dependencies(deps)
|
|
24
24
|
# # => "\x01\x02\x03"
|
data/lib/sprockets/utils/gzip.rb
CHANGED
|
@@ -10,13 +10,15 @@ module Sprockets
|
|
|
10
10
|
# writes contents to the `file` passed in. Sets `mtime` of
|
|
11
11
|
# written file to passed in `mtime`
|
|
12
12
|
module ZlibArchiver
|
|
13
|
-
|
|
13
|
+
MTIME = RUBY_VERSION >= "2.7" ? 0 : 1
|
|
14
|
+
|
|
15
|
+
def self.call(file, source)
|
|
14
16
|
gz = Zlib::GzipWriter.new(file, Zlib::BEST_COMPRESSION)
|
|
15
|
-
gz.mtime =
|
|
17
|
+
gz.mtime = MTIME
|
|
16
18
|
gz.write(source)
|
|
17
19
|
gz.close
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
nil
|
|
20
22
|
end
|
|
21
23
|
end
|
|
22
24
|
|
|
@@ -28,8 +30,8 @@ module Sprockets
|
|
|
28
30
|
# writes contents to the `file` passed in. Sets `mtime` of
|
|
29
31
|
# written file to passed in `mtime`
|
|
30
32
|
module ZopfliArchiver
|
|
31
|
-
def self.call(file, source
|
|
32
|
-
compressed_source = Autoload::Zopfli.deflate(source, format: :gzip
|
|
33
|
+
def self.call(file, source)
|
|
34
|
+
compressed_source = Autoload::Zopfli.deflate(source, format: :gzip)
|
|
33
35
|
file.write(compressed_source)
|
|
34
36
|
file.close
|
|
35
37
|
|
|
@@ -49,7 +51,7 @@ module Sprockets
|
|
|
49
51
|
|
|
50
52
|
# What non-text mime types should we compress? This list comes from:
|
|
51
53
|
# https://www.fastly.com/blog/new-gzip-settings-and-deciding-what-compress
|
|
52
|
-
|
|
54
|
+
COMPRESSIBLE_MIME_TYPES = {
|
|
53
55
|
"application/vnd.ms-fontobject" => true,
|
|
54
56
|
"application/x-font-opentype" => true,
|
|
55
57
|
"application/x-font-ttf" => true,
|
|
@@ -71,7 +73,7 @@ module Sprockets
|
|
|
71
73
|
# can be compressed.
|
|
72
74
|
#
|
|
73
75
|
# We also check against our list of non-text compressible mime types
|
|
74
|
-
@charset ||
|
|
76
|
+
@charset || COMPRESSIBLE_MIME_TYPES.include?(@content_type)
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
# Private: Opposite of `can_compress?`.
|
|
@@ -90,7 +92,8 @@ module Sprockets
|
|
|
90
92
|
# Returns nothing.
|
|
91
93
|
def compress(file, target)
|
|
92
94
|
mtime = Sprockets::PathUtils.stat(target).mtime
|
|
93
|
-
archiver.call(file, source
|
|
95
|
+
archiver.call(file, source)
|
|
96
|
+
File.utime(mtime, mtime, file.path)
|
|
94
97
|
|
|
95
98
|
nil
|
|
96
99
|
end
|
data/lib/sprockets/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sprockets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sam Stephenson
|
|
8
8
|
- Joshua Peek
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|
|
@@ -36,14 +36,14 @@ dependencies:
|
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '1.
|
|
39
|
+
version: '1.1'
|
|
40
40
|
type: :runtime
|
|
41
41
|
prerelease: false
|
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '1.
|
|
46
|
+
version: '1.1'
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: logger
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -450,7 +450,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
450
450
|
- !ruby/object:Gem::Version
|
|
451
451
|
version: '0'
|
|
452
452
|
requirements: []
|
|
453
|
-
rubygems_version:
|
|
453
|
+
rubygems_version: 4.0.16
|
|
454
454
|
specification_version: 4
|
|
455
455
|
summary: Rack-based asset packaging system
|
|
456
456
|
test_files: []
|