-
I'd like to write a shared scripts for some notebooks. Imagine the following:
<!doctype html>
<notebook theme="air">
<script id="1" type="module">
import { dummy } from '../dummy.js';
</script>
</notebook> and then the file: export const dummy = 'foo'; This code succeeds with both I didn't file it as an issue because 1) it's not an issue with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I think I've answered my own question with nothing fancier than a symbolic link to a shared lib/ directory. It seems to work with all the variants, e.g.: https://rreusser.github.io/notebooks/regl-canvas/ This also probably has a bit in common with resolving node modules, which I think I saw somewhere required instructing vite how to resolve them to the |
Beta Was this translation helpful? Give feedback.
-
As you surmised this design is for security purposes; you can only import files in the same directory as (or a subdirectory of) the current notebook. The same is true for file attachments. Apart from the symlink workaround, I was thinking that we might be able to use a project configuration file, say observable.config.js, in a parent directory to signify a project root. If this file isn’t present, the current limitations apply; but if it is found, then you can access any file in the project. The downside of this approach is that we’d have to crawl up the parent directories to look for said config file, and it’s possible that you might accidentally expose too much if you put a project config file in a silly place (such as your home directory). What do you think? |
Beta Was this translation helpful? Give feedback.
As you surmised this design is for security purposes; you can only import files in the same directory as (or a subdirectory of) the current notebook. The same is true for file attachments.
Apart from the symlink workaround, I was thinking that we might be able to use a project configuration file, say observable.config.js, in a parent directory to signify a project root. If this file isn’t present, the current limitations apply; but if it is found, then you can access any file in the project. The downside of this approach is that we’d have to crawl up the parent directories to look for said config file, and it’s possible that you might accidentally expose too much if you put a project conf…