Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

deps-regex

mathieudutour3mMIT0.2.0TypeScript support: included

Regular expression for matching javascript require/import statements.

exec, expression, expressions, find, match, matcher, matches, matching, module, modules, re, regex, regexp, regular, require, requires, statement, test

readme

deps-regex

Regular expression for matching javascript require/import statements.

This is pretty fragile and created for perf reasons where using a real parser would be overkill.

Install

Install with npm

npm install --save deps-regex

Usage

var DepsRegex = require("deps-regex");
var re = new DepsRegex({
  matchInternal: true,
  matchES6: true,
  matchCoffeescript: true,
});

re.getDependencies("var foo = require('bar');");
// => [ 'bar']

Known false positives

module.exports = 'require("false-positive");';

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running tests

Install dev dependencies:

npm install && npm test

License

Released under the MIT license.

changelog

Changelog

0.2.0

  • Include typescript definition