Skip to content

Commit

Permalink
fix(api/commonjs/package.js): ensure package type is correctly derived
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed Apr 23, 2024
1 parent ebfd804 commit 9b71319
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/commonjs/package.js
Expand Up @@ -883,19 +883,24 @@ export class Package {
}
}

if (info.main && !info.module) {
this.#type = 'commonjs'
}

if (info.main) {
this.#exports['.'].require = info.main
if (info.type === 'module') {
this.#exports['.'].import = info.main
}
}

if (info.module) {
if (info.module && !info.main) {
this.#exports['.'].import = info.module
this.#type = 'module'
}

if (typeof info.exports === 'string') {
if (type === 'commonjs') {
if (this.#type === 'commonjs') {
this.#exports['.'].require = info.exports
} else if (type === 'module') {
this.#exports['.'].import = info.exports
Expand Down

0 comments on commit 9b71319

Please sign in to comment.