RepoPilot

How is the function exported? Is it a default export or a named one?

About sindresorhus/escape-string-regexp · 2 messages · last activity 9/1/2026

Question

How is the function exported? Is it a default export or a named one?

RepoPilot

The function is a default export.

In [index.js:L1-L10], the module declares:

export default function escapeStringRegexp(string) {

This is confirmed in a few other places:

  • The package.json sets "exports": "./index.js" [package.json:L1-L40], and since "type": "module" is set, this is loaded as an ES module.
  • The TypeScript declaration file mirrors this with export default function escapeStringRegexp(string: string): string; [index.d.ts:L16-L17].
  • Usage in tests and docs consistently imports it as a default export, e.g. import escapeStringRegexp from './index.js'; [test.js:L2] and import escapeStringRegexp from './index.js'; [index.test-d.ts:L2], as well as in the README example import escapeStringRegexp from 'escape-string-regexp'; [readme.md:L16].

There is no named export alongside it — the single function is the module's only export, and consumers must import it as the default.

FOLLOW_UPS:

  • How does the escaping regex handle the hyphen character?
  • Why does the package require Node.js 12 or higher?
  • What does the RepoPilot "Stale" verdict imply here?

Public Q&A. Generated by RepoPilot from the actual source of sindresorhus/escape-string-regexp. AI answers can be incomplete or stale — verify before relying on them.