sprockets-commoner 0.1.2 → 0.1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0f64fc540ae4a4e9d1e7113bebd91a5453598e7
|
4
|
+
data.tar.gz: 10254542506d4e61dc2f055b43951781c1601b15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52f46af8d4abb7b4b9241556217505a2ba5acc9f072ca09a0cb0a2f722fcace33a78e9531b7210e652d277669c877e384c797fb66a7ba3befef924f6a7cc066
|
7
|
+
data.tar.gz: 6dfd607e5b3593bd3c04d3d1e834a7d02e0611f6821f03af59a51db743ec42dd2b4554fb5bd4897d3e37a556a4d8e8777ce975ff68c698b3a30899c4f79ff4a3
|
@@ -116,7 +116,7 @@ module.exports = function (context) {
|
|
116
116
|
return '__commoner_module__' + escapedPath;
|
117
117
|
}
|
118
118
|
|
119
|
-
function resolveTarget(file, path) {
|
119
|
+
function resolveTarget(file, path, ensureTargetIsProcessed) {
|
120
120
|
var name = void 0;
|
121
121
|
if (opts.globals != null && (name = opts.globals[path]) != null) {
|
122
122
|
return name;
|
@@ -135,10 +135,13 @@ module.exports = function (context) {
|
|
135
135
|
}
|
136
136
|
|
137
137
|
if (/\.coffee$/.test(resolvedPath)) {
|
138
|
-
// If it's a coffee script file, look for global variable assignments
|
138
|
+
// If it's a coffee script file, look for global variable assignments.
|
139
139
|
return findDeclarationInCoffeeFile(resolvedPath);
|
140
140
|
} else {
|
141
|
-
|
141
|
+
if (ensureTargetIsProcessed) {
|
142
|
+
file.metadata.targetsToProcess.push(resolvedPath);
|
143
|
+
}
|
144
|
+
// Otherwise we just look for the module by referencing its Special Identifier™.
|
142
145
|
return pathToIdentifier(resolvedPath);
|
143
146
|
}
|
144
147
|
}
|
@@ -160,14 +163,14 @@ module.exports = function (context) {
|
|
160
163
|
return;
|
161
164
|
}
|
162
165
|
|
163
|
-
var name = resolveTarget(state.file, target);
|
166
|
+
var name = resolveTarget(state.file, target, true);
|
164
167
|
if (name === false) {
|
165
168
|
path.get('init').replaceWith(t.objectExpression([]));
|
166
|
-
|
169
|
+
} else {
|
170
|
+
path.scope.rename(name);
|
171
|
+
path.scope.rename(path.node.id.name, name);
|
172
|
+
path.remove();
|
167
173
|
}
|
168
|
-
path.scope.rename(name);
|
169
|
-
path.scope.rename(path.node.id.name, name);
|
170
|
-
path.remove();
|
171
174
|
},
|
172
175
|
CallExpression: function CallExpression(path, state) {
|
173
176
|
if (!isRequire(path)) {
|
@@ -179,14 +182,15 @@ module.exports = function (context) {
|
|
179
182
|
return;
|
180
183
|
}
|
181
184
|
|
182
|
-
var replacement = resolveTarget(state.file, target);
|
183
185
|
switch (path.parent.type) {
|
184
186
|
case "ExpressionStatement":
|
185
|
-
// We just need to know there's a dependency, we can remove
|
187
|
+
// We just need to know there's a dependency, we can remove the `require` call.
|
188
|
+
resolveTarget(state.file, target, false);
|
186
189
|
path.remove();
|
187
190
|
break;
|
188
191
|
default:
|
189
|
-
// Otherwise we just look for the module by referencing its Special Identifier
|
192
|
+
// Otherwise we just look for the module by referencing its Special Identifier™.
|
193
|
+
var replacement = resolveTarget(state.file, target, true);
|
190
194
|
if (replacement === false) {
|
191
195
|
path.replaceWith(t.objectExpression([]));
|
192
196
|
} else {
|
@@ -202,6 +206,9 @@ module.exports = function (context) {
|
|
202
206
|
if (file.metadata.required == null) {
|
203
207
|
file.metadata.required = [];
|
204
208
|
}
|
209
|
+
if (file.metadata.targetsToProcess == null) {
|
210
|
+
file.metadata.targetsToProcess = [];
|
211
|
+
}
|
205
212
|
},
|
206
213
|
|
207
214
|
visitor: {
|
@@ -70,11 +70,16 @@ module Sprockets
|
|
70
70
|
|
71
71
|
result = transform(input[:data], options(input), paths: @env.paths)
|
72
72
|
|
73
|
+
if result['metadata'].has_key?('targetsToProcess')
|
74
|
+
result['metadata']['targetsToProcess'].each do |t|
|
75
|
+
unless should_process?(t)
|
76
|
+
raise ExcludedFileError, "#{t} was imported from #{filename} but this file won't be processed by Sprockets::Commoner"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
73
81
|
if result['metadata'].has_key?('required')
|
74
82
|
result['metadata']['required'].each do |r|
|
75
|
-
unless COFFEE_EXTENSION =~ r || should_process?(r)
|
76
|
-
raise ExcludedFileError, "#{r} was imported from #{filename} but this file won't be processed by Sprockets::Commoner"
|
77
|
-
end
|
78
83
|
asset = resolve(r, accept: input[:content_type], pipeline: :self)
|
79
84
|
@required.insert(insertion_index, asset)
|
80
85
|
end
|