Skip to content

resolveDirectory fails for packages that specify an object in package.json browser field #9

@BigDataSamuli

Description

@BigDataSamuli

Hi,

Apparently some npm packages (e.g. asap) specify an object in package.json's browser field (see https://github.com/defunctzombie/package-browser-field-spec). This causes small to fail in the Resolve.resolveDirectory function as path.join throws

TypeError: Path must be a string. Received { './asap': './browser-asap.js',
  './asap.js': './browser-asap.js',
  './raw': './browser-raw.js',
  './raw.js': './browser-raw.js',
  './test/domain.js': './test/browser-domain.js' }
    at assertPath (path.js:7:11)
    at Object.join (path.js:468:7)
    ...

Maybe emit a warning and fall back to the main field in these cases, and/or allow selecting the preferred main file (e.g. main or browser)? Or implement the extended browser field spec.

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