Skip to content

Idea: Add Header to Identify imported names #156

@Jamesernator

Description

@Jamesernator

For libraries with large collections of functions it can be nice to import them in a single declaration e.g.

import { map, filter } from "./some-itertools.mjs"

// vs individual
import map from "some-itertools/map.mjs"
import filter from "some-itertools/filter.mjs"

However with the former this will fetch the entire library even if a lot of it is not used. Basically what would be nice is if there was an additional header that the server could choose to consider when serving a module e.g.

import { map, filter } from "./some-itertools.mjs"

could send an additional header:

Imported-Names: map, filter

which a smart server could choose to respond with only what's needed instead:

export function map() {
    ...
}

export function filter() {
    ...
}

or even respond more simply with something like:

export { map } from "./some-itertools/map.js"
export { filter } from "./some-itertools/filter.js"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions