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

only one instance of babel-polyfill is allowed #7

Open
Gerst20051 opened this issue Sep 5, 2018 · 1 comment
Open

only one instance of babel-polyfill is allowed #7

Gerst20051 opened this issue Sep 5, 2018 · 1 comment

Comments

@Gerst20051
Copy link

Serverless plugin "serverless-dynalite" initialization errored: only one instance of babel-polyfill is allowed

@Gerst20051
Copy link
Author

Gerst20051 commented Jan 8, 2019

I'm writing this 4 months after looking through this issue so some things may be incorrect but want to write down my thoughts as I remember them...

I think the root cause is when multiple packages require the package require("babel-polyfill");.

The two packages in my case were serverless-dynalite and @serverless/platform-sdk.

This issue started popping up after serverless version 1.28.0 which started including the @serverless/platform-sdk dependency.

See here: serverless/serverless@v1.27.3...v1.28.0#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R95

Inside that dependency, you'll find the following line which also requires the package require("babel-polyfill");.

You can see that line in the @serverless/platform-sdk package here: https://github.com/serverless/platform-sdk/blob/master/src/index.js#L2-L5

if (!global._babelPolyfill) {
  require('babel-polyfill')
}

You can also see that line in the serverless-dynalite package here:

require("babel-polyfill");

require("babel-polyfill");

The major difference is that serverless-dynalite doesn't do the if (!global._babelPolyfill) { check.

THE FIX:

This issue was encountered in two different ways and it was fixed differently in both cases. You could also clone/fork this repo and add that check above that is missing.

The first was when running sls deploy in gitlab pipelines.

  • This was fixed by updating .gitlab-ci.yml to use the version of serverless from the project's node_modules folder by changing sls deploy to npm run sls deploy.

  • The command npm run sls references the script "sls": "npx serverless" in package.json.

  • The version of serverless didn't seem to make a difference in this instance since this is what was defined in the package.json "serverless": "^1.30.3",.

  • This might be because the serverless-dynalite module is included first or doesn't get bundled when deploying? Might be completely wrong on that though...

The second was when running serverless (npx serverless offline) locally.

  • The latest version of serverless that works is version "1.27.3".

  • There was an update mentioned above in version "1.28.0" that started causing this error. That update "broke" versions "1.28.0" through "1.30.3".

  • I haven't checked versions "1.30.3" through "1.35.1".

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