condenser 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/condenser/asset.rb +19 -16
  3. data/lib/condenser/build_cache.rb +1 -1
  4. data/lib/condenser/context.rb +9 -25
  5. data/lib/condenser/helpers/parse_helpers.rb +1 -1
  6. data/lib/condenser/manifest.rb +3 -1
  7. data/lib/condenser/pipeline.rb +8 -3
  8. data/lib/condenser/processors/babel_processor.rb +1 -1
  9. data/lib/condenser/processors/css_media_combiner_processor.rb +81 -0
  10. data/lib/condenser/processors/js_analyzer.rb +0 -2
  11. data/lib/condenser/processors/purgecss_processor.rb +6 -4
  12. data/lib/condenser/processors/rollup_processor.rb +37 -35
  13. data/lib/condenser/resolve.rb +1 -3
  14. data/lib/condenser/templating_engine/ejs.rb +1 -1
  15. data/lib/condenser/transformers/dart_sass_transformer.rb +285 -0
  16. data/lib/condenser/transformers/jst_transformer.rb +67 -17
  17. data/lib/condenser/transformers/sass/functions.rb +133 -0
  18. data/lib/condenser/transformers/sass/importer.rb +48 -0
  19. data/lib/condenser/transformers/sass.rb +4 -0
  20. data/lib/condenser/transformers/sass_transformer.rb +124 -281
  21. data/lib/condenser/transformers/svg_transformer/base.rb +26 -0
  22. data/lib/condenser/transformers/svg_transformer/tag.rb +54 -0
  23. data/lib/condenser/transformers/svg_transformer/template.rb +151 -0
  24. data/lib/condenser/transformers/svg_transformer/template_error.rb +2 -0
  25. data/lib/condenser/transformers/svg_transformer/value.rb +13 -0
  26. data/lib/condenser/transformers/svg_transformer/var_generator.rb +10 -0
  27. data/lib/condenser/transformers/svg_transformer.rb +19 -0
  28. data/lib/condenser/version.rb +1 -1
  29. data/lib/condenser.rb +17 -5
  30. data/test/cache_test.rb +46 -2
  31. data/test/dependency_test.rb +2 -2
  32. data/test/manifest_test.rb +34 -0
  33. data/test/minifiers/terser_minifier_test.rb +0 -1
  34. data/test/minifiers/uglify_minifier_test.rb +0 -1
  35. data/test/postprocessors/css_media_combiner_test.rb +107 -0
  36. data/test/postprocessors/purgecss_test.rb +62 -0
  37. data/test/preprocessor/babel_test.rb +693 -299
  38. data/test/preprocessor/js_analyzer_test.rb +0 -2
  39. data/test/processors/rollup_test.rb +50 -20
  40. data/test/resolve_test.rb +8 -9
  41. data/test/server_test.rb +6 -1
  42. data/test/templates/ejs_test.rb +2 -11
  43. data/test/templates/erb_test.rb +0 -5
  44. data/test/test_helper.rb +3 -1
  45. data/test/transformers/dart_scss_test.rb +139 -0
  46. data/test/transformers/jst_test.rb +165 -21
  47. data/test/transformers/scss_test.rb +14 -0
  48. data/test/transformers/svg_test.rb +40 -0
  49. metadata +23 -6
  50. data/lib/condenser/transformers/sass_transformer/importer.rb +0 -50
@@ -4,8 +4,6 @@ class JSAnalyzerTest < ActiveSupport::TestCase
4
4
 
5
5
  def setup
6
6
  super
7
- @env.unregister_preprocessor 'application/javascript', Condenser::BabelProcessor
8
- @env.register_preprocessor 'application/javascript', Condenser::JSAnalyzer
9
7
  @env.unregister_minifier('application/javascript')
10
8
  end
11
9
 
