我想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
我不确定这是一个错误react-admin
或其依赖项之一,它可能可以通过更改配置来解决snowpack.config.json
复制步骤
使用Create Snowpack App初始化一个 Snowpack 项目
npx create-snowpack-app new-dir --template @snowpack/app-template-react --use-yarn
添加包react-admin
yarn add `react-admin`
添加以下行src/index.jsx
import { Admin } from 'react-admin'
运行命令启动应用程序
npm start
会有一堆警告,如:
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
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)
Warning: 1+ circular dependencies found via "node_modules/ra-core/esm/actions/index.js"
然后最后启动脚本以错误结束
✖ 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