У меня есть проект в reactjs с использованием приложения create-react-App, и кто-то предоставил мне локальную библиотеку для установки в моем проекте, чтобы иметь общий компонент, которым мы делимся. Эта библиотека построена на базе create-react-library.
Когда я ее устанавливаю, все работает, кроме моих тестовых примеров. Вот ошибка.
23 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
24 |
> 25 | var React = require('react');
| ^
26 | var React__default = _interopDefault(React);
27 | var officeUiFabricReact = require('office-ui-fabric-react');
И мой пакет. json
{
"name": "presaletodelivery",
"version": "0.1.0",
"private": true,
"dependencies": {
"@uifabric/styling": "^7.12.16",
"axios": "^0.19.2",
"country-state-city": "^1.0.5",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"fetch-mock": "^7.3.9",
"node-fetch": "^2.6.0",
"node-sass": "^4.14.1",
"office-ui-fabric-core": "^11.0.0",
"office-ui-fabric-react": "^7.115.2",
"react": "^16.13.1",
"react-avatar-uploader": "^1.0.3",
"react-dom": "^16.13.1",
"react-redux": "^7.1.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"redux": "^4.0.4",
"redux-api-middleware": "^3.0.1",
"redux-logger": "^3.0.6",
"redux-mock-store": "^1.5.3",
"redux-promise": "^0.6.0",
"redux-thunk": "^2.3.0",
"styled-components": "^5.1.1"
},
"devDependencies": {
"babel-jest": "^24.9.0",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.4.0",
"jest-junit": "^6.3.0",
"react-test-renderer": "^16.9.0",
"local-lib": "../local-lib"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --coverage",
"eject": "react-scripts eject",
"coverage": "react-scripts test --coverage"
}
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx}",
"!coverage/**",
"!ptdui/node_modules/**",
"!src/index.js",
"!src/setupTests.js",
"!src/index.test.js",
"!src/App.test.js",
"!src/serviceWorker.js",
"!public/**",
"!build/**"
],
"coverageReporters": [
"text",
"lcov",
"json",
"text",
"clover"
]
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all",
"ie >= 9"
],
"development": [
"ie >= 9",
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Кто-нибудь сталкивался с этой проблемой раньше.