Skip to content

Verify sourcemaps before publishing #372

@justingrant

Description

@justingrant

Description

np should warn users when they try to publish a sourcemap that points to source files that don't exist in the package being published.

Is the feature request related to a problem?

Lately I've been wasting a lot of time chasing down libraries that publish broken sourcemaps to npm, where "broken" means that the sourcemap's sources array includes paths to source files that are either not published or are published to different locations than what's specified in the sourcemap. There are two basic cases:

It would be very helpful for the ecosystem if publishing tools like np showed warnings if a sourcemap points to non-existent files.

Possible solution

A solution could be something like this:

  1. run npm pack to generate the tarball that would be published
  2. unpack that tarball
  3. Find all *.map files inside the package
  4. Pull out the sources array from each sourcemap
  5. For each path in sources, verify that that path (usually a relative path) is present in the package
  6. If not present, show a warning, e.g. WARN: sourcemap ${sourcemap file} references ${filePath} which does not exist. Please publish source folders for debugging!

Alternatives

  • Get npm publish to add this warning instead, which I think is the right long-term solution, but it might be helpful to first get it into a faster-evolving tool like np.

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