Skip to content

Commit

Permalink
fix(findExports): detect async function
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 29, 2021
1 parent 243e6f0 commit 9fcc555
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/analyze.ts
Expand Up @@ -53,7 +53,7 @@ export interface DefaultExport extends ESMExport {
export const ESM_STATIC_IMPORT_RE = /^(?<=\s*)import\s*(["'\s]*(?<imports>[\w*${}\n\r\t, /]+)from\s*)?["']\s*(?<specifier>.*[@\w_-]+)\s*["'][^\n]*$/gm
export const DYNAMIC_IMPORT_RE = /import\s*\((?<expression>(?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gm

export const EXPORT_DECAL_RE = /\bexport\s+(?<declaration>(function|let|const|var|class))\s+(?<name>[\w$_]+)/g
export const EXPORT_DECAL_RE = /\bexport\s+(?<declaration>(async function|function|let|const|var|class))\s+(?<name>[\w$_]+)/g
const EXPORT_NAMED_RE = /\bexport\s+{(?<exports>[^}]+)}/g
const EXPORT_DEFAULT_RE = /\bexport\s+default\s+/g

Expand Down
2 changes: 1 addition & 1 deletion test/exports.test.mjs
Expand Up @@ -7,7 +7,7 @@ describe('findExports', () => {
'export const useD = () => { return \'d\' }': { name: 'useD', type: 'declaration' },
'export { useB, _useC as useC }': { names: ['useB', 'useC'], type: 'named' },
'export default foo': { type: 'default', name: 'default', names: ['default'] },
'export async function foo ()': { type: 'named', names: ['foo'] },
'export async function foo ()': { type: 'declaration', names: ['foo'] },
'export const $foo = () => {}': { type: 'declaration', names: ['$foo'] },
'export { foo as default }': { type: 'default', name: 'default', names: ['default'] }
}
Expand Down

0 comments on commit 9fcc555

Please sign in to comment.