diff --git a/src/services/map-tests.ts b/src/services/map-tests.ts index f30717ea..d2229e73 100644 --- a/src/services/map-tests.ts +++ b/src/services/map-tests.ts @@ -20,7 +20,11 @@ export const getDeepImports = (content: string): Set => { const lines = content.split('\n'); for (const line of lines) { - if (line.includes('import') || line.includes('require')) { + if ( + line.indexOf('import') !== -1 || + line.indexOf('require') !== -1 || + line.indexOf(' from ') !== -1 + ) { const path = line.match(/['"](\.{1,2}\/[^'"]+)['"]/); if (path) paths.add(normalizePath(path[1].replace(extFilter, ''))); diff --git a/test/unit/map-tests.test.ts b/test/unit/map-tests.test.ts index aa9171b2..974ef464 100644 --- a/test/unit/map-tests.test.ts +++ b/test/unit/map-tests.test.ts @@ -103,6 +103,20 @@ test(async () => { import './k'; import './l.js'; import('./m.js'); + import { + moduleA, + moduleB, + } from 'some-c'; + import { + moduleA, + moduleB, + } from './n.js'; + import '../../o.js'; + import { + moduleA, + moduleB, + } from '../p.js'; + import('../q.js'); ` ), new Set([ @@ -119,6 +133,10 @@ test(async () => { 'k', 'l', 'm', + 'n', + 'o', + 'p', + 'q', ]), 'import' ); @@ -141,6 +159,7 @@ test(async () => { require('./k'); require('./l.js'); require('./m.js').default; + const { some } = require('../../../n.mjs'); ` ), new Set([ @@ -157,6 +176,7 @@ test(async () => { 'k', 'l', 'm', + 'n', ]), 'require' );