Socket
Socket
Sign inDemoInstall

@visx/vendor

Package Overview
Dependencies
22
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @visx/vendor

vendored packages for visx


Version published
Maintainers
4
Install size
2.13 MB
Created

Changelog

Source

v3.5.0 (2023-11-13)

:rocket: Enhancements
  • new(geo, vendor): add d3-geo@3 to visx-vendor, support geoPath.digits(n) #1767

:memo: Documentation

  • Add to "In the wild" #1765
:trophy: Contributors

Readme

Source

@visx/vendor

This package consists of vendored packages for other visx packages. It is meant to enable dual support for export of CommonJS and ESM formats by re-exporting some visx dependencies, and even some transitive dependencies, which are ESM-only.

This package is heavily based off of victory-vendor which aims to solve the same problem.

Vendored packages

All vendored packages are listed as dependencies in the package.json of this package (note that the yarn nohoist option is set for this package to guarantee version specificity in this large monorepo where we may have mixed versions of d3 packages). For each (non-types) package <pkg>, we generate the following:

  • an ESM version of the package in esm/<pkg>.js
  • a CJS version of the package in lib/<pkg>.js
    • this points to the fully-transpiled version of the package in vendor-cjs/vendor-<pkg>/src/index.js
    • vendor-cjs/vendor-<pkg>/LICENSE contains the upstream license of the vendored package
    • other ESM-only packages (e.g., <pkg2>) that are referenced by <pkg> are updated to point to vendor-cjs/vendor-<pkg2>/src/index.js
  • TypeScript types from @types/<pkg> as root <pkg>.d.ts files (when available as specified in the package.json dependencies)
  • a root <pkg>.js file (pointing to the CJS version of the lib) for tooling that doesn't yet support package.json:exports (conditional exports)

How it works

We provide two alternate paths and behaviors -- for ESM and CommonJS

ESM

When you use a module import syntax like the following, it will resolve to a re-exported version of node_modules/d3-interpolate, the unmodified ESM library from D3.

import { interpolate } from '@visx/vendor/d3-interpolate';

CommonJS

If you use a CJS require syntax like the following, it will resolve to an alternate path that contains the transpiled version of the underlying d3-* (or other) library to be found at @visx/vendor/vendor-cjs/d3-interpolate/**/*.js.

const { interpolate } = require('@visx/vendor/d3-interpolate');

Such transpiled versions have internally consistent import references to other other @visx/vendor/vendor-cjs/<pkg-name> paths that need to be transpiled.

Root index files & types

For tooling that doesn't yet support package.json:exports (conditional exports), we include root index files for all vendored packages, e.g., @visx/vendor/d3-array.js.

Type declaration files are also included in the root, e.g., @types/d3-array is exported as @visx/vendor/d3-array.d.ts.

Keywords

FAQs

Last updated on 13 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc