(Docs Update) Using .mjs assets requires explicit mimetype specification
@T4rk1n がすでに取り組んでいます。
2026年7月23日 から。
評価
この issue はまだ評価されていません。
説明
While changing my custom JavaScript files (.js) to modules (.mjs), the browser started complaining of not being able to import the JavaScript assets:
Loading module from “http://localhost/assets/my_js_file.mjs?m=timestamp” was blocked because of a disallowed MIME type (“text/plain”)
The error message holds a clue, but for the uninitiated this is still quite cryptic. After some sparring with the AI and an internet search I found a Dash Forum topic where I posted my issue.
The solution that makes the module files be accepted is to explicitly add the MIME type for module files (before starting the server).
import mimetypes
mimetypes.add_type("application/javascript", ".mjs")
@BSd3v was helpful in replying that this is expected behavior, while I was left confused that I could not find any reference to this requirement when using .mjs files, see the Dash docs on static assets.
So now stands the question: Is this indeed the expected solution? Why is this suggestion not readily found online? Even in the example of AnnMarie in the linked Dash Forum post, this MIME type definition is not used. If it is expected, should the docs include a hint to this requirement. Something like: "If the browser shows this error, then your Python doesn't correctly MIME type mjs files. Add this explicit definition to fix your system."
- 主要言語
- Python
- スター
- 24.4k
- フォーク
- 2.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 19
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
plotly/dash のほかの issue
-
good first issue P3 size: 1 task
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
enhancement P2 size: 5
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
-
enhancement P3 size: 10+
-
P2 size: 1 task
-
enhancement P3 size: 1
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
似ている issue
-
essnmx good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
-
[Feature] 奇物选择添加优先级 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
syfoud/Simulated_Scepter#174 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Giskard-AI/giskard-oss#2840 · コメント 1 件 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success オープンarea: repo bug perceived difficulty: 2
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
yeti-platform/yeti#1380 ·