Skip to content

Don't load transitive notebook modules if they aren't referenced #74

@mootari

Description

@mootari

Is your feature request related to a problem? Please describe.
The Observable compiler currently translates notebook imports to static import statements. This causes transitive notebook modules to be loaded even if no observed runtime variables depend on them.

Example:

import {samples} from "@mbostock/evenly-spaced-sampling"

will also load the notebook @observablehq/inputs, even though samples does not depend on any of its cells.

Authors will often import notebooks which are only used for documentation / demonstration purposes.

Describe the solution you'd like
Only load notebook modules if cells depend on them.

Describe alternatives you've considered
Notebooks can be loaded lazily by dynamically importing and instantiating them through a separate Runtime instance. However, these separate runtime modules cannot be integrated easily, and the separate d3-require instance can cause conflicts.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions