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

Unable to bundle with rollup for Lambda deployment #1164

Closed
monken opened this issue May 9, 2020 · 11 comments
Closed

Unable to bundle with rollup for Lambda deployment #1164

monken opened this issue May 9, 2020 · 11 comments
Assignees
Labels
closed-for-staleness guidance General information and guidance, answers to FAQs, or recommended best practices/resources. High Priority

Comments

@monken
Copy link

monken commented May 9, 2020

Describe the bug
I'm trying to use rollup to create a deployable bundle for Lambda.

SDK version number
beta-5

Is the issue in the browser/Node.js?
Node.js

Details of the browser/Node.js version
12

To Reproduce (observed behavior)

git clone https://github.com/monken/js-sdk-v3-rollup
yarn
yarn rollup -c

Expected behavior
I expect rollup to find and resolve all dependencies.

Screenshots

./src/index.js → dist...
[!] Error: 'NodeHttpHandler' is not exported by node_modules/@aws-sdk/node-http-handler/build/index.js, imported by node_modules/@aws-sdk/client-sts/dist/es/runtimeConfig.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
@monken
Copy link
Author

monken commented May 9, 2020

Generally speaking it seems that some bundlers might have issues with the export * from syntax used in many places. Explicit exports seem to resolve this specific issue and make three-shaking more efficient.

@AllanZhengYP
Copy link
Contributor

Hi @monken

Can you elaborate which export * from exactly is causing this issue?

@AllanZhengYP AllanZhengYP added the guidance General information and guidance, answers to FAQs, or recommended best practices/resources. label May 13, 2020
@monken
Copy link
Author

monken commented May 14, 2020

The immediate export * from is defined in https://github.com/aws/aws-sdk-js-v3/blob/master/packages/node-http-handler/src/index.ts. Were you able to reproduce the issue with my test repo?

@trivikr
Copy link
Member

trivikr commented Jul 9, 2020

All AWS SDK v3 packages are exported as ESM in 1.0.0-gamma.3

However, a new error appears with rollup using @aws-sdk/client-sts@1.0.0-gamma.3

@aws-sdk/protocol-http (imported by node_modules/@aws-sdk/client-sts/dist/es/protocols/Aws_query.js)
[!] Error: 'parse' is not exported by node_modules/fast-xml-parser/src/parser.js, imported by node_modules/@aws-sdk/client-sts/dist/es/protocols/Aws_query.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules/@aws-sdk/client-sts/dist/es/protocols/Aws_query.js (4:9)

Code in https://github.com/trivikr/js-sdk-v3-rollup/tree/gamma

@andrefelipe
Copy link

Also getting the same error when bundling with Rollup. Any ideas on how to fix?

Error: 'parse' is not exported by node_modules/bowser/src/bowser.js, imported by node_modules/@aws-sdk/util-user-agent-browser/dist/es/index.js

@monken
Copy link
Author

monken commented Dec 30, 2020

I've since switched to https://esbuild.github.io/ which can deal with @AWS-SDK just fine (and is blazingly fast).

@trivikr
Copy link
Member

trivikr commented Mar 24, 2021

Revisiting this issue while examining xml-parser issues.

Tested rollup bundling with @aws-sdk/client-sts@3.9.0 in https://github.com/trivikr/js-sdk-v3-rollup/tree/test-3.9.0

The new error is due to v4 from uuid:

Error: 'v4' is not exported by node_modules/uuid/index.js, imported by node_modules/@aws-sdk/middleware-retry/dist/es/defaultStrategy.js
    at error (/Users/trivikr/workspace/js-sdk-v3-rollup/node_modules/rollup/dist/shared/rollup.js:161:30)
    at Module.error (/Users/trivikr/workspace/js-sdk-v3-rollup/node_modules/rollup/dist/shared/rollup.js:15027:16)

@thefat32
Copy link

Error when using @aws-sdk/client-lex-runtime-v2 in my lib and generating bundle using rollup

[build:bundles] [!] Error: 'parse' is not exported by node_modules\fast-xml-parser\src\parser.js, imported by node_modules\@aws-sdk\client-sts\dist\es\protocols\Aws_query.js
[build:bundles] https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
[build:bundles] node_modules\@aws-sdk\client-sts\dist\es\protocols\Aws_query.js (5:9)
[build:bundles] 3: import { expectNonNull as __expectNonNull, expectString as __expectString, extendedEncodeURIComponent as __extendedEncodeURIComponent, getValueFromTextNode as __getValueFromTextNode, parseRfc3339DateTime as __parseRf
c3339DateTime, strictParseInt32 as __strictParseInt32, } from "@aws-sdk/smithy-client";
[build:bundles] 4: import { decodeHTML } from "entities";
[build:bundles] 5: import { parse as xmlParse } from "fast-xml-parser";
[build:bundles]             ^
[build:bundles] 6: export var serializeAws_queryAssumeRoleCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
[build:bundles] 7:     var headers, body;
[build:bundles] Error: 'parse' is not exported by node_modules\fast-xml-parser\src\parser.js, imported by node_modules\@aws-sdk\client-sts\dist\es\protocols\Aws_query.js

@tbenbrahim
Copy link

using "@rollup/plugin-node-resolve": "^13.0.5",

src/lambda.ts → dist/debug/lambda.js, dist...
(!) `this` has been rewritten to `undefined`
https://rollupjs.org/guide/en/#error-this-is-undefined
node_modules\cronstrue\dist\cronstrue.js
 8:   else
 9:     root["cronstrue"] = factory();
10: })(typeof self !== 'undefined' ? self : this, function() {
                                            ^
11: return /******/ (function(modules) { // webpackBootstrap
12: /******/    // The module cache
[!] Error: 'parse' is not exported by node_modules\fast-xml-parser\src\parser.js, imported by node_modules\@aws-sdk\client-sts\dist\es\protocols\Aws_query.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules\@aws-sdk\client-sts\dist\es\protocols\Aws_query.js (5:9)

@github-actions
Copy link

github-actions bot commented Oct 4, 2022

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Oct 4, 2022
@github-actions github-actions bot closed this as completed Oct 9, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closed-for-staleness guidance General information and guidance, answers to FAQs, or recommended best practices/resources. High Priority
Projects
None yet
Development

No branches or pull requests

8 participants