Skip to content

Commit

Permalink
Fix check for unknown deps regex (#28366)
Browse files Browse the repository at this point in the history
* fix regex

* Small updates

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
  • Loading branch information
Enriqe and jridgewell committed May 13, 2020
1 parent 61a062b commit bc74e40
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions build-system/compile/check-for-unknown-deps.js
Expand Up @@ -20,24 +20,24 @@ const through = require('through2');
const {red, cyan, yellow} = require('ansi-colors');

/**
* Searches for the identifier "$$module$", which Closure uses to uniquely
* Searches for the identifier "module$", which Closure uses to uniquely
* reference module imports. If any are found, that means Closure couldn't
* import the module correctly.
*
* @return {!Stream}
*/
exports.checkForUnknownDeps = function () {
const regex = /[\w$]+?\$\$module\$[\w$]+/;
const regex = /[\w$]*module\$[\w$]+/;

return through.obj(function (file, encoding, cb) {
const contents = file.contents.toString();
if (!contents.includes('$$module$')) {
if (!contents.includes('module$')) {
// Fast check, since regexes can backtrack like crazy.
return cb(null, file);
}

const match = regex.exec(contents) || [
`couldn't parse the dep. Look for "$$module$" in the file`,
`couldn't parse the dep. Look for "module$" in the file`,
];

log(
Expand Down

0 comments on commit bc74e40

Please sign in to comment.