{"id":19584838,"url":"https://github.com/flex-development/export-regex","last_synced_at":"2026-05-13T01:02:36.109Z","repository":{"id":65052031,"uuid":"581303582","full_name":"flex-development/export-regex","owner":"flex-development","description":"Export statement regex","archived":false,"fork":false,"pushed_at":"2024-04-23T14:46:36.000Z","size":3418,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-24T05:48:08.578Z","etag":null,"topics":["ecmascript","export","regex","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/flex-development/export-regex","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flex-development.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["flex-development"]}},"created_at":"2022-12-22T20:16:49.000Z","updated_at":"2024-05-07T22:48:23.000Z","dependencies_parsed_at":"2023-09-28T15:47:35.696Z","dependency_job_id":"4e65b3eb-8c04-40b1-8cf0-751bd5f0b773","html_url":"https://github.com/flex-development/export-regex","commit_stats":{"total_commits":112,"total_committers":2,"mean_commits":56.0,"dds":0.4285714285714286,"last_synced_commit":"b1b2741196a815e3c63f09c63b8b28490d0bc613"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/flex-development/export-regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fexport-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fexport-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fexport-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fexport-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flex-development","download_url":"https://codeload.github.com/flex-development/export-regex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fexport-regex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32963176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"ssl_error","status_checked_at":"2026-05-12T23:30:18.191Z","response_time":102,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecmascript","export","regex","typescript"],"created_at":"2024-11-11T07:50:17.510Z","updated_at":"2026-05-13T01:02:36.056Z","avatar_url":"https://github.com/flex-development.png","language":"TypeScript","funding_links":["https://github.com/sponsors/flex-development"],"categories":[],"sub_categories":[],"readme":"# export-regex\n\n[![github release](https://img.shields.io/github/v/release/flex-development/export-regex.svg?include_prereleases\u0026sort=semver)](https://github.com/flex-development/export-regex/releases/latest)\n[![npm](https://img.shields.io/npm/v/@flex-development/export-regex.svg)](https://npmjs.com/package/@flex-development/export-regex)\n[![codecov](https://codecov.io/github/flex-development/export-regex/branch/main/graph/badge.svg?token=f79rIEL1sK)](https://codecov.io/github/flex-development/export-regex)\n[![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)\n[![license](https://img.shields.io/github/license/flex-development/export-regex.svg)](LICENSE.md)\n[![conventional commits](https://img.shields.io/badge/-conventional%20commits-fe5196?logo=conventional-commits\u0026logoColor=ffffff)](https://conventionalcommits.org/)\n[![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript\u0026logoColor=ffffff)](https://typescriptlang.org/)\n[![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat\u0026logo=vitest\u0026logoColor=ffffff)](https://vitest.dev/)\n[![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat\u0026logo=yarn\u0026logoColor=ffffff)](https://yarnpkg.com/)\n\n`export` statement regex.\n\n## Contents\n\n- [What is this?](#what-is-this)\n- [When should I use this?](#when-should-i-use-this)\n- [Install](#install)\n- [Use](#use)\n- [API](#api)\n  - [`EXPORT_AGGREGATE_REGEX`](#export_aggregate_regex)\n  - [`EXPORT_DECLARATION_REGEX`](#export_declaration_regex)\n  - [`EXPORT_DEFAULT_REGEX`](#export_default_regex)\n  - [`EXPORT_LIST_REGEX`](#export_list_regex)\n- [Types](#types)\n- [Related](#related)\n- [Contribute](#contribute)\n\n## What is this?\n\nThis package contains regular expressions for matching [`export`][1] statements.\n\n## When should I use this?\n\nUse this package when you need to match `export` statements.\n\n**Note**:\n\n- Statements in docblock (`/** */`), multiline (`/* */`), and single-line (`//`) comments are ignored\n- Expressions are ECMAScript-compatible. They have **not** been tested with other flavors (PCRE, PCRE2, etc)\n\n## Install\n\nThis package is [ESM only][2].\n\n```sh\nyarn add @flex-development/export-regex\n```\n\nFrom Git:\n\n```sh\nyarn add @flex-development/export-regex@flex-development/export-regex\n```\n\n\u003cblockquote\u003e\n  \u003csmall\u003e\n    See \u003ca href='https://yarnpkg.com/features/protocols#git'\u003eGit - Protocols | Yarn\u003c/a\u003e\n    \u0026nbsp;for details on requesting a specific branch, commit, or tag.\n  \u003c/small\u003e\n\u003c/blockquote\u003e\n\n## Use\n\nSuppose we have the following module:\n\n```ts\nimport * as regexp from '@flex-development/export-regex'\nimport { at, omit, select, type Times } from '@flex-development/tutils'\nimport { dedent } from 'ts-dedent'\n\nconst code: Times\u003c4, string\u003e = [\n  dedent`\n    export { defineBuildConfig, type BuildConfig } from \"#src\"\n    export type {\n      JsonObject,\n      LiteralUnion,\n      Nullable\n    } from '@flex-development/tutils'\n    export * as constants from \"./constants\"\n    export * from './interfaces'\n  `,\n  dedent`\n    export const ESM_SYNTAX_REGEX: RegExp = /pattern/gm;\n    export declare const RESOLVE_EXTENSIONS: string[]\n    export enum Snack{}\n    export interface User {}\n    export class House {}\n    export declare abstract class House extends Building {}\n    export abstract class House {}\n    export async function run() {}\n    export function* foo() {}\n    export namespace Foo {}\n    export type Foo = 'foo'\n    export function functionName() {}\n    export class ClassName {}\n    export const { name1, name2: bar } = o;\n    export const [ name1, name2 ] = array;\n  `,\n  dedent`\n    export default function () {}\n    export default async function() {}\n    export default class {}\n\n    export default function functionName() {}\n    export default function* generatorName() {}\n    export default class ClassName {}\n    export default abstract class ClassName {}\n\n    export default async () =\u003e {}\n    export default () =\u003e {}\n    export default arg =\u003e {}\n\n    export default foo\n    export default 1 + 1;\n  `,\n  dedent`\n    export { defineBuildConfig, type BuildConfig }\n    export type {\n      JsonObject,\n      LiteralUnion,\n      Nullable\n    }\n  `\n]\n\nconst print = (matches: IterableIterator\u003cRegExpMatchArray\u003e): void =\u003e {\n  console.debug(select([...matches], null, match =\u003e omit(match, ['input'])))\n}\n\nprint(at(code, 0).matchAll(regexp.EXPORT_AGGREGATE_REGEX))\nprint(at(code, 1).matchAll(regexp.EXPORT_DECLARATION_REGEX))\nprint(at(code, 2).matchAll(regexp.EXPORT_DEFAULT_REGEX))\nprint(at(code, 3).matchAll(regexp.EXPORT_LIST_REGEX))\n```\n\n...running that yields:\n\n```zsh\n[\n  {\n    '0': 'export { defineBuildConfig, type BuildConfig } from \"#src\"',\n    '1': undefined,\n    '2': '{ defineBuildConfig, type BuildConfig }',\n    '3': '#src',\n    index: 0,\n    groups: [Object: null prototype] {\n      type: undefined,\n      exports: '{ defineBuildConfig, type BuildConfig }',\n      specifier: '#src'\n    }\n  },\n  {\n    '0': 'export type {\\n' +\n      '  JsonObject,\\n' +\n      '  LiteralUnion,\\n' +\n      '  Nullable\\n' +\n      \"} from '@flex-development/tutils'\",\n    '1': 'type',\n    '2': '{\\n  JsonObject,\\n  LiteralUnion,\\n  Nullable\\n}',\n    '3': '@flex-development/tutils',\n    index: 59,\n    groups: [Object: null prototype] {\n      type: 'type',\n      exports: '{\\n  JsonObject,\\n  LiteralUnion,\\n  Nullable\\n}',\n      specifier: '@flex-development/tutils'\n    }\n  },\n  {\n    '0': 'export * as constants from \"./constants\"',\n    '1': undefined,\n    '2': '* as constants',\n    '3': './constants',\n    index: 148,\n    groups: [Object: null prototype] {\n      type: undefined,\n      exports: '* as constants',\n      specifier: './constants'\n    }\n  },\n  {\n    '0': \"export * from './interfaces'\",\n    '1': undefined,\n    '2': '*',\n    '3': './interfaces',\n    index: 189,\n    groups: [Object: null prototype] {\n      type: undefined,\n      exports: '*',\n      specifier: './interfaces'\n    }\n  }\n]\n[\n  {\n    '0': 'export const ESM_SYNTAX_REGEX',\n    '1': undefined,\n    '2': 'const',\n    '3': 'ESM_SYNTAX_REGEX',\n    index: 0,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'const',\n      exports: 'ESM_SYNTAX_REGEX'\n    }\n  },\n  {\n    '0': 'export declare const RESOLVE_EXTENSIONS',\n    '1': 'declare',\n    '2': 'const',\n    '3': 'RESOLVE_EXTENSIONS',\n    index: 53,\n    groups: [Object: null prototype] {\n      modifiers: 'declare',\n      declaration: 'const',\n      exports: 'RESOLVE_EXTENSIONS'\n    }\n  },\n  {\n    '0': 'export enum Snack',\n    '1': undefined,\n    '2': 'enum',\n    '3': 'Snack',\n    index: 103,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'enum',\n      exports: 'Snack'\n    }\n  },\n  {\n    '0': 'export interface User',\n    '1': undefined,\n    '2': 'interface',\n    '3': 'User',\n    index: 123,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'interface',\n      exports: 'User'\n    }\n  },\n  {\n    '0': 'export class House',\n    '1': undefined,\n    '2': 'class',\n    '3': 'House',\n    index: 148,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'class',\n      exports: 'House'\n    }\n  },\n  {\n    '0': 'export declare abstract class House',\n    '1': 'declare abstract',\n    '2': 'class',\n    '3': 'House',\n    index: 170,\n    groups: [Object: null prototype] {\n      modifiers: 'declare abstract',\n      declaration: 'class',\n      exports: 'House'\n    }\n  },\n  {\n    '0': 'export abstract class House',\n    '1': 'abstract',\n    '2': 'class',\n    '3': 'House',\n    index: 226,\n    groups: [Object: null prototype] {\n      modifiers: 'abstract',\n      declaration: 'class',\n      exports: 'House'\n    }\n  },\n  {\n    '0': 'export async function run',\n    '1': 'async',\n    '2': 'function',\n    '3': 'run',\n    index: 257,\n    groups: [Object: null prototype] {\n      modifiers: 'async',\n      declaration: 'function',\n      exports: 'run'\n    }\n  },\n  {\n    '0': 'export function* foo',\n    '1': undefined,\n    '2': 'function*',\n    '3': 'foo',\n    index: 288,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'function*',\n      exports: 'foo'\n    }\n  },\n  {\n    '0': 'export namespace Foo',\n    '1': undefined,\n    '2': 'namespace',\n    '3': 'Foo',\n    index: 314,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'namespace',\n      exports: 'Foo'\n    }\n  },\n  {\n    '0': 'export type Foo',\n    '1': undefined,\n    '2': 'type',\n    '3': 'Foo',\n    index: 338,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'type',\n      exports: 'Foo'\n    }\n  },\n  {\n    '0': 'export function functionName',\n    '1': undefined,\n    '2': 'function',\n    '3': 'functionName',\n    index: 362,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'function',\n      exports: 'functionName'\n    }\n  },\n  {\n    '0': 'export class ClassName',\n    '1': undefined,\n    '2': 'class',\n    '3': 'ClassName',\n    index: 396,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'class',\n      exports: 'ClassName'\n    }\n  },\n  {\n    '0': 'export const { name1, name2: bar } = o',\n    '1': undefined,\n    '2': 'const',\n    '3': '{ name1, name2: bar }',\n    index: 422,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'const',\n      exports: '{ name1, name2: bar }'\n    }\n  },\n  {\n    '0': 'export const [ name1, name2 ] = array',\n    '1': undefined,\n    '2': 'const',\n    '3': '[ name1, name2 ]',\n    index: 462,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      declaration: 'const',\n      exports: '[ name1, name2 ]'\n    }\n  }\n]\n[\n  {\n    '0': 'export default function',\n    '1': undefined,\n    '2': 'function',\n    '3': undefined,\n    index: 0,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      kind: 'function',\n      exports: undefined\n    }\n  },\n  {\n    '0': 'export default async function',\n    '1': 'async',\n    '2': 'function',\n    '3': undefined,\n    index: 30,\n    groups: [Object: null prototype] {\n      modifiers: 'async',\n      kind: 'function',\n      exports: undefined\n    }\n  },\n  {\n    '0': 'export default class',\n    '1': undefined,\n    '2': 'class',\n    '3': undefined,\n    index: 65,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      kind: 'class',\n      exports: undefined\n    }\n  },\n  {\n    '0': 'export default function functionName',\n    '1': undefined,\n    '2': 'function',\n    '3': 'functionName',\n    index: 90,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      kind: 'function',\n      exports: 'functionName'\n    }\n  },\n  {\n    '0': 'export default function* generatorName',\n    '1': undefined,\n    '2': 'function*',\n    '3': 'generatorName',\n    index: 132,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      kind: 'function*',\n      exports: 'generatorName'\n    }\n  },\n  {\n    '0': 'export default class ClassName',\n    '1': undefined,\n    '2': 'class',\n    '3': 'ClassName',\n    index: 176,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      kind: 'class',\n      exports: 'ClassName'\n    }\n  },\n  {\n    '0': 'export default abstract class ClassName',\n    '1': 'abstract',\n    '2': 'class',\n    '3': 'ClassName',\n    index: 210,\n    groups: [Object: null prototype] {\n      modifiers: 'abstract',\n      kind: 'class',\n      exports: 'ClassName'\n    }\n  },\n  {\n    '0': 'export default async',\n    '1': 'async',\n    '2': undefined,\n    '3': undefined,\n    index: 254,\n    groups: [Object: null prototype] {\n      modifiers: 'async',\n      kind: undefined,\n      exports: undefined\n    }\n  },\n  {\n    '0': 'export default',\n    '1': undefined,\n    '2': undefined,\n    '3': undefined,\n    index: 284,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      kind: undefined,\n      exports: undefined\n    }\n  },\n  {\n    '0': 'export default',\n    '1': undefined,\n    '2': undefined,\n    '3': undefined,\n    index: 308,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      kind: undefined,\n      exports: undefined\n    }\n  },\n  {\n    '0': 'export default foo',\n    '1': undefined,\n    '2': undefined,\n    '3': 'foo',\n    index: 334,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      kind: undefined,\n      exports: 'foo'\n    }\n  },\n  {\n    '0': 'export default',\n    '1': undefined,\n    '2': undefined,\n    '3': undefined,\n    index: 353,\n    groups: [Object: null prototype] {\n      modifiers: undefined,\n      kind: undefined,\n      exports: undefined\n    }\n  }\n]\n[\n  {\n    '0': 'export { defineBuildConfig, type BuildConfig }',\n    '1': undefined,\n    '2': '{ defineBuildConfig, type BuildConfig }',\n    index: 0,\n    groups: [Object: null prototype] {\n      type: undefined,\n      exports: '{ defineBuildConfig, type BuildConfig }'\n    }\n  },\n  {\n    '0': 'export type {\\n  JsonObject,\\n  LiteralUnion,\\n  Nullable\\n}',\n    '1': 'type',\n    '2': '{\\n  JsonObject,\\n  LiteralUnion,\\n  Nullable\\n}',\n    index: 47,\n    groups: [Object: null prototype] {\n      type: 'type',\n      exports: '{\\n  JsonObject,\\n  LiteralUnion,\\n  Nullable\\n}'\n    }\n  }\n]\n```\n\n## API\n\nThis package exports the following identifiers:\n\n- [`EXPORT_AGGREGATE_REGEX`](#export_aggregate_regex)\n- [`EXPORT_DECLARATION_REGEX`](#export_declaration_regex)\n- [`EXPORT_DEFAULT_REGEX`](#export_default_regex)\n- [`EXPORT_LIST_REGEX`](#export_list_regex)\n\nThere is no default export.\n\n### `EXPORT_AGGREGATE_REGEX`\n\n- **Source**: [`src/export-aggregate.ts`](src/export-aggregate.ts)\n\nAggregate `export` statement regex. Ignores matches in comments.\n\n### `EXPORT_DECLARATION_REGEX`\n\n- **Source**: [`src/export-declaration.ts`](src/export-declaration.ts)\n\nDeclaration `export` statement regex. Ignores matches in comments.\n\n**Requires unicode support ([flag u][3])**.\n\n### `EXPORT_DEFAULT_REGEX`\n\n- **Source**: [`src/export-default.ts`](src/export-default.ts)\n\nDefault `export` statement regex. Ignores matches in comments.\n\nDeclaration bodies and expressions that are not identifiers are not captured.\n\n**Requires unicode support ([flag u][3])**.\n\n### `EXPORT_LIST_REGEX`\n\n- **Source**: [`src/export-list.ts`](src/export-list.ts)\n\nList `export` statement regex. Ignores matches in comments.\n\n## Types\n\nThis package is fully typed with [TypeScript][4].\n\n## Related\n\n- [`import-regex`][5] \u0026mdash; `import` statement regex\n\n## Contribute\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md).\n\n[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/export\n[2]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n[3]: https://javascript.info/regexp-unicode\n[4]: https://www.typescriptlang.org\n[5]: https://github.com/flex-development/import-regex\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Fexport-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflex-development%2Fexport-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Fexport-regex/lists"}