Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shiny server does not allow local OJS/js module imports #653

Open
bjyberg opened this issue Feb 6, 2025 · 0 comments
Open

Shiny server does not allow local OJS/js module imports #653

bjyberg opened this issue Feb 6, 2025 · 0 comments

Comments

@bjyberg
Copy link

bjyberg commented Feb 6, 2025

Problem:
When trying to import a local module for OJS as outlined here when server: shiny, an error occurs and the module cannot be used. The module is found, otherwise the error will occur on initial build and the render will fail, but it is unable to be imported. This does not happen if the shiny server is not used. It would be useful to be able to store OJS code (such as functions that can make plots) as a .qmd module and import it into a quarto document running with a shiny server to feed in the data.

Currently this is the error that occurs:
Error: error loading dynamically imported module Loading module from “http://localhost:6366/square.js” was blocked because of a disallowed MIME type (“text/html”)

Minimal Example:

square.js:
export function square(x) { return x * x; }

This works:

---
title: "Module Import Test"
format: html
---

```{ojs}
//| echo: true
//| output: true

import { square } from "./square.js";
square(5);
```

This does not:

---
title: "Module Import Test"
format: html
server: shiny

---

```{ojs}
//| echo: true
//| output: true

import { square } from "./square.js" // This recieves an error and square is undefined. 
square(x) 
```

```{ojs}
x * x  // This code is able to run perfectly fine
```

```{r}
#| context: server
#| echo: true
x <- reactive(5)

ojs_define(x)
```

Environment Information
Quarto Version: 1.7.6
Browser: Firefox & Chrome
Shiny Version: 1.10.0
R Version: 4.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant