Skip to content

Commit

Permalink
Fixes #411
Browse files Browse the repository at this point in the history
Fix in index.js
Extra configuration on webpack.config.js to trip the error if not fied
  • Loading branch information
Satyam committed Jul 4, 2016
1 parent 566c0a2 commit 078029a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions resolvers/webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ exports.resolve = function (source, file, settings) {
log('Using config: ', webpackConfig)

// externals
if (findExternal(source, webpackConfig.externals)) return { found: true, path: null }
if (findExternal(source, webpackConfig.externals, path.dirname(file))) return { found: true, path: null }


// otherwise, resolve "normally"
Expand Down Expand Up @@ -154,7 +154,7 @@ function makeRootPlugin(name, root) {
}
/* eslint-enable */

function findExternal(source, externals) {
function findExternal(source, externals, context) {
if (!externals) return false

// string match
Expand All @@ -171,11 +171,11 @@ function findExternal(source, externals) {

if (typeof externals === 'function') {
var functionExternalFound = false
externals.call(null, null, source, function(err, value) {
externals.call(null, context, source, function(err, value) {
if (err) {
functionExternalFound = false
} else {
functionExternalFound = findExternal(source, value)
functionExternalFound = findExternal(source, value, context)
}
})
return functionExternalFound
Expand Down
2 changes: 1 addition & 1 deletion resolvers/webpack/test/files/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
{ 'jquery': 'jQuery' },
'bootstrap',
function (context, request, callback) {
if (request === 'underscore') {
if (request === 'underscore' && context.indexOf('/') !== -1) {
return callback(null, 'underscore');
};
callback();
Expand Down

0 comments on commit 078029a

Please sign in to comment.