quarto-dev / quarto-dev/quarto

Shiny server does not allow local OJS/js module imports

未关闭
#653 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
TypeScript
星标
645
派生
62
平均合并
17 小时 42 分钟
30 天内合并 PR
13

描述

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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

Reproduce the failure with square.js and the minimal Quarto document using server: shiny, comparing it with the working non-Shiny document. Start by tracing how the local JavaScript module is served during Shiny rendering; done means the local OJS import loads and square(5) works in the Shiny document without the MIME-type error.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, r
领域
backend, web-dev
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。