@@ -31,15 +31,14 @@ class RollupTest < ActiveSupport::TestCase
31
31
  (function () {
32
32
  'use strict';
33
33
 
34
- // This function isn't used anywhere, so
35
-
36
- function cube(x) {
34
+ // This function gets included
35
+ function cube ( x ) {
37
36
  return x * x * x;
38
37
  }
39
38
 
40
- console.log(cube(5)); // 125
39
+ console.log( cube( 5 ) ); // 125
41
40
 
42
- }());
41
+ })();
43
42
  FILE
44
43
  end
45
44
 
@@ -59,13 +58,13 @@ class RollupTest < ActiveSupport::TestCase
59
58
  (function () {
60
59
  'use strict';
61
60
 
62
- function cube(x) {
61
+ function cube ( x ) {
63
62
  return 2 * x * x;
64
63
  }
65
64
 
66
- console.log(cube(5)); // 125
65
+ console.log( cube( 5 ) ); // 125
67
66
 
68
- }());
67
+ })();
69
68
  FILE
70
69
  end
71
70
 
@@ -93,13 +92,13 @@ class RollupTest < ActiveSupport::TestCase
93
92
  (function () {
94
93
  'use strict';
95
94
 
96
- function cube(x) {
95
+ function cube ( x ) {
97
96
  return x * x * x;
98
97
  }
99
98
 
100
- console.log(cube(5)); // 125
99
+ console.log( cube( 5 ) ); // 125
101
100
 
102
- }());
101
+ })();
103
102
  FILE
104
103
  end
105
104
 
@@ -126,17 +125,17 @@ class RollupTest < ActiveSupport::TestCase
126
125
  (function () {
127
126
  'use strict';
128
127
 
129
- window.cube = function (x) {
128
+ window.cube = function ( x ) {
130
129
  return x * x * x;
131
130
  };
132
131
 
133
- window.square = function (x) {
132
+ window.square = function ( x ) {
134
133
  return x * x;
135
134
  };
136
135
 
137
- console.log(square(cube(5)));
136
+ console.log( square(cube( 5 )) );
138
137
 
139
- }());
138
+ })();
140
139
  FILE
141
140
  end
142
141
 
@@ -168,27 +167,58 @@ class RollupTest < ActiveSupport::TestCase
168
167
  (function () {
169
168
  'use strict';
170
169
 
171
- function cube(x) {
170
+ function cube ( x ) {
172
171
  return x * x * x;
173
172
  }
174
173
 
175
- function square(x) {
174
+ function square ( x ) {
176
175
  return x * x;
177
176
  }
178
177
 
179
178
  var maths = [cube, square];
180
179
 
181
180
  var x = 1;
182
-
183
181
  for (var i = 0; i < maths.length; i++) {
184
182
  x = maths[i](x);
185
183
  }
186
-
187
184
  console.log(x);
188
185
 
189
- }());
186
+ })();
190
187
  FILE
191
188
  $d = false
192
189
  end
193
190
 
191
+ test 'import the same file via relative require and full path' do
192
+ file "#{@npm_path}/module/base.js", <<~JS
193
+ export default class Base { };
194
+ JS
195
+
196
+ file "#{@npm_path}/module/base/other.js", <<~JS
197
+ import Base from '../base';
198
+
199
+ export default class Lower extends Base { };
200
+ JS
201
+
202
+ file 'main.js', <<~JS
203
+ import Other from 'module/base/other';
204
+ import Base from 'module/base';
205
+
206
+ console.log( Base, Other );
207
+ JS
208
+
209
+
210
+ assert_exported_file 'main.js', 'application/javascript', <<~FILE
211
+ (function () {
212
+ 'use strict';
213
+
214
+ class Base { }
215
+
216
+ class Lower extends Base { }
217
+
218
+ console.log( Base, Lower );
219
+
220
+ })();
221
+ FILE
222
+ end
223
+
194
224
  end
data/test/resolve_test.rb CHANGED
@@ -83,7 +83,6 @@ class ResolveTest < ActiveSupport::TestCase
83
83
  @env.append_path File.join(@path, 'b')
84
84
  @env.append_path File.join(@path, 'a')
85
85
 
86
-
87
86
  assert_exported_file('main.js', 'application/javascript', <<~JS)
88
87
  (function () {
89
88
  'use strict';
@@ -94,7 +93,7 @@ class ResolveTest < ActiveSupport::TestCase
94
93
 
95
94
  console.log( cube( 5 ) ); // 125
96
95
 
97
- }());
96
+ })();
98
97
  JS
99
98
  end
100
99
 
@@ -111,15 +110,15 @@ class ResolveTest < ActiveSupport::TestCase
111
110
  end
112
111
 
113
112
  test 'resolve a file.*' do
114
- file 'file.js', 'console.log(1);'
115
- file 'file.scss', 'body { background: red; }'
116
- file 'test/file.scss', 'body { background: green; }'
113
+ file 'foo.js', 'console.log(1);'
114
+ file 'foo.scss', 'body { background: red; }'
115
+ file 'test/foo.scss', 'body { background: green; }'
117
116
 
118
- assert_equal %w(file.js file.scss), @env.resolve('file.*').map(&:filename)
119
- assert_equal %w(file.css file.js), @env.resolve('file.*', accept: ['text/css', 'application/javascript']).map(&:filename)
117
+ assert_equal %w(foo.js foo.scss), @env.resolve('foo.*').map(&:filename)
118
+ assert_equal %w(foo.css foo.js), @env.resolve('foo.*', accept: ['text/css', 'application/javascript']).map(&:filename)
120
119
 
121
- assert_equal %w(file.js file.scss test/file.scss), @env.resolve('**/file.*').map(&:filename)
122
- assert_equal %w(file.css file.js test/file.css), @env.resolve('**/file.*', accept: ['text/css', 'application/javascript']).map(&:filename)
120
+ assert_equal %w(foo.js foo.scss test/foo.scss), @env.resolve('**/foo.*').map(&:filename)
121
+ assert_equal %w(foo.css foo.js test/foo.css), @env.resolve('**/foo.*', accept: ['text/css', 'application/javascript']).map(&:filename)
123
122
  end
124
123
 
125
124
  end
data/test/server_test.rb CHANGED
@@ -224,7 +224,12 @@ class ServerTest < ActiveSupport::TestCase
224
224
  assert_equal "pass", last_response.headers['X-Cascade']
225
225
  end
226
226
 
227
- test "re-throw JS exceptions in the browser" do
227
+ test "re-throw JS exceptions in the browser when using babel" do
228
+ @env.unregister_preprocessor('application/javascript', Condenser::JSAnalyzer)
229
+ @env.register_preprocessor 'application/javascript', Condenser::BabelProcessor.new(@path,
230
+ presets: [ ['@babel/preset-env', { modules: false, targets: { browsers: 'firefox > 41' } }] ]
231
+ )
232
+
228
233
  file 'error.js', "var error = {;"
229
234
 
230
235
  get "/assets/error.js"
@@ -4,7 +4,6 @@ class CondenserEJSTest < ActiveSupport::TestCase
4
4
 
5
5
  def setup
6
6
  super
7
- @env.unregister_preprocessor('application/javascript', Condenser::BabelProcessor)
8
7
  @env.unregister_exporter('application/javascript', Condenser::RollupProcessor)
9
8
  end
10
9
 
@@ -15,14 +14,10 @@ class CondenserEJSTest < ActiveSupport::TestCase
15
14
  import { escape } from 'ejs';
16
15
  export default function (locals) {
17
16
  var __output = [],
18
- __append = __output.push.bind(__output);
19
-
17
+ __append = __output.push.bind(__output);
20
18
  __append("1");
21
-
22
19
  __append(escape(1 + 1));
23
-
24
20
  __append("3\\n");
25
-
26
21
  return __output.join("");
27
22
  }
28
23
  JS
