Skip to content

Commit

Permalink
fix(detectSyntax): detect export class as esm syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jun 29, 2022
1 parent 83e976f commit 896c8a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/syntax.ts
Expand Up @@ -4,7 +4,7 @@ import { readPackageJSON } from 'pkg-types'
import { ResolveOptions, resolvePath } from './resolve'
import { isNodeBuiltin, getProtocol } from './utils'

const ESM_RE = /([\s;]|^)(import[\w,{}\s*]*from|import\s*['"*{]|export\b\s*(?:[*{]|default|type|function|const|var|let|async function)|import\.meta\b)/m
const ESM_RE = /([\s;]|^)(import[\w,{}\s*]*from|import\s*['"*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m

const BUILTIN_EXTENSIONS = new Set(['.mjs', '.cjs', '.node', '.wasm'])

Expand Down
1 change: 1 addition & 0 deletions test/syntax.test.ts
Expand Up @@ -20,6 +20,7 @@ const staticTests = {
'export const a = 1': { hasESM: true, hasCJS: false, isMixed: false },
'export function hi() {}': { hasESM: true, hasCJS: false, isMixed: false },
'export async function foo() {}': { hasESM: true, hasCJS: false, isMixed: false },
'export class': { hasESM: true, hasCJS: false, isMixed: false },
// CJS
'exports.c={}': { hasESM: false, hasCJS: true, isMixed: false },
'const b=true;module.exports={b};': { hasESM: false, hasCJS: true, isMixed: false },
Expand Down

0 comments on commit 896c8a7

Please sign in to comment.