Replies: 2 comments 5 replies
-
Notebooks 2.0 supports Observable JavaScript as a cell mode (and you can import 1.0 notebooks as described in #9), so there’s no reason for you to convert your Observable JavaScript to vanilla JavaScript unless you want to. My opinion is that it’s generally better to convert Observable JavaScript to vanilla JavaScript by hand; you know best how to produce the most idiomatic result. For example, because 2.0 allows cells to declare multiple top-level variables, you often want to combine cells when converting from 1.0 to 2.0. Still, perhaps there’s an opportunity for the community to contribute codemods to automate or partially automate conversion. Here’s a draft of a guide I’ve been working on… Converting Observable JavaScript to vanilla JavaScriptThis guide covers how to convert from Observable JavaScript, the nonstandard syntax introduced with Observable Notebooks 1.0, to vanilla JavaScript, the standard syntax now supported by Observable Notebooks 2.0. (Observable Framework also uses vanilla JavaScript; you might also find Framework’s Converting notebooks guide helpful.) Note: you don’t have to convert to vanilla JavaScript! Observable JavaScript is still supported and should — with a few quirks — “just work.” That said, we highly recommend adopting vanilla JavaScript because it’s the standard. Vanilla JavaScript makes your code more easily understood by others. And vanilla JavaScript syntax allows cells to define multiple top-level variables (via standard Observable Notebooks 2.0 allows intermingling of Observable and vanilla JavaScript within the same notebook via cell modes. An Observable JavaScript cell is denoted by Remove cell declarations; replace
|
Beta Was this translation helpful? Give feedback.
-
Oh, also note that there was a bug where you couldn’t import a import {figure, viewof$rotation} from "observable:@rreusser/drawing-3d-objects-with-svg"; More in this thread: https://bsky.app/profile/ocks.org/post/3lvjhyimjuc2x |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When I use
notebooks download NOTEBOOK_URL
to download a notebook to my filesystem, it's downloading the Observable-flavored Javascript which the runtime in notebook-kit doesn't support (e.g.viewof
,import...with
,mutable
, and standard library). Shouldnotebooks download
handle the transpilation from OJS to vanilla JS? Are there currently any tools to do this?Beta Was this translation helpful? Give feedback.
All reactions