@@ -35,14 +30,10 @@ class CondenserEJSTest < ActiveSupport::TestCase
35
30
  import { escape } from 'ejs';
36
31
  export default function (locals) {
37
32
  var __output = [],
38
- __append = __output.push.bind(__output);
39
-
33
+ __append = __output.push.bind(__output);
40
34
  __append("1");
41
-
42
35
  __append(escape(locals.input));
43
-
44
36
  __append("3\\n");
45
-
46
37
  return __output.join("");
47
38
  }
48
39
  JS
@@ -2,11 +2,6 @@ require 'test_helper'
2
2
 
3
3
  class CondenserErubiTest < ActiveSupport::TestCase
4
4
 
5
- def setup
6
- super
7
- @env.unregister_preprocessor('application/javascript', Condenser::BabelProcessor)
8
- end
9
-
10
5
  test 'find' do
11
6
  file 'test.js.erb', "1<%= 1 + 1 %>3\n"
12
7
 
data/test/test_helper.rb CHANGED
@@ -39,6 +39,7 @@ class ActiveSupport::TestCase
39
39
  @env.unregister_writer(Condenser::BrotliWriter)
40
40
  @env.context_class.class_eval do
41
41
  def asset_path(path, options = {})
42
+ path = environment.find!(path, options).path
42
43
  "/assets/#{path}"
43
44
  end
44
45
  end
@@ -53,7 +54,7 @@ class ActiveSupport::TestCase
53
54
  end
54
55
 
55
56
  def file(name, source)
56
- dir = File.join(@path, File.dirname(name))
57
+ dir = name.include?('/') ? File.join(@path, File.dirname(name)) : @path
57
58
  path = File.join(@path, name)
58
59
 
59
60
  FileUtils.mkdir_p(dir)
@@ -62,6 +63,7 @@ class ActiveSupport::TestCase
62
63
  sleep(1 - stat) if stat < 1
63
64
  end
64
65
  File.write(path, source)
66
+ sleep 0.25 if @env.build_cache.listening
65
67
  end
66
68
 
67
69
  def rm(name)
@@ -0,0 +1,139 @@
1
+ require 'test_helper'
2
+
3
+ class CondenserDartSCSSTest < ActiveSupport::TestCase
4
+
5
+ def setup
6
+ super
7
+ @env.clear_pipeline
8
+ @env.register_transformer 'text/scss', 'text/css', Condenser::DartScssTransformer
9
+ end
10
+
11
+ test 'find' do
12
+ file 'test.scss', <<~SCSS
13
+ body {
14
+ background-color: green;
15
+
16
+ &:hover {
17
+ background-color: blue;
18
+ }
19
+ }
20
+ SCSS
21
+
22
+ assert_file 'test.css', 'text/css', <<~CSS
23
+ body {
24
+ background-color: green;
25
+ }
26
+ body:hover {
27
+ background-color: blue;
28
+ }
29
+ CSS
30
+ end
31
+
32
+ test 'scss import globing' do
33
+ file "c/dir/a.scss", "body { color: blue; }"
34
+ file "c/dir/b.scss", "body { color: green; }"
35
+
36
+ file 'c/test.scss', '@import "./dir/*"'
37
+
38
+ assert_file 'c/test.css', 'text/css', <<~CSS
39
+ body {
40
+ color: blue;
41
+ }
42
+
43
+ body {
44
+ color: green;
45
+ }
46
+ CSS
47
+
48
+ file 'c/test2.scss', '@import "c/dir/*"'
49
+
50
+ assert_file 'c/test2.css', 'text/css', <<~CSS
51
+ body {
52
+ color: blue;
53
+ }
54
+
55
+ body {
56
+ color: green;
57
+ }
58
+ CSS
59
+ end
60
+
61
+ test "url functions" do
62
+ file 'a.scss', <<~SCSS
63
+ body {
64
+ color: green; }
65
+ SCSS
66
+
67
+ file 'test.scss', <<~SCSS
68
+ @import 'a';
69
+
70
+ div {
71
+ url: asset-url("foo.svg");
72
+ url: image-url("foo.png");
73
+ url: video-url("foo.mov");
74
+ url: audio-url("foo.mp3");
75
+ url: font-url("foo.woff2");
76
+ url: font-url("foo.woff");
77
+ url: javascript-url("foo.js");
78
+ url: stylesheet-url("foo.css");
79
+ }
80
+ SCSS
81
+
82
+ file 'foo.svg', ''
83
+ file 'foo.png', ''
84
+ file 'foo.mov', ''
85
+ file 'foo.mp3', ''
86
+ file 'foo.woff2', ''
87
+ file 'foo.woff', ''
88
+ file 'foo.js', ''
89
+ file 'foo.css', ''
90
+
91
+ assert_file 'test.css', 'text/css', <<~CSS
92
+ body {
93
+ color: green;
94
+ }
95
+
96
+ div {
97
+ url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.svg);
98
+ url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.png);
99
+ url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.mov);
100
+ url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.mp3);
101
+ url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.woff2);
102
+ url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.woff);
103
+ url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js);
104
+ url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css);
105
+ }
106
+ CSS
107
+
108
+ asset = @env.find('test.css')
109
+ assert_equal ["a.scss", "foo.svg", "foo.png", "foo.mov", "foo.mp3", "foo.woff2", "foo.woff", "foo.js", "foo.css"], asset.process_dependencies.map(&:filename)
110
+ assert_equal ["a.scss", "foo.svg", "foo.png", "foo.mov", "foo.mp3", "foo.woff2", "foo.woff", "foo.js", "foo.css"], asset.export_dependencies.map(&:filename)
111
+ end
112
+
113
+ test "sass dependencies" do
114
+ file 'd.scss', <<~SCSS
115
+ $secondary-color: #444;
116
+ SCSS
117
+
118
+ file 'a.scss', <<~SCSS
119
+ @import 'd';
120
+ $primary-color: #333;
121
+ SCSS
122
+
123
+ file 'b.scss', <<~SCSS
124
+ body {
125
+ color: $primary-color;
126
+ }
127
+ SCSS
128
+
129
+ file 'c.scss', <<~SCSS
130
+ @import 'a';
131
+ @import 'b';
132
+ SCSS
133
+
134
+ asset = @env.find('c.css')
135
+ assert_equal ["a.scss", "d.scss", "b.scss"], asset.process_dependencies.map(&:filename)
136
+ assert_equal ["a.scss", "d.scss", "b.scss"], asset.export_dependencies.map(&:filename)
137
+ end
138
+
139
+ end
@@ -2,23 +2,23 @@ require 'test_helper'
2
2
 
3
3
  class JSTTransformerTest < ActiveSupport::TestCase
4
4
 
5
- test 'jst transoformation' do
5
+ test 'jst transformation' do
6
6
  file 'test.jst', <<~SCSS
7
7
  import {escape} from 'ejs';
8
8
  export default function (locals) {
9
9
  var __output = [], __append = __output.push.bind(__output);
10
10
  __append("<div class=\\"uniformLoader\\n");
11
- if(typeof transparent != "undefined") {
11
+ if(typeof transparent != "undefined") {
12
12
  __append(" -transparent");
13
- }
13
+ }
14
14
  __append("\\n");
15
- if(typeof cover != "undefined") {
15
+ if(typeof cover != "undefined") {
16
16
  __append(" -cover");
17
- }
17
+ }
18
18
  __append("\\n");
19
- if(typeof light != "undefined") {
19
+ if(typeof light != "undefined") {
20
20
  __append(" -light");
21
- }
21
+ }
22
22
  __append(" ");
23
23
  __append( klass );
24
24
  __append("\\">\\n <div class=\\"uniformLoader-container\\">\\n <span></span>\\n <span></span>\\n <span></span>\\n </div>\\n</div>");
@@ -27,41 +27,185 @@ class JSTTransformerTest < ActiveSupport::TestCase
27
27
  SCSS
28
28
 
29
29
  assert_file 'test.js', 'application/javascript', <<~JS
30
- import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
31
30
  import { escape } from 'ejs';
32
31
  export default function (locals) {
33
- var _context;
34
-
35
32
  var __output = [],
36
- __append = _bindInstanceProperty(_context = __output.push).call(_context, __output);
37
-
33
+ __append = __output.push.bind(__output);
38
34
  __append("<div class=\\"uniformLoader\\n");
39
-
40
35
  if (typeof locals.transparent != "undefined") {
41
36
  __append(" -transparent");
42
37
  }
43
-
44
38
  __append("\\n");
45
-
46
39
  if (typeof locals.cover != "undefined") {
47
40
  __append(" -cover");
48
41
  }
49
-
50
42
  __append("\\n");
51
-
52
43
  if (typeof locals.light != "undefined") {
53
44
  __append(" -light");
54
45
  }
55
-
56
46
  __append(" ");
57
-
58
47
  __append(locals.klass);
59
-
60
48
  __append("\\">\\n <div class=\\"uniformLoader-container\\">\\n <span></span>\\n <span></span>\\n <span></span>\\n </div>\\n</div>");
61
-
62
49
  return __output.join("");
63
50
  }
64
51
  JS
65
52
  end
66
53
 
54
+ test 'jst transformation with object' do
55
+ file 'test.jst', <<~SCSS
56
+ import {append as __ejx_append} from 'ejx';
57
+ export default function (locals) {
58
+ var __output = [];
59
+ __ejx_append(avatarTemplate({ account: account }), __output);
60
+ return __output;
61
+ }
62
+ SCSS
63
+
64
+ assert_file 'test.js', 'application/javascript', <<~JS
65
+ import { append as __ejx_append } from 'ejx';
66
+ export default function (locals) {
67
+ var __output = [];
68
+ __ejx_append(locals.avatarTemplate({
69
+ account: locals.account
70
+ }), __output);
71
+ return __output;
72
+ }
73
+ JS
74
+ end
75
+
76
+ test 'jst with transformation scope test of a defined function' do
77
+ file 'test.jst', <<~SCSS
78
+ import {append as __ejx_append} from 'ejx';
79
+ export default function (locals) {
80
+ var __output = [];
81
+
82
+ function x(files) {
83
+ return files.test();
84
+ }
85
+
86
+ class B {
87
+ }
88
+
89
+ models.map(m => m.name)
90
+
91
+ __ejx_append(avatarTemplate({ account: x(files), klass: B }), __output);
92
+ return __output;
93
+ }
94
+ SCSS
95
+
96
+ assert_file 'test.js', 'application/javascript', <<~JS
97
+ import { append as __ejx_append } from 'ejx';
98
+ export default function (locals) {
99
+ var __output = [];
100
+ function x(files) {
101
+ return files.test();
102
+ }
103
+ class B {}
104
+ locals.models.map(m => m.name);
105
+ __ejx_append(locals.avatarTemplate({
106
+ account: x(locals.files),
107
+ klass: B
108
+ }), __output);
109
+ return __output;
110
+ }
111
+ JS
112
+ end
113
+
114
+ test 'jst with transformation shadow variable example' do
115
+ file 'test.jst', <<~JS
116
+ import {append as __ejx_append} from 'ejx';
117
+ export default async function (locals) {
118
+ function f (items, template) {
119
+ return items.map((file) => {
120
+ const row = template(file);
121
+ const bar = row.querySelector('.progress-bar');
122
+ file.onprogress = (n) => { row.style.width = "" + n + "%"; }
123
+
124
+ return row;
125
+ });
126
+ }
127
+ __ejx_append(f(items, (f) => { return __v; }));
128
+ return __output;
129
+ }
130
+ JS
131
+
132
+ assert_file 'test.js', 'application/javascript', <<~JS
133
+ import { append as __ejx_append } from 'ejx';
134
+ export default async function (locals) {
135
+ function f(items, template) {
136
+ return items.map(file => {
137
+ const row = template(file);
138
+ const bar = row.querySelector('.progress-bar');
139
+ file.onprogress = n => {
140
+ row.style.width = "" + n + "%";
141
+ };
142
+ return row;
143
+ });
144
+ }
145
+ __ejx_append(f(locals.items, f => {
146
+ return locals.__v;
147
+ }));
148
+ return locals.__output;
149
+ }
150
+ JS
151
+ end
152
+
153
+ test 'try/catch example' do
154
+ file 'test.jst', <<~JS
155
+ import {append as __ejx_append} from 'ejx';
156
+ export default function (locals) {
157
+ var __output = [];
158
+ try {
159
+ __ejx_append(avatarTemplate({ account: account }), __output);
160
+ } catch (e) {
161
+ console.error(e);
162
+ }
163
+
164
+ console.error(e);
165
+
166
+ return __output;
167
+ }
168
+ JS
169
+
170
+ assert_file 'test.js', 'application/javascript', <<~JS
171
+ import { append as __ejx_append } from 'ejx';
172
+ export default function (locals) {
173
+ var __output = [];
174
+ try {
175
+ __ejx_append(locals.avatarTemplate({
176
+ account: locals.account
177
+ }), __output);
178
+ } catch (e) {
179
+ console.error(e);
180
+ }
181
+ console.error(locals.e);
182
+ return __output;
183
+ }
184
+ JS
185
+ end
186
+
187
+ test 'splats' do
188
+ file 'test.jst', <<~JS
189
+ import {append as __ejx_append} from 'ejx';
190
+ export default function (locals) {
191
+ var __output = [];
192
+
193
+ var x = ((...args) => { return y(...args); })(z, y);
194
+
195
+ return __output;
196
+ }
197
+ JS
198
+
199
+ assert_file 'test.js', 'application/javascript', <<~JS
200
+ import { append as __ejx_append } from 'ejx';
201
+ export default function (locals) {
202
+ var __output = [];
203
+ var x = ((...args) => {
204
+ return locals.y(...args);
205
+ })(locals.z, locals.y);
206
+ return __output;
207
+ }
208
+ JS
209
+ end
210
+
67
211
  end
@@ -47,7 +47,14 @@ class CondenserSCSSTest < ActiveSupport::TestCase
47
47
  end
48
48
 
49
49
  test "url functions" do
50
+ file 'a.scss', <<~SCSS
51
+ body {
52
+ color: green; }
53
+ SCSS
54
+
50
55
  file 'test.scss', <<~SCSS
56
+ @import 'a';
57
+
51
58
  div {
52
59
  url: asset-url("foo.svg");
53
60
  url: image-url("foo.png");
@@ -70,6 +77,9 @@ class CondenserSCSSTest < ActiveSupport::TestCase
70
77
  file 'foo.css', ''
71
78
 
72
79
  assert_file 'test.css', 'text/css', <<~CSS
80
+ body {
81
+ color: green; }
82
+
73
83
  div {
74
84
  url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.svg);
75
85
  url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.png);
@@ -80,6 +90,10 @@ class CondenserSCSSTest < ActiveSupport::TestCase
80
90
  url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js);
81
91
  url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css); }
82
92
  CSS
93
+
94
+ asset = @env.find('test.css')
95
+ assert_equal ["a.scss", "foo.svg", "foo.png", "foo.mov", "foo.mp3", "foo.woff2", "foo.woff", "foo.js", "foo.css"], asset.process_dependencies.map(&:filename)
96
+ assert_equal ["a.scss", "foo.svg", "foo.png", "foo.mov", "foo.mp3", "foo.woff2", "foo.woff", "foo.js", "foo.css"], asset.export_dependencies.map(&:filename)
83
97
  end
84
98
 
85
99
  test "sass dependencies" do