Проблема
В собственном веб-приложении React relay не работает на собственных целях ( babel.config. js не может найти модуль 'relay' ), но отлично работает с веб-целью. В чистой настройке приложения на основе реакции работают те же шаги установки. Не уверен, какой конфигурации мне не хватает.
Как воспроизвести
Первоначально проект был создан с помощью create-response-native-web-app это было очень просто.
На основе шагов установки relay https://relay.dev/docs/en/installation-and-setup Мне удалось заставить веб-сборку работать и получать данные из конечной точки graphql.
Когда я пытаюсь запустить сборку android, мне кажется, что в моей конфигурации чего-то не хватает. (Babel.config. js не может найти модуль relay)
Среда
babel.config. js
module.exports = api => {
api.cache(true);
return {
plugins: [
'relay',
'@babel/plugin-transform-runtime',
// '@babel/plugin-proposal-class-properties', // Breaks fast refresh on native for some reason, left here if needed
].map(require.resolve),
presets: ['module:metro-react-native-babel-preset'],
};
};
пакетов. json
{
"name": "creaternwapp",
"version": "0.1.0",
"private": true,
"scripts": {
"web": "react-app-rewired start",
"test:web": "react-app-rewired jest",
"chrome:debug": "./chrome.bat",
"build": "react-app-rewired build",
"start": "npm run web",
"start-clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm start -- --reset-cache",
"test": "npm run test:web && npm run test:native",
"android": "react-native run-android",
"android:release": "react-native run-android --variant release",
"ios": "react-native run-ios",
"ios-release": "react-native run-ios --configuration Release",
"test:native": "node_modules/.bin/jest -c ./config/jest/jest.config.native.js",
"update-schema:local": "npx ./node_modules/graphql-schema-cli --url=http://localhost:4000/graphql --path=./data/schema.graphql",
"relay": "relay-compiler --src ./src --schema ./data/schema.graphql --extensions js jsx tsx"
},
"dependencies": {
"@babel/core": "7.8.4",
"@svgr/webpack": "4.3.3",
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"babel-jest": "^24.9.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.6",
"babel-preset-react-app": "^9.1.1",
"camelcase": "^5.3.1",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"css-loader": "3.4.2",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"eslint": "^6.6.0",
"eslint-config-react-app": "^5.2.0",
"eslint-loader": "3.0.3",
"eslint-plugin-flowtype": "4.6.0",
"eslint-plugin-import": "2.20.0",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.18.0",
"eslint-plugin-react-hooks": "^1.6.1",
"file-loader": "4.3.0",
"fs-extra": "^8.1.0",
"html-webpack-plugin": "4.0.0-beta.11",
"identity-obj-proxy": "3.0.0",
"jest": "24.9.0",
"jest-environment-jsdom-fourteen": "1.0.1",
"jest-resolve": "24.9.0",
"jest-watch-typeahead": "0.4.2",
"mini-css-extract-plugin": "0.9.0",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.6.0",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"react": "^16.13.1",
"react-app-polyfill": "^1.0.6",
"react-dev-utils": "^10.2.0",
"react-dom": "^16.13.1",
"react-native": "0.61.5",
"react-native-elements": "^1.2.7",
"react-native-vector-icons": "^6.6.0",
"react-native-web": "^0.11.7",
"react-relay": "^9.1.0",
"react-scripts": "^3.4.1",
"resolve": "1.15.0",
"resolve-url-loader": "3.1.1",
"sass-loader": "8.0.2",
"semver": "6.3.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "2.3.4",
"ts-pnp": "1.1.5",
"url-loader": "2.3.0",
"webpack": "4.42.0",
"webpack-dev-server": "3.10.3",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "4.3.1"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^0.0.5",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.4",
"@types/react": "^16.9.34",
"@types/react-native": "^0.62.4",
"@types/react-relay": "^7.0.6",
"@types/react-test-renderer": "^16.9.2",
"@types/webpack": "^4.41.12",
"babel-eslint": "10.1.0",
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-relay": "^9.1.0",
"customize-cra": "^0.9.1",
"graphql": "^15.0.0",
"graphql-cli": "^3.0.14",
"graphql-schema-cli": "^1.0.2",
"metro-react-native-babel-preset": "^0.58.0",
"react-app-rewired": "^2.1.5",
"react-test-renderer": "16.9.0",
"relay-compiler": "^9.1.0",
"relay-compiler-language-typescript": "^12.0.1",
"relay-config": "^9.1.0",
"relay-test-utils": "^9.1.0",
"typescript": "^3.8.3"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"eslintConfig": {
"extends": "react-app"
},
"jest": {
"preset": "react-native-web",
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [
"<rootDir>/src/setupTests.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
}
}
введите описание изображения здесь