Skip to content

Commit e5bdbb8

Browse files
committed
Choose regex expression to replace require line based on whether strict flag used
1 parent 3b465ce commit e5bdbb8

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

tasks/partial_bundle.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ module.exports = function partialBundle(tasks, opts) {
3434
excludes.forEach(function(t) {
3535
var WHITESPACE_BEFORE = '\\s*';
3636
// remove require
37-
var newCode = partialIndex.replace(
38-
new RegExp(
39-
WHITESPACE_BEFORE +
40-
'require\\(\'\\./' + t + '\'\\),' + '|' +
41-
'require\\(\'\\.\\./src/traces/' + t + '/strict\'\\),',
42-
'g'), ''
43-
);
37+
const regEx = (strict) ?
38+
WHITESPACE_BEFORE + 'require\\(\'\\.\\./src/traces/' + t + '/strict\'\\),' :
39+
WHITESPACE_BEFORE + 'require\\(\'\\./' + t + '\'\\),';
40+
41+
var newCode = partialIndex.replace(new RegExp(regEx, 'g'), '');
4442

4543
// test removal
4644
if(newCode === partialIndex) {

0 commit comments

Comments
 (0)