Skip to content

Commit 2a667c7

Browse files
authored
fix: escape rollup external test items (#650)
1 parent f4ab33d commit 2a667c7

File tree

3 files changed

+65
-4
lines changed

3 files changed

+65
-4
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"camelcase": "^5.3.1",
8787
"cssnano": "^4.1.10",
8888
"es6-promisify": "^6.0.1",
89+
"escape-string-regexp": "^4.0.0",
8990
"filesize": "^6.1.0",
9091
"gzip-size": "^5.1.1",
9192
"kleur": "^3.0.3",

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import json from '@rollup/plugin-json';
2121
import logError from './log-error';
2222
import { readFile, isDir, isFile, stdout, stderr, isTruthy } from './utils';
2323
import camelCase from 'camelcase';
24+
import escapeStringRegexp from 'escape-string-regexp';
2425

2526
const removeScope = name => name.replace(/^@.*\//, '');
2627

@@ -506,7 +507,9 @@ function createConfig(options, entry, format, writeMeta) {
506507

507508
const useTypescript = extname(entry) === '.ts' || extname(entry) === '.tsx';
508509

509-
const externalPredicate = new RegExp(`^(${external.join('|')})($|/)`);
510+
const externalPredicate = new RegExp(
511+
`^(${external.map(escapeStringRegexp).join('|')})($|/)`,
512+
);
510513
const externalTest =
511514
external.length === 0 ? id => false : id => externalPredicate.test(id);
512515

0 commit comments

Comments
 (0)