-
Notifications
You must be signed in to change notification settings - Fork 45
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
#node-web-compat missing upon execution #66
Comments
Thanks for reporting this! This is a bug (or at the very least a development opportunity) in jest. I've logged it here, would appreciate your +1 : jestjs/jest#12619 A fix, or better said: a workaround, is documented here: https://github.com/ottokruse/jest-subpath-import |
Thank you for the quick response. You're right. In my case the following mapping helped:
where Thank you for looking into it. |
hitting this error when trying to use the library in react native, is there anyway to work around it? |
@mtj8033 - what does react native use for a crypto library? My google searching just finds things that are years old like https://github.com/imchintan/react-native-crypto-js and https://github.com/tradle/react-native-crypto as ways to shim in the node API. Also, do you know if subpath imports work in react-native? |
Had a look into supporting React Native and made some progress with this metro config: module.exports = {
resolver: {
resolveRequest: (context, moduleName, platform, realModuleName) => {
// Specific redirect for #node-web-compat
if (moduleName === '#node-web-compat') {
return {
filePath: path.join(
path.resolve(context.originModulePath, '..'),
'./node-web-compat-web.js',
),
type: 'sourceFile',
};
}
// Forward everything else to the default resolver
return defaultResolver(
{
...context,
resolveRequest: null,
},
moduleName,
platform,
realModuleName,
);
},
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
}; However, now I run into another issue, as React Native does not support aws-jwt-verify/src/node-web-compat-web.ts Lines 89 to 90 in 6476a42
It would be great to hear your use case in React Native @mtj8033 , we need to judge whether React Native would maybe be worth further effort / support. |
For the record, after polyfilling |
Was able to get it working in a local emulator with the following metro.config.js file, the important part being the extraNodeModules configuration (or at least I think it's working): /**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
const rootDir = __dirname;
module.exports = {
resolver: {
extraNodeModules: {
"#node-web-compat": `${rootDir}/node_modules/aws-jwt-verify/dist/cjs/node-web-compat-web.js`,
},
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
}; Note I am also using the following package: |
@mtj8033 interestingly you point to The best solution might be to create a custom If feasible, it might be good to add such a RN compat implementation to this library, but it's not in the roadmap currently. |
Please move any further React Native talk to #73 |
the aws-jwt-verify module currently needs to be set to 2.1.3 vs. 3.x due to a awslabs/aws-jwt-verify#66 in how it jestjs/jest#12270. Until this is fixed upstream, avoid using the latest version.
In my case I had a similar issue while unit testing and downgrading from |
I've just pinned this issue. But the ball is in Jest's court. |
Should be solved in jest now: jestjs/jest#12270 (comment) |
thabks. it work for me |
Question
The library works as expected when testing with local Express server on localhost via HTTP. However, when attempting to use with
supertest
andjest
and my app server simulator (no changes in server implementation) I am getting an error:Tried to debug it, reinstall; checked and those modules are there. I am thinking might be something to do with
supertest
settings judging byhttps.js
but might be a coincidence.Test is simple:
Has anyone had similar issue before or saw anything like it?
Versions
Which version of
aws-jwt-verify
are you using?^3.0.0
Are you using the library in Node.js or in the Web browser?
NodeJS
If Node.js, which version of Node.js are you using? (Should be at least 14)
16..13.0
If using TypeScript, which version of TypeScript are you using? (Should be at least 4)
4.5.2
The text was updated successfully, but these errors were encountered: