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

[Bug] ssr + dompurify 报错 #5732

Closed
crazyair opened this issue Nov 25, 2020 · 5 comments
Closed

[Bug] ssr + dompurify 报错 #5732

crazyair opened this issue Nov 25, 2020 · 5 comments
Assignees
Labels

Comments

@crazyair
Copy link

What happens?

.umirc.js

  ssr: {},
  exportStatic: {},

index.tsx

import React from 'react';
// import { sanitize } from 'dompurify'; 
import { sanitize } from 'isomorphic-dompurify';
import styles from './index.less';

export default () => {
  return (
    <div>
      <h1 className={styles.title}>{sanitize('demo')}</h1>
    </div>
  );
};

使用 dompurify 会报错,

ERROR [SSR] /index.html TypeError: (void 0) is not a function

而是用支持服务端渲染的 isomorphic-dompurify 会报错

 ERROR  Failed to compile with 1 errors                                                                                                                                               1:59:57 PM

This dependency was not found:

* canvas in ./node_modules/jsdom/lib/jsdom/utils.js

To install it, you can run: npm install --save canvas

Mini Showcase Repository(REQUIRED)

Provide a mini GitHub repository which can reproduce the issue. Use yarn create @umijs/umi-app then upload to your GitHub

How To Reproduce

Steps to reproduce the behavior: 1. 2.

Expected behavior 1. 2.

Context

  • Umi Version:latest
  • Node Version:12
  • Platform:mac
@kkomelin
Copy link

Other people experience this issue as well jsdom/jsdom#3042

@crazyair
Copy link
Author

install canval


 ERROR  Failed to compile with 1 errors                                                                                                                                              10:08:39 AM

 error  in ./node_modules/canvas/build/Release/canvas.node

Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

demo:https://github.com/crazyair/umi-dompurify-demo

@crazyair
Copy link
Author

crazyair commented Dec 2, 2020

无人问津

@kkomelin
Copy link

kkomelin commented Dec 2, 2020

Привет @crazyair,

无人问津

Не согласен с вами. Мы работаем над этой проблемой kkomelin/isomorphic-dompurify#36

@ycjcl868 ycjcl868 self-assigned this Dec 14, 2020
@ycjcl868 ycjcl868 added the type(ssr) UmiJS SSR label Dec 14, 2020
@moshangqi
Copy link

install canval


 ERROR  Failed to compile with 1 errors                                                                                                                                              10:08:39 AM

 error  in ./node_modules/canvas/build/Release/canvas.node

Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

demo:https://github.com/crazyair/umi-dompurify-demo

请问下你这问题解决了吗

@sorrycc sorrycc closed this as completed Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants