Skip to content

Possibility to refer file-system from js-land ? #290

Answered by manzt
pnsvk asked this question in JavaScript
Discussion options

You must be logged in to vote

anywidget only supports a single local JavaScript entrypoint for _esm, and I'm not sure if we'll ever be able to support importing other ESM modules natively from the file system (within _esm). For example,

import { foo } from './bar.js';

export function render(view) {
  foo();
}

will not work. This is a technical limitation due to the way anywidget needs to load _esm in the front end.

In order to support local js libraries (not from a CDN), you'll need to bundle your source code into a single ES Module and load it in anywidget. We have have a section in our documentation on this subject, but it's a little out of date.

I would recommend using esbuild. You can install it globally with npm

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by manzt
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #78 on September 17, 2023 16:40.