Skip to content

Allow npm: protocol imports from JavaScript & TypeScript data loaders #288

Open
@mbostock

Description

@mbostock

To further increase parity between JavaScript in Markdown and JavaScript in data loaders, we could add a loader that allows npm: protocol imports to be automatically loaded from jsDelivr, or we could resolve them to node_modules (just stripping the npm: prefix). For example, in npm-loader.js:

export function resolve(specifier, context, nextResolve) {
  return specifier.startsWith("npm:")
    ? {shortCircuit: true, url: `https://cdn.jsdelivr.net/npm/${specifier.slice("npm:".length)}/+esm`}
    : nextResolve(specifier, context);
}

And then adding additional args when running node for data loaders:

node --experimental-network-imports --loader ./npm-loader.js ./data.csv.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions