sprockets-commoner 0.1.0 → 0.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a57316ae97d13d23f2f99b58b201059e5e9747f0
|
4
|
+
data.tar.gz: 0181f1332eb2186e3ead1d9ce0e667003515f918
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
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
|
-
|
194
|
+
}
|
195
|
+
break;
|
182
196
|
}
|
183
197
|
}
|
184
198
|
};
|
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.
|
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-
|
11
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|