humid 0.0.1 → 0.0.2
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/README.md +3 -3
- data/lib/humid.rb +11 -7
- data/lib/humid/version.rb +1 -1
- data/spec/render_spec.rb +1 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cd194cc5fb744d074ef3d6e8599399e67badcf850c2d499ab13b7e6a642b3fd
|
4
|
+
data.tar.gz: 181241a3e3cf678560deb8c053dcb43f7ab5dae4257b735e2582e9ecadac16e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25db74cf8176dc280e2739b61995969a91eb893063020b7c455553ab2a5d571b4f402c96943bc9e8bb66541612e535e9a030e1ab28e7ca849baf1f9e77c0208e
|
7
|
+
data.tar.gz: 39ca3a3b46f5426e81c3811591d6e6a6f54fde304e9531f5a37490c380dd4272bfac9b3afa44997391fe6987e9927d3ac1ff3b52a51131841f6ae84bc12fe66d
|
data/README.md
CHANGED
@@ -36,8 +36,8 @@ Humid.configure do |config|
|
|
36
36
|
# name of your webpacker pack. Defaults to "server_rendering.js"
|
37
37
|
config.server_rendering_source = "server_rendering.js"
|
38
38
|
|
39
|
-
# name of your webpacker pack source map. Defaults to `
|
40
|
-
config.
|
39
|
+
# name of your webpacker pack source map. Defaults to `false`
|
40
|
+
config.use_source_map = true
|
41
41
|
|
42
42
|
# The logger instance. Defaults to `Logger.new(STDOUT)`
|
43
43
|
# `console.log` and friends (`warn`, `error`) are delegated to
|
@@ -56,7 +56,7 @@ end
|
|
56
56
|
```
|
57
57
|
|
58
58
|
If you'd like support for source map support, you will need to
|
59
|
-
1. Ensure `config.
|
59
|
+
1. Ensure `config.use_source_map` is set to `true`
|
60
60
|
2. Add the following to your `server_rendering.js` pack.
|
61
61
|
|
62
62
|
```javascript
|
data/lib/humid.rb
CHANGED
@@ -15,8 +15,8 @@ module Humid
|
|
15
15
|
"server_rendering.js"
|
16
16
|
end
|
17
17
|
|
18
|
-
config_accessor :
|
19
|
-
|
18
|
+
config_accessor :use_source_map do
|
19
|
+
false
|
20
20
|
end
|
21
21
|
|
22
22
|
config_accessor :logger do
|
@@ -84,12 +84,16 @@ module Humid
|
|
84
84
|
ctx.eval(js)
|
85
85
|
|
86
86
|
public_path = Webpacker.config.public_path
|
87
|
-
|
88
|
-
|
89
|
-
ctx.eval(File.read(asset_path), filename: filename)
|
87
|
+
server_rendering_file = config.server_rendering_file
|
88
|
+
server_rendering_map = "#{config.server_rendering_file}.map"
|
90
89
|
|
91
|
-
|
92
|
-
|
90
|
+
source_path = public_path.join(Webpacker.manifest.lookup(server_rendering_file)[1..-1])
|
91
|
+
map_path = public_path.join(Webpacker.manifest.lookup(server_rendering_map)[1..-1])
|
92
|
+
|
93
|
+
filename = File.basename(source_path.to_s)
|
94
|
+
ctx.eval(File.read(source_path), filename: filename)
|
95
|
+
|
96
|
+
if config.use_source_map
|
93
97
|
ctx.attach("readSourceMap", proc { File.read(map_path) })
|
94
98
|
end
|
95
99
|
|
data/lib/humid/version.rb
CHANGED
data/spec/render_spec.rb
CHANGED
@@ -119,9 +119,7 @@ RSpec.describe "Humid" do
|
|
119
119
|
|
120
120
|
it "can use source maps to see errors" do
|
121
121
|
allow(Humid.config).to receive("server_rendering_file") { "reporting.js" }
|
122
|
-
allow(Humid.config).to receive("
|
123
|
-
"reporting.js.map"
|
124
|
-
}
|
122
|
+
allow(Humid.config).to receive("use_source_map") { true }
|
125
123
|
|
126
124
|
Humid.create_context
|
127
125
|
|