Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make custom extension name has higher priority. #1736

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ Browserify.prototype._createDeps = function (opts) {
// Let mdeps populate these values since it will be resolving file paths
// anyway.
mopts.expose = this._expose;
mopts.extensions = [ '.js', '.json' ].concat(mopts.extensions || []);
mopts.extensions = (mopts.extensions || []).concat([ '.js', '.json' ]);
self._extensions = mopts.extensions;

mopts.transform = [];
Expand Down
31 changes: 31 additions & 0 deletions test/custom_extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var browserify = require('../')
var tap = require('tap')

tap.test('default extension is js & json', function(t) {

var stub = browserify('')

t.plan(1)
t.same(stub._extensions, [
'.js',
'.json'
])

})

tap.test('custom extension is higher than js & json', function(t) {

var stub = browserify('', {
extensions: [
'.custom'
]
})

t.plan(1)
t.same(stub._extensions, [
'.custom',
'.js',
'.json'
])

})