Using modules

Open
#425 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, r
Domain
frontend, web-dev

Research direction

Compare the working live-server example with the htmlwidget rendered from the Rmd file using runtime: shiny. Start with /lib/library.min.js and inspect how the widget is included when rendered, focusing on why import.meta is treated outside a module. Done means identifying the rendering difference and documenting or implementing a reproducible resolution.

Written by the indexing model from the issue text.

Description

Perhaps this is just an instance of a larger issue, maybe related to #405 but not quite the same (I don't get the MIME type of "text/plain" error).

I am able to run my code with live-server without issue. I packaged it into an htmlwidget and tried to run it in an Rmd file with runtime: shiny. I get no output, and I get this in the console:

Uncaught SyntaxError: import.meta may only appear in a module

The import.meta does appear in my /lib/library.min.js file, but this error only happens when trying to render the htmlwidget.

Running the same code outside of the htmlwidgets context, i.e. having a js file with import Thing from "/some/lib.js;" and then <script type="module" src="/my-script.js"></script> in my index.html works perfectly using live-server.

I will be happy for even a high-level explanation of what might be going on here, or where to look for solutions.

Dominant language
R
Stars
801
Forks
202
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ramnathv/htmlwidgets

All issues in ramnathv/htmlwidgets

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.