Skip to content

Commit e27f77d

Browse files
author
benholloway
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents e929c24 + b1a2bc1 commit e27f77d

File tree

4 files changed

+71
-67
lines changed

4 files changed

+71
-67
lines changed

lib/build/browserify.js

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -286,44 +286,47 @@ module.exports = create;
286286
*/
287287
function requireTransform(allowBowerRelative, allowProjectRelative) {
288288
var BOWER = path.relative(process.cwd(), bowerDir.sync());
289-
return transformTools.makeRequireTransform('requireTransform', null, function transform(args, opts, done) {
289+
var transformOpts = {
290+
excludeExtensions: ['json'] // must exclude any extension that is not javascript once all transforms have run
291+
};
292+
return transformTools.makeRequireTransform('requireTransform', transformOpts, function transform(args, opts, done) {
290293

291294
// find the original path and transform it so log as it is not relative
292295
var original = args[0];
293-
var split = original.split(/[\\\/]/g); // keep delimiters
294-
var firstTerm = split.splice(0, 1).shift(); // remove the first term from the split
295-
var isTransform = (firstTerm.length) && !(/^\.{1,2}$/.test(firstTerm));
296+
var split = original.split(/[\\\/]/g); // keep delimiters
297+
var firstTerm = split.splice(0, 1).shift(); // remove the first term from the split
298+
var isTransform = (firstTerm.length) && !(/^\.{1,2}$/.test(firstTerm)); // must not be relative
296299

297300
// first valid result wins
298301
// if we are not transforming then we fall back to the original value
299302
var transformed = [
300303

301-
// current project
302-
isTransform && allowProjectRelative && function resolveProjectRelative() {
303-
var packageJson = require(path.resolve('package.json'));
304-
if ((typeof packageJson.name === 'string') && (packageJson.name === firstTerm)) {
305-
return slash(path.resolve(path.join.apply(path, split))); // full path to second term onwards
306-
}
307-
},
308-
309-
// bower project
310-
isTransform && allowBowerRelative && function resolveBowerRelative() {
311-
var partial = path.dirname(original);
312-
var directory = (partial !== '.') && path.resolve(path.join(BOWER, partial));
313-
var isFound = directory && fs.existsSync(directory) && fs.statSync(directory).isDirectory();
314-
if (isFound) {
315-
return slash(path.resolve(path.join(BOWER, original))); // path is within the bower directory
316-
}
317-
},
318-
319-
// fall back value
320-
original
321-
]
322-
.map(function (candidate) {
323-
return (typeof candidate === 'function') ? candidate() : candidate;
324-
})
325-
.filter(Boolean)
326-
.shift();
304+
// current project
305+
isTransform && allowProjectRelative && function resolveProjectRelative() {
306+
var packageJson = require(path.resolve('package.json'));
307+
if ((typeof packageJson.name === 'string') && (packageJson.name === firstTerm)) {
308+
return slash(path.resolve(path.join.apply(path, split))); // full path to second term onwards
309+
}
310+
},
311+
312+
// bower project
313+
isTransform && allowBowerRelative && function resolveBowerRelative() {
314+
var partial = path.dirname(original);
315+
var directory = (partial !== '.') && path.resolve(path.join(BOWER, partial));
316+
var isFound = directory && fs.existsSync(directory) && fs.statSync(directory).isDirectory();
317+
if (isFound) {
318+
return slash(path.resolve(path.join(BOWER, original))); // path is within the bower directory
319+
}
320+
},
321+
322+
// fallback value
323+
original
324+
]
325+
.map(function (candidate) {
326+
return (typeof candidate === 'function') ? candidate() : candidate;
327+
})
328+
.filter(Boolean)
329+
.shift();
327330

328331
// update
329332
done(null, 'require("' + transformed + '")');

npm-shrinkwrap.json

Lines changed: 34 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@
111111
"yargs": "latest"
112112
},
113113
"devDependencies": {
114-
"angularity-helloworld-es5": "angularity/angularity-helloworld-es5#ci-build-0.2.0-D",
115-
"angularity-todo-es5": "angularity/angularity-todo-es5#ci-build-0.2.0-D",
116-
"autodocs": "^0.6.5",
114+
"angularity-helloworld-es5": "angularity/angularity-helloworld-es5#ci-build-0.2.0-E",
115+
"angularity-todo-es5": "angularity/angularity-todo-es5#ci-build-0.2.0-E",
116+
"autodocs": "^0.6.8",
117117
"jasmine-diff-matchers": "~2.0.0",
118118
"jasmine-node": "2.0.0-beta4",
119119
"jshint-stylish": "^1.0.1",

tasks/javascript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function setUpTaskJavascript(context) {
221221
return [
222222
babelify.configure({ignore: /(?!)/}), // convert any es6 to es5 (degenerate regex)
223223
stringify({minify: false}), // allow import of html to a string
224-
ngInject(), // annotate dependencies for angular
224+
ngInject({filter: /\.(?!json)\w+$/}), // annotate dependencies for angular (everything except .json)
225225
isMinify && esmangleify() // minify
226226
].filter(Boolean);
227227
// TODO @bholloway fix stringify({ minify: true }) throwing error on badly formed html so that we can minify

0 commit comments

Comments
 (0)