将 react-admin 与 snowpack 一起使用

tha*_*.ts 8 javascript rollup reactjs react-admin snowpack

我想react-admin在一个项目中使用,snowpack但遇到以下错误

? snowpack failed to load node_modules/ra-core/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js
  'default' is not exported by node_modules/@sheerun/mutationobserver-shim/dist/mutationobserver.min.js, imported by node_modules/ra-core/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js
Run Code Online (Sandbox Code Playgroud)

我不确定这是一个错误react-admin还是它的依赖项之一,它可能可以通过更改配置来解决snowpack.config.json

繁殖步骤

使用Create Snowpack App初始化一个 Snowpack 项目

npx create-snowpack-app new-dir --template @snowpack/app-template-react --use-yarn
Run Code Online (Sandbox Code Playgroud)

添加包 react-admin

yarn add `react-admin`
Run Code Online (Sandbox Code Playgroud)

添加以下行 src/index.jsx

import { Admin } from 'react-admin'
Run Code Online (Sandbox Code Playgroud)

运行命令以启动应用程序

npm start
Run Code Online (Sandbox Code Playgroud)

会有一堆警告,如:

The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
Run Code Online (Sandbox Code Playgroud)
Conflicting namespaces: node_modules/ra-core/esm/i18n/index.js re-exports 'TranslationContext' from both node_modules/ra-core/esm/i18n/index.js and node_modules/ra-core/esm/i18n/TranslationContext.js (will be ignored)
Conflicting namespaces: node_modules/ra-core/node_modules/@testing-library/react/dist/@testing-library/react.esm.js re-exports 'fireEvent' from both node_modules/ra-core/node_modules/@testing-library/react/dist/@testing-library/react.esm.js and node_modules/ra-core/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js (will be ignored)
Run Code Online (Sandbox Code Playgroud)
Warning: 1+ circular dependencies found via "node_modules/ra-core/esm/actions/index.js"
Run Code Online (Sandbox Code Playgroud)

然后最后启动脚本以错误结束

? snowpack failed to load node_modules/ra-core/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js
  'default' is not exported by node_modules/@sheerun/mutationobserver-shim/dist/mutationobserver.min.js, imported by node_modules/ra-core/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js
Run Code Online (Sandbox Code Playgroud)