close
Skip to content

importing a js library fails in Jupyter Hub, works in Jupyter Lab #385

@mlamoureux

Description

@mlamoureux

I'm creating an "anywidget" to access some hardware devices known as "Phidgets."
This requires importing a library of js code in the _esm file for the anywidget.
My import statement works fine in Jupyter Lab, but not in Jupyter Hub (the classic Jupyter notebook).
My question is: what is the proper way to import a js module into the _esm file?

This statement works in Jupyter Lab, but not in Hub (i.e. not in classic notebook):
_esm = """
import "https://unpkg.com/phidget22/browser/phidget22";
....

I've also tried the following, based on the examples in the anywidget docs:
import * as phidget22 from "https://unpkg.com/phidget22/browser/phidget22"; or
import USBConnection from "https://unpkg.com/phidget22/browser/phidget22";

But they don't work at all. So, what is the right way to import?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions