Skip to content

Commit

Permalink
fix: escape rollup external test items (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
katywings committed Jun 14, 2020
1 parent f4ab33d commit 2a667c7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
63 changes: 60 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"camelcase": "^5.3.1",
"cssnano": "^4.1.10",
"es6-promisify": "^6.0.1",
"escape-string-regexp": "^4.0.0",
"filesize": "^6.1.0",
"gzip-size": "^5.1.1",
"kleur": "^3.0.3",
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import json from '@rollup/plugin-json';
import logError from './log-error';
import { readFile, isDir, isFile, stdout, stderr, isTruthy } from './utils';
import camelCase from 'camelcase';
import escapeStringRegexp from 'escape-string-regexp';

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

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

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

const externalPredicate = new RegExp(`^(${external.join('|')})($|/)`);
const externalPredicate = new RegExp(
`^(${external.map(escapeStringRegexp).join('|')})($|/)`,
);
const externalTest =
external.length === 0 ? id => false : id => externalPredicate.test(id);

Expand Down

0 comments on commit 2a667c7

Please sign in to comment.