Skip to content

Inject require #274

@mootari

Description

@mootari

A fundamental limitation of d3-require in the context of Observable is that there can only be one require instance, because each instance needs to register its window.define.

There is currently no way to load a separate Runtime with an existing require instance without redefining the entire stdlib surface.

Why is this a problem?

Notebook imports within Observable are static imports, meaning that the module files will be loaded even if no cell uses them. Very often notebooks load additional utilities to enhance their documentation. These dependencies are usually not required to use a notebook's core exports.

As a workaround, a notebook dependency can be instantiated lazily through a second Runtime instance. However, this fails if the notebook contains any require calls, as the Runtime will load its own Library instance and require instance.

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