sprockets-commoner 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1b9fda2acf409f31fb052204e5319eecc1b9ed2
4
- data.tar.gz: 8b5eee7b0be2cce4141b62388fd83fdf99b0c41d
3
+ metadata.gz: 050e566c2312264eeea0ddadb4e080829145b5b7
4
+ data.tar.gz: e31e4762cd2d77377373a9ea64c2604484205b3e
5
5
  SHA512:
6
- metadata.gz: b77a61c55a9dcbf6c7f9f81a7bd48d926519f8b5e56fedcc07eace32841cc1e6e5ca31079faf4e0b91a1aac9797ee912e2dfd7c345a2f3b8d15e7920ab93fc13
7
- data.tar.gz: 589434178aa3f2156952ec3aadf726bc1617cbe75a8ec3124940a7a4b973e04300bb9ced705a18ed6c498c00f55c4fcf4fb911495963505495da7bc627e086ca
6
+ metadata.gz: d8c37e78ec66df4a9f7a9fdaf988b9510012eeed51e2bebd1f16794a8777c3505551d11481c4b0185234a6b03518a873f5cdc0eaef7cddc6fccb324f8d6d706e
7
+ data.tar.gz: 59d6ca6f918fdf4836457d2e50c6016a516c07fcb4336e10634bc03f7a4544fcecb07fb2e13144bff54450d00df4492e294d433558794680f6294a9f26250e71
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.4
4
+
5
+ * Enable completely optimizing away empty module definitions.
6
+
3
7
  ## v0.2.3
4
8
 
5
9
  * Only avoid imports that won't be processed by Commoner if we actually use the module.
@@ -276,9 +276,21 @@ module.exports = function (context) {
276
276
 
277
277
  // Transform module to a variable assignment.
278
278
  // This variable is then referenced by any dependant children.
279
- node.body = [t.variableDeclaration('var', [t.variableDeclarator(t.identifier(identifier), t.callExpression(t.identifier('__commoner_initialize_module__'), [t.functionExpression(null, [t.identifier('module'), t.identifier('exports')], t.blockStatement(node.body, node.directives))]))])];
279
+ var block = t.blockStatement(node.body, node.directives);
280
+ var f = t.functionExpression(null, [t.identifier('module'), t.identifier('exports')], block);
281
+ var call = t.callExpression(t.identifier('__commoner_initialize_module__'), [f]);
282
+ var declarator = t.variableDeclarator(t.identifier(identifier), call);
283
+ var declaration = t.variableDeclaration('var', [declarator]);
284
+
285
+ node.body = [declaration];
280
286
  node.directives = [];
287
+
288
+ // Rewrite calls
281
289
  path.traverse(callRewriter, state);
290
+
291
+ if (block.body.length === 0) {
292
+ declarator.init = t.objectExpression([]);
293
+ }
282
294
  }
283
295
  }
284
296
  }
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Commoner
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-commoner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bouke van der Bijl