-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-esm.mjs
More file actions
31 lines (26 loc) · 1.03 KB
/
test-esm.mjs
File metadata and controls
31 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* ESM Smoke Test - Verifies Node.js native ESM compatibility
* This should run without ERR_MODULE_NOT_FOUND errors
*/
console.log('Testing ESM imports...');
try {
// Test direct imports work without crashes
const { collectRoutes, generateDocsHtml } = await import('./dist/index.js');
console.log('✅ Successfully imported collectRoutes:', typeof collectRoutes);
console.log('✅ Successfully imported generateDocsHtml:', typeof generateDocsHtml);
// Verify they are the expected types
if (typeof collectRoutes !== 'function') {
throw new Error('collectRoutes should be a function');
}
if (typeof generateDocsHtml !== 'function') {
throw new Error('generateDocsHtml should be a function');
}
console.log('\n✅ ESM compatibility test PASSED');
console.log('All imports resolved correctly with .js extensions');
process.exit(0);
} catch (error) {
console.error('\n❌ ESM compatibility test FAILED');
console.error('Error:', error.message);
console.error('\nStack:', error.stack);
process.exit(1);
}