Skip to content

Commit 4d6413f

Browse files
Improve cjs syntax needles regex test (#9)
1 parent b3fe2b0 commit 4d6413f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mixed-format/loader.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ function containsCJS(source) {
2525
const src = '' + source;
2626

2727
// A realistic version of this loader would use a parser like Acorn to check for actual `module.exports` syntax
28-
if (src.match(/exports[\.( ?=)]/)) { return true };
28+
if ((/exports[\[\.( ?=)]/).test(src)) { return true };
2929

3030
if (
31-
src.match(/require\(/)
32-
&& !src.match(/createRequire\(/)
33-
) return true;
31+
(/require\(/).test(src)
32+
&& !(/createRequire\(/).test(src)
33+
) { return true; }
3434
}

0 commit comments

Comments
 (0)