diff --git a/src/syntax.ts b/src/syntax.ts index d823a01..05ecc17 100644 --- a/src/syntax.ts +++ b/src/syntax.ts @@ -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']) diff --git a/test/syntax.test.ts b/test/syntax.test.ts index fd2f6a4..a7da182 100644 --- a/test/syntax.test.ts +++ b/test/syntax.test.ts @@ -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 },