microsoft / microsoft/BotFramework-WebChat

Vite: Warnings on console from renderMarkdown sanitize-html dependency

Open
#4,956 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bot Services bug customer-reported
Dominant language
HTML
Stars
1.8k
Forks
1.6k
Avg merge
22h 58m
Merged PRs (30d)
2

Description

Is it an issue related to Adaptive Cards?

No

Is this an accessibility issue?

No

What version of Web Chat are you using?

Latest production

Which distribution are you using Web Chat from?

NPM

Which hosting environment does this issue primarily affect?

Others or unrelated

Which browsers and platforms do the issue happened?

Others or unrelated

Which area does this issue affect?

Others or unrelated

What is the public URL for the website?

No response

Please describe the bug

Our project is a React SPA app and we use Vite (v4.4.4) for building. We use the default markdown which is exported as renderMarkdown botframework-webchat.
Running the application results to following warning on console:
Module <X> has been externalized for browser compatibility. Cannot access <X.Y> in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
Affected modules are:

  • path
  • fs
  • url
  • source-map-js
    All of these are originated from renderMarkdown.ts dependency of sanitize-html.
Do you see any errors in console log?
Only warnings
How to reproduce the issue?
  1. Create new project with Vite
  2. Install botframework-webchat from NPM
  3. Include in project and implement some chat using the default renderMarkdown function
  4. Run using npm run vite
    Our setup is this, but I would expect the warnings to appear with any usage of the function:
    import { createDirectLine, Components, renderMarkdown, } from 'botframework-webchat'
    <Components.Composer directLine={createDirectline({token:token})} renderMarkdown={renderMarkdown} >
    <Components.BasicWebChat/>
    </Components.Composer>
What do you expect?

No warnings

What actually happened?

Warnings as stated above

Do you have any screenshots or recordings to repro the issue?

image

Adaptive Card JSON

No response

Additional context

No response

Contributor guide

Open the contributing guide

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.

Research direction

Start with renderMarkdown.ts and trace its sanitize-html dependency as it is bundled by Vite. Reproduce the issue in a minimal Vite React app using the documented renderMarkdown import, then verify that the path, fs, url, and source-map-js browser warnings no longer appear.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript, vite
Domain
build-system, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.