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

Support React Native #468

Open
CoSNaYe opened this issue Oct 15, 2022 · 0 comments
Open

Support React Native #468

CoSNaYe opened this issue Oct 15, 2022 · 0 comments

Comments

@CoSNaYe
Copy link

CoSNaYe commented Oct 15, 2022

Description

Is it possible to make this great package support react-native runtime?

I've tried to integrate pollyjs with React Native runtime with below setups, but it failed.

import FetchAdapter from '@pollyjs/adapter-fetch';
import XHRAdapter from '@pollyjs/adapter-xhr';
import FSPersister from '@pollyjs/persister-fs';

Polly.register(FetchAdapter);
Polly.register(XHRAdapter);
Polly.register(FSPersister);

new Polly('<Recording Name>', {
  adapters: ['fetch', 'xhr'],
  persister: 'fs',
});

Error Message & Stack Trace

Error: Unable to resolve module http from ./node_modules/http-graceful-shutdown/lib/index.js: http could not be found within the project or in these directories:
  node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
   6 | //             |     _|
   7 | // -----------------------------------------------------------------------------
>  8 | // gracefully shuts downs http server
     |                           ^
   9 | // can be used with http, express, koa, ...
  10 | // (c) 2022 Sebastian Hildebrandt
  11 | // License: MIT
    at ModuleResolver.resolveDependency (/Users//developer/rn_app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:129:15)
    at DependencyGraph.resolveDependency (/Users//developer/rn_app/node_modules/metro/src/node-haste/DependencyGraph.js:288:43)
    at Object.resolve (/Users//developer/rn_app/node_modules/metro/src/lib/transformHelpers.js:129:24)
    at resolve (/Users//developer/rn_app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
    at /Users//developer/rn_app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/Users//developer/rn_app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
    at processModule (/Users//developer/rn_app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async addDependency (/Users//developer/rn_app/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)

Dependencies

Copy the @pollyjs dependencies from package.json:

{
    "@pollyjs/adapter-fetch": "^6.0.5",
    "@pollyjs/adapter-xhr": "^6.0.5",
    "@pollyjs/core": "^6.0.5",
    "@pollyjs/persister-fs": "^6.0.5",
}

Environment

Tell us which operating system you are using, as well as which versions of Node.js and npm/yarn. If applicable, include the browser and the corresponding version.

Run the following to get it quickly:

Node.js v16.14.0
darwin 21.5.0
yarn 1.22.18

"react": "17.0.2",
"react-native": "0.67.4",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant