sprockets-commoner 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7be0d75114fb75a73b272d1493290b864cce8455
4
- data.tar.gz: 3c98183d4ecfc9ab3824ece0acf091255f9df219
3
+ metadata.gz: a57316ae97d13d23f2f99b58b201059e5e9747f0
4
+ data.tar.gz: 0181f1332eb2186e3ead1d9ce0e667003515f918
5
5
  SHA512:
6
- metadata.gz: 6985592443fef03121a57c8a8e1f3c37e684a2fedb0561014f8c242f2629fccf6dc2f3c30789494b4a41eececaccde49424a40b858b7a7e11ad3c204093da44e
7
- data.tar.gz: 16d3679cb215ca29fd2c8b1513cfb09704096ab31cf368ad42e5a7c8b6a41bbd13e3344ddfc0bbd89ee9f38119428f257ba3b4ab9749dec58dd896c2d3cf9307
6
+ metadata.gz: 67bcc7e5802143423cb943c3bae82248ba5e8719abc22ff4bd7607a642a3b1acbcda606483eb9d2831acef42ec42bb47a43da805a76d4aae79dfdf2ef28257e6
7
+ data.tar.gz: 8d87680e92ff8bf583f5bf5608cf1f9e34387b96381e98559767dc4ec858a2761a062f1c9986dbd586ee3b839bfafc503e87c54895a38526012c6577e384fb42
@@ -25,7 +25,9 @@ if (typeof Object.assign != 'function') {
25
25
 
26
26
  var fs = require('fs');
27
27
  var dirname = require('path').dirname;
28
+ var join = require('path').join;
28
29
  var resolve = require('browser-resolve').sync;
30
+ var emptyModule = join(__dirname, 'node_modules', 'browser-resolve', 'empty.js');
29
31
 
30
32
  module.exports = function (context) {
31
33
  var t = context.types;
@@ -63,7 +65,7 @@ module.exports = function (context) {
63
65
  }
64
66
 
65
67
  if (identifiers.length === 0) {
66
- throw new Error('No identifiers found in ' + path);
68
+ return false;
67
69
  } else if (identifiers.length > 1) {
68
70
  throw new Error('Multiple identifiers found in ' + path);
69
71
  }
@@ -120,6 +122,10 @@ module.exports = function (context) {
120
122
  return name;
121
123
  } else {
122
124
  var resolvedPath = resolve(path, opts);
125
+ if (resolvedPath === emptyModule) {
126
+ return false;
127
+ }
128
+
123
129
  file.metadata.required.push(resolvedPath);
124
130
 
125
131
  // Check if the path is under sourceRoot
@@ -155,6 +161,10 @@ module.exports = function (context) {
155
161
  }
156
162
 
157
163
  var name = resolveTarget(state.file, target);
164
+ if (name === false) {
165
+ path.get('init').replaceWith(t.objectExpression([]));
166
+ return;
167
+ }
158
168
  path.scope.rename(name);
159
169
  path.scope.rename(path.node.id.name, name);
160
170
  path.remove();
@@ -171,14 +181,18 @@ module.exports = function (context) {
171
181
 
172
182
  var replacement = resolveTarget(state.file, target);
173
183
  switch (path.parent.type) {
174
- case "ExpressionStatement":
175
- // We just need to know there's a dependency, we can remove it then
176
- path.remove();
177
- break;
178
- default:
179
- // Otherwise we just look for the module by referencing its Special Identifier™
184
+ case "ExpressionStatement":
185
+ // We just need to know there's a dependency, we can remove it then
186
+ path.remove();
187
+ break;
188
+ default:
189
+ // Otherwise we just look for the module by referencing its Special Identifier™
190
+ if (replacement === false) {
191
+ path.replaceWith(t.objectExpression([]));
192
+ } else {
180
193
  path.replaceWith(t.identifier(replacement));
181
- break;
194
+ }
195
+ break;
182
196
  }
183
197
  }
184
198
  };
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Commoner
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-commoner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bouke van der Bijl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-03 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets