lambdabaa / dav

WebDAV, CalDAV, and CardDAV client for nodejs and the browser.
Mozilla Public License 2.0
304 stars 71 forks source link

require() must have a single string literal argument / when using with React Native #123

Open edouardpagnier opened 6 years ago

edouardpagnier commented 6 years ago

Hello,

I just try to use dav.js in a React Native (0.50) project, and I got the following error when loading the bundle: error: bundling failed: Error: require() must have a single string literal argument: ./node_modules/dav/dav.js:3156 at pushDependency (./node_modules/metro-bundler/src/JSTransformer/worker/extract-dependencies.js:44:13) at CallExpression (./node_modules/metro-bundler/src/JSTransformer/worker/extract-dependencies.js:59:9) at NodePath._call (./node_modules/babel-traverse/lib/path/context.js:76:18) at NodePath.call (./node_modules/babel-traverse/lib/path/context.js:48:17) at NodePath.visit (./node_modules/babel-traverse/lib/path/context.js:105:12) at TraversalContext.visitQueue (./node_modules/babel-traverse/lib/context.js:150:16) at TraversalContext.visitSingle (./node_modules/babel-traverse/lib/context.js:108:19) at TraversalContext.visit (./node_modules/babel-traverse/lib/context.js:192:19) at Function.traverse.node (./node_modules/babel-traverse/lib/index.js:114:17)

This issue happened on other lib as well when used with React Native, like real for example: https://github.com/realm/realm-js/issues/1342

Thanks

designtesbrot commented 6 years ago

I can confirm this is still an issue. The cause seems to be https://github.com/lambdabaa/dav/blob/master/lib/xmlhttprequest.js#L9. @lambdabaa is tricking browserify here really required? This line knocks out packagers like haste/metro