condenser 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/condenser.rb +4 -2
- data/lib/condenser/asset.rb +30 -6
- data/lib/condenser/minifiers/uglify_minifier.rb +2 -5
- data/lib/condenser/processors/babel_processor.rb +5 -7
- data/lib/condenser/processors/rollup_processor.rb +11 -4
- data/lib/condenser/resolve.rb +2 -2
- data/lib/condenser/transformers/ejs.rb +5 -7
- data/lib/condenser/version.rb +1 -1
- 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: 8a3307e3793ca525115048d1d418cccdd1ec5727171475fc4909a15b178ac14b
|
4
|
+
data.tar.gz: b991118f195efe01eaae6960862c1101e273f86f3bb1a3ccad009c3ad98f213d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce1137d43308c657fffaff3620a6a6095cf961d697a7c56c85dc685821f637b8e6efe73bfa341ae810b467170fa4ccc6b8e8a7a76cca1e42f24e4e112b47418d
|
7
|
+
data.tar.gz: ffc9df1b3a0222888272d7bcff193854ca4eae42d379d974cbf377cd2302aca24bc839ba82de5ae49efa965e64b455523e19cb06845b936e47c1a115d30f16f8
|
data/lib/condenser.rb
CHANGED
@@ -11,11 +11,13 @@ require 'condenser/encoding_utils'
|
|
11
11
|
require 'condenser/asset'
|
12
12
|
require 'condenser/manifest'
|
13
13
|
|
14
|
+
require 'active_support/benchmarkable'
|
14
15
|
|
15
16
|
class Condenser
|
16
|
-
|
17
|
+
|
18
|
+
include ActiveSupport::Benchmarkable
|
17
19
|
prepend Environment, Pipeline, Resolve
|
18
|
-
|
20
|
+
|
19
21
|
autoload :BabelProcessor, 'condenser/processors/rollup_processor'
|
20
22
|
autoload :RollupProcessor, 'condenser/processors/babel_processor'
|
21
23
|
autoload :UglifyMinifier, 'condenser/minifiers/uglify_minifier'
|
data/lib/condenser/asset.rb
CHANGED
@@ -8,6 +8,7 @@ class Condenser
|
|
8
8
|
class Asset
|
9
9
|
|
10
10
|
include EncodingUtils
|
11
|
+
include ActiveSupport::Benchmarkable
|
11
12
|
|
12
13
|
attr_reader :environment, :filename, :content_types, :source_file, :source_path
|
13
14
|
attr_reader :linked_assets, :content_types_digest
|
@@ -124,9 +125,14 @@ class Condenser
|
|
124
125
|
Digest::SHA1.base64digest(JSON.generate(key))
|
125
126
|
end
|
126
127
|
|
128
|
+
def logger
|
129
|
+
@environment.logger
|
130
|
+
end
|
131
|
+
|
127
132
|
def process
|
128
133
|
return if @processed
|
129
134
|
|
135
|
+
benchmark "Processing Asset #{self.filename}", level: :info do
|
130
136
|
result = @environment.cache.fetch_if(Proc.new { "process/#{cache_key}" }, "dependencies/#{cache_key(false)}") do
|
131
137
|
@environment.build do
|
132
138
|
|
@@ -154,7 +160,10 @@ class Condenser
|
|
154
160
|
data[:processors] << templator_klass.name
|
155
161
|
@environment.load_processors(templator_klass)
|
156
162
|
|
157
|
-
templator.
|
163
|
+
benchmark "Preprocessing #{data[:filename]} with #{templator.name}", level: :info do
|
164
|
+
templator.call(@environment, data)
|
165
|
+
end
|
166
|
+
|
158
167
|
data[:filename] = data[:filename].gsub(/\.#{extensions.last}$/, '')
|
159
168
|
end
|
160
169
|
|
@@ -174,9 +183,10 @@ class Condenser
|
|
174
183
|
processor_klass = (processor.is_a?(Class) ? processor : processor.class)
|
175
184
|
data[:processors] << processor_klass.name
|
176
185
|
@environment.load_processors(processor_klass)
|
177
|
-
|
178
|
-
|
179
|
-
|
186
|
+
|
187
|
+
benchmark "Preprocessing #{self.filename} with #{processor.name}", level: :info do
|
188
|
+
processor.call(@environment, data)
|
189
|
+
end
|
180
190
|
end
|
181
191
|
end
|
182
192
|
|
@@ -234,9 +244,11 @@ class Condenser
|
|
234
244
|
load_processors
|
235
245
|
|
236
246
|
@processed = true
|
247
|
+
end
|
237
248
|
end
|
238
249
|
|
239
250
|
def export
|
251
|
+
benchmark "Exporting Asset #{self.filename}", level: :info do
|
240
252
|
@environment.build do
|
241
253
|
result = @environment.cache.fetch("export/#{cache_key}") do
|
242
254
|
process
|
@@ -252,8 +264,19 @@ class Condenser
|
|
252
264
|
linked_assets: [],
|
253
265
|
dependencies: []
|
254
266
|
}
|
255
|
-
|
256
|
-
@environment.
|
267
|
+
|
268
|
+
if exporter = @environment.exporters[content_type]
|
269
|
+
benchmark "Preprocessing #{data[:filename]} with #{exporter.name}", level: :info do
|
270
|
+
exporter.call(@environment, data)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
if minifier = @environment.minifier_for(content_type)
|
275
|
+
benchmark "Preprocessing #{data[:filename]} with #{minifier.name}", level: :info do
|
276
|
+
minifier.call(@environment, data)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
257
280
|
data[:digest] = @environment.digestor.digest(data[:source])
|
258
281
|
data[:digest_name] = @environment.digestor.name.sub(/^.*::/, '').downcase
|
259
282
|
data
|
@@ -261,6 +284,7 @@ class Condenser
|
|
261
284
|
|
262
285
|
Export.new(@environment, result)
|
263
286
|
end
|
287
|
+
end
|
264
288
|
end
|
265
289
|
|
266
290
|
def to_s
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require File.expand_path('../../processors/node_processor', __FILE__)
|
2
2
|
|
3
|
+
# From npm install uglify-js
|
3
4
|
class Condenser::UglifyMinifier < Condenser::NodeProcessor
|
4
5
|
|
5
6
|
class Error < StandardError
|
6
7
|
end
|
7
8
|
|
8
|
-
# From npm install uglify-js
|
9
|
-
UGLIFY_SOURCE = File.expand_path('../node_modules', __FILE__)
|
10
|
-
|
11
9
|
def self.call(environment, input)
|
12
10
|
new.call(environment, input)
|
13
11
|
end
|
@@ -30,8 +28,7 @@ class Condenser::UglifyMinifier < Condenser::NodeProcessor
|
|
30
28
|
}.merge(@options)
|
31
29
|
|
32
30
|
result = exec_runtime(<<-JS)
|
33
|
-
|
34
|
-
const UglifyJS = require("uglify-js");
|
31
|
+
const UglifyJS = require("#{File.expand_path('../node_modules', __FILE__)}/uglify-js");
|
35
32
|
const source = #{JSON.generate(input[:filename] => input[:source])}
|
36
33
|
const options = #{JSON.generate(opts)};
|
37
34
|
|
@@ -17,11 +17,11 @@ class Condenser::BabelProcessor < Condenser::NodeProcessor
|
|
17
17
|
ast: false,
|
18
18
|
compact: false,
|
19
19
|
plugins: [
|
20
|
-
['babel-plugin-transform-class-extended-hook
|
21
|
-
["
|
22
|
-
['
|
20
|
+
["#{File.expand_path('../node_modules', __FILE__)}/babel-plugin-transform-class-extended-hook", {}],
|
21
|
+
["#{File.expand_path('../node_modules', __FILE__)}/@babel/plugin-proposal-class-properties", {}],
|
22
|
+
["#{File.expand_path('../node_modules', __FILE__)}/@babel/plugin-transform-runtime", { corejs: 3 }],
|
23
23
|
],
|
24
|
-
presets: [["
|
24
|
+
presets: [["#{File.expand_path('../node_modules', __FILE__)}/@babel/preset-env", {
|
25
25
|
"modules": false,
|
26
26
|
"targets": { "browsers": "> 1% and not dead" }
|
27
27
|
} ]],
|
@@ -42,9 +42,7 @@ class Condenser::BabelProcessor < Condenser::NodeProcessor
|
|
42
42
|
}.merge(@options)
|
43
43
|
|
44
44
|
result = exec_runtime(<<-JS)
|
45
|
-
|
46
|
-
|
47
|
-
const babel = require('@babel/core');
|
45
|
+
const babel = require("#{File.expand_path('../node_modules', __FILE__)}/@babel/core");
|
48
46
|
const source = #{JSON.generate(input[:source])};
|
49
47
|
const options = #{JSON.generate(opts).gsub(/"@?babel[\/-][^"]+"/) { |m| "require(#{m})"}};
|
50
48
|
|
@@ -4,6 +4,8 @@ require File.expand_path('../node_processor', __FILE__)
|
|
4
4
|
|
5
5
|
class Condenser::RollupProcessor < Condenser::NodeProcessor
|
6
6
|
|
7
|
+
include ActiveSupport::Benchmarkable
|
8
|
+
|
7
9
|
ROLLUP_VERSION = '0.56.1'
|
8
10
|
|
9
11
|
def self.call(environment, input)
|
@@ -13,6 +15,10 @@ class Condenser::RollupProcessor < Condenser::NodeProcessor
|
|
13
15
|
def initialize(options = {})
|
14
16
|
@options = options.merge({}).freeze
|
15
17
|
end
|
18
|
+
|
19
|
+
def logger
|
20
|
+
@environment.logger
|
21
|
+
end
|
16
22
|
|
17
23
|
def call(environment, input)
|
18
24
|
@environment = environment
|
@@ -71,9 +77,9 @@ class Condenser::RollupProcessor < Condenser::NodeProcessor
|
|
71
77
|
buffer = emitMessages(buffer);
|
72
78
|
});
|
73
79
|
|
74
|
-
const rollup = require("rollup");
|
75
|
-
const commonjs = require('rollup-plugin-commonjs');
|
76
|
-
const nodeResolve = require('rollup-plugin-node-resolve');
|
80
|
+
const rollup = require("#{File.expand_path('../node_modules', __FILE__)}/rollup");
|
81
|
+
const commonjs = require('#{File.expand_path('../node_modules', __FILE__)}/rollup-plugin-commonjs');
|
82
|
+
const nodeResolve = require('#{File.expand_path('../node_modules', __FILE__)}/rollup-plugin-node-resolve');
|
77
83
|
var rid = 0;
|
78
84
|
var renderStack = {};
|
79
85
|
var nodeResolver = null;
|
@@ -196,9 +202,9 @@ class Condenser::RollupProcessor < Condenser::NodeProcessor
|
|
196
202
|
end
|
197
203
|
|
198
204
|
messages.each do |message|
|
199
|
-
# puts message
|
200
205
|
message = JSON.parse(message)
|
201
206
|
|
207
|
+
benchmark "Rollup #{message['method']}(#{message['args'].map(&:inspect).join(', ')})", level: :info do
|
202
208
|
ret = case message['method']
|
203
209
|
when 'resolve'
|
204
210
|
importee, importer = message['args']
|
@@ -286,6 +292,7 @@ class Condenser::RollupProcessor < Condenser::NodeProcessor
|
|
286
292
|
end
|
287
293
|
|
288
294
|
io.write(JSON.generate({rid: message['rid'], return: ret}))
|
295
|
+
end
|
289
296
|
end
|
290
297
|
end
|
291
298
|
rescue Errno::EPIPE, EOFError
|
data/lib/condenser/resolve.rb
CHANGED
@@ -95,9 +95,9 @@ class Condenser
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
def find(filename, base=nil,
|
98
|
+
def find(filename, base=nil, accept: nil, ignore: [])
|
99
99
|
build do
|
100
|
-
resolve(filename, base,
|
100
|
+
@build_cache["find/#{[filename, base, accept].join('-')}"] ||= resolve(filename, base, accept: accept, ignore: ignore).first
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -32,13 +32,13 @@ class Condenser::EjsTransformer < Condenser::NodeProcessor
|
|
32
32
|
ast: false,
|
33
33
|
compact: false,
|
34
34
|
plugins: [
|
35
|
-
['babel-plugin-transform-class-extended-hook
|
36
|
-
["
|
37
|
-
['
|
35
|
+
["#{File.expand_path('../../processors/node_modules', __FILE__)}/babel-plugin-transform-class-extended-hook", {}],
|
36
|
+
["#{File.expand_path('../../processors/node_modules', __FILE__)}/@babel/plugin-proposal-class-properties", {}],
|
37
|
+
["#{File.expand_path('../../processors/node_modules', __FILE__)}/@babel/plugin-transform-runtime", {
|
38
38
|
corejs: 3,
|
39
39
|
}],
|
40
40
|
],
|
41
|
-
presets: [["
|
41
|
+
presets: [["#{File.expand_path('../../processors/node_modules', __FILE__)}/@babel/preset-env", {
|
42
42
|
"modules": false,
|
43
43
|
"targets": { "browsers": "> 1% and not dead" }
|
44
44
|
} ]],
|
@@ -46,9 +46,7 @@ class Condenser::EjsTransformer < Condenser::NodeProcessor
|
|
46
46
|
}
|
47
47
|
|
48
48
|
result = exec_runtime(<<-JS)
|
49
|
-
|
50
|
-
|
51
|
-
const babel = require('@babel/core');
|
49
|
+
const babel = require("#{File.expand_path('../../processors/node_modules', __FILE__)}/@babel/core");
|
52
50
|
const source = #{JSON.generate(input[:source])};
|
53
51
|
const options = #{JSON.generate(opts).gsub(/"@?babel[\/-][^"]+"/) { |m| "require(#{m})"}};
|
54
52
|
|
data/lib/condenser/version.rb
CHANGED