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

Duplicate export in strange package 'aws-sign2' #1556

Closed
aschrijver opened this issue Aug 16, 2017 · 1 comment
Closed

Duplicate export in strange package 'aws-sign2' #1556

aschrijver opened this issue Aug 16, 2017 · 1 comment

Comments

@aschrijver
Copy link

aschrijver commented Aug 16, 2017

I am trying to bundle 'node_modules' but get stuck on package aws-sign2 ((0.6.0) because it has a strange way of exporting the same module twice. (I didn't even know it was legal, maybe it is not).

rollup -c leads to error: Error: Duplicate export 'queryStringToSign'

I have created a repo to reproduce: https://github.com/aschrijver/dat

git clone https://github.com/aschrijver/dat
npm install
npm run rollup

(Related info: https://stackoverflow.com/questions/45707711/does-rollup-bundle-node-modules-into-bundle-js)

Stacktrace
11:13 $ rollup -c

index.js → bundle.js...
[!] Error: Duplicate export 'queryStringToSign'
node_modules/aws-sign2/index.js (224:32)
222: export { signQuery_1 as signQuery };
223: export { queryStringToSign_1 as queryStringToSign };
224: export { queryStringToSign_2 as queryStringToSign };
                                     ^
225: export { canonicalizeHeaders_1 as canonicalizeHeaders };
226: export { canonicalizeResource_1 as canonicalizeResource };
Strange dual export in 'aws-sign2')
/**
 * Return a string for sign() with the given `options`.
 *
 * Spec:
 * 
 *    <verb>\n
 *    <md5>\n
 *    <content-type>\n
 *    <date>\n
 *    [headers\n]
 *    <resource>
 *
 * @param {Object} options
 * @return {String}
 * @api private
 */

function stringToSign (options) {
  var headers = options.amazonHeaders || ''
  if (headers) headers += '\n'
  var r = 
    [ options.verb
    , options.md5
    , options.contentType
    , options.date ? options.date.toUTCString() : ''
    , headers + options.resource
    ]
  return r.join('\n')
}
module.exports.queryStringToSign = stringToSign

/**
 * Return a string for sign() with the given `options`, but is meant exclusively
 * for S3 presigned URLs
 *
 * Spec:
 * 
 *    <date>\n
 *    <resource>
 *
 * @param {Object} options
 * @return {String}
 * @api private
 */

function queryStringToSign (options){
  return 'GET\n\n\n' + options.date + '\n' + options.resource
}
module.exports.queryStringToSign = queryStringToSign

Is this a case that should be handled, or a bug in 'aws-sign2' that I should address?

@aschrijver
Copy link
Author

This is not a rollup issue. Found this commit that corrects duplicate export (thanks @robertklep): request/aws-sign@03755f2 and request/request#2483

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