Skip to content

Silently fails with with subpath pattern maps #6

@Gozala

Description

@Gozala

Use of Subpath patterns in export maps seems to break ipjs bulid, which exits without reporting any errors and 0 exit code.

Some investigation uncovered that error is happening somewhere in file parse function

ipjs/src/package/file.js

Lines 36 to 65 in 2fca839

if (this.parsed) throw new Error(`Already parsed this file ${this.url}`)
this.onParse(this)
const data = await readFile(this.url)
const program = parse(data, { sourceType: 'module', ecmaVersion: 2020 })
const imports = []
for (let i = 0; i < program.body.length; i++) {
const node = program.body[i]
if (node.type === 'ImportDeclaration') {
imports.push(node.source.value)
}
}
dynamicImports(program).forEach(name => imports.push(name))
this.esm = generate(program, stropts)
this.imports = new Map()
for (const value of imports) {
if (value.startsWith('.')) {
const url = new URL(value, this.url)
this.imports.set(value, this.pkg.file(url))
} else {
this.imports.set(value, null)
}
}
await Promise.all([...this.imports.values()].filter(x => x))
this.onParsed(this)

Which I am guessing is due to the following line which does not seems to await on file(this, url, this.hooks).

file (url) {
const key = url.toString()
if (!this.files.has(key)) {
this.files.set(key, file(this, url, this.hooks))
}
return this.files.get(key)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions