Skip to content

Commit ec6bedb

Browse files
feat: remove require (cjs) support for now
1 parent 1e97c7d commit ec6bedb

File tree

2 files changed

+1
-23
lines changed

2 files changed

+1
-23
lines changed

index.js

-12
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,7 @@ async function getChildrenModuleIds ({ id, alias }) {
9292
children = (await parse(cleanCodeForParsing(raw)))[0].map(i => i.n)
9393
}
9494

95-
try {
96-
children = children.concat(
97-
Array.from(raw.matchAll(/require\(['"](.+)['"]\)/gm)).map(
98-
([_, child]) => child
99-
)
100-
)
101-
} catch (e) {}
102-
10395
return children
104-
.reduce((_, child) => {
105-
// get unique children
106-
return _.includes(child) ? _ : _.concat(child)
107-
}, [])
10896
.map(moduleId => {
10997
const req = createRequire(id)
11098
let resolved

test/index.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ test('constructs valid tree', async () => {
7676
a_a: {
7777
url: './valid/a_a.js',
7878
content: `
79-
const a_a_a = require('./a_a_a')
80-
const a_a_b = require('./a_a_b') // multiline
79+
import a_a_a from './a_a_a'
8180
export default ''
8281
`
8382
},
@@ -87,12 +86,6 @@ test('constructs valid tree', async () => {
8786
export default ''
8887
`
8988
},
90-
a_a_b: {
91-
url: './valid/a_a_b.js',
92-
content: `
93-
module.exports = ''
94-
`
95-
},
9689
a_b: {
9790
url: './valid/a_b.js',
9891
content: `
@@ -122,9 +115,6 @@ test('constructs valid tree', async () => {
122115
assert(
123116
tree[fsx.files.a_a].childrenPointers.includes(tree[fsx.files.a_a_a].pointer)
124117
)
125-
assert(
126-
tree[fsx.files.a_a].childrenPointers.includes(tree[fsx.files.a_a_b].pointer)
127-
)
128118

129119
// parents
130120
assert(tree[fsx.files.a_a].parentPointers.includes(tree[fsx.files.a].pointer))

0 commit comments

Comments
 (0)