Socket
Socket
Sign inDemoInstall

publint

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

publint - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

12

lib/node.js

@@ -11,6 +11,12 @@ import path from 'node:path'

const pkgDir = options?.pkgDir ?? process.cwd()
const packedFiles = (await packlist({ path: pkgDir })).map((file) =>
path.join(pkgDir, file)
)
/** @type {string[] | undefined} */
let packedFiles
// only search for packed files if the consumer is not running on a virtual filesystem
if (options?.vfs == null) {
packedFiles = (await packlist({ path: pkgDir })).map((file) =>
path.join(pkgDir, file)
)
}
return _publint({

@@ -17,0 +23,0 @@ pkgDir,

{
"name": "publint",
"version": "0.2.0",
"version": "0.2.1",
"description": "Lint packaging errors",

@@ -5,0 +5,0 @@ "type": "module",

@@ -63,3 +63,7 @@ import {

} catch {
for (const ext of tryExtensions) {
for (let ext of tryExtensions) {
// remove duplicated slashes
if (ext[0] === '/' && path[path.length - 1] === '/') {
ext = ext.slice(1)
}
try {

@@ -325,3 +329,3 @@ const content = await vfs.readFile(path + ext)

const browserPath = vfs.pathJoin(pkgDir, fieldValue)
await readFile(browserPath, currentPath)
await readFile(browserPath, currentPath, ['.js', '/index.js'])
})

@@ -624,7 +628,40 @@ } else if (typeof fieldValue === 'object') {

)
// get the intended format from the conditions. yes, while the `import` condition can actually
// point to a CJS file, what we're checking here is the intent of the expected format.
// otherwise the package could currently have the wrong format (which we would emit a message above),
// but when we reach here, we don't want to base on that incorrect format.
const dtsExpectFormat = format === 'import' ? 'ESM' : 'CJS'
/** @type {'ESM' | 'CJS' | undefined} */
let dtsExpectFormat = undefined
// get the intended format from the conditions without types, e.g. if the adjacent file
// is a CJS file, despite resolving with the "import" condition, make sure the dts format
// is expected to be CJS too.
// only run this if not dual publish since we know dual publish should have both ESM and CJS
// versions of the dts file, and we don't need to be lenient.
// NOTE: could there be setups with CJS code and ESM types? seems a bit weird.
if (!result.dualPublish) {
const nonTypesResult = resolveExports(
exportsRootValue,
// @ts-expect-error till this day, ts still doesn't understand `filter(Boolean)`
[format, env].filter(Boolean),
exportsPath
)
if (nonTypesResult?.value) {
const nonTypesResolvedPath = vfs.pathJoin(
pkgDir,
nonTypesResult.value
)
if (await vfs.isPathExist(nonTypesResolvedPath)) {
dtsExpectFormat = await getFilePathFormat(
nonTypesResolvedPath,
vfs
)
}
}
}
// fallback if we can't determine the non types format, we base on the condition instead.
// NOTE: this favours "import" condition over "require" when the library doesn't dual publish
// because we run "import" first in the for loop.
if (dtsExpectFormat == null) {
dtsExpectFormat = format === 'import' ? 'ESM' : 'CJS'
}
if (dtsActualFormat !== dtsExpectFormat) {

@@ -631,0 +668,0 @@ messages.push({

@@ -367,4 +367,8 @@ /**

} else if (Array.isArray(exportsValue)) {
// prettier-ignore
return { value: exportsValue[0], path: currentPath, dualPublish: _metadata.dualPublish }
return resolveExports(
exportsValue[0],
conditions,
currentPath.concat('0'),
_metadata
)
}

@@ -371,0 +375,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc