Skip to content

CDN webpackJsonp function conflicts with existing webpackJsonp function #42

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

Closed
aputinski opened this issue Jun 7, 2017 · 5 comments · Fixed by #43
Closed

CDN webpackJsonp function conflicts with existing webpackJsonp function #42

aputinski opened this issue Jun 7, 2017 · 5 comments · Fixed by #43
Assignees

Comments

@aputinski
Copy link

aputinski commented Jun 7, 2017

[REQUIRED] Describe your environment

  • Operating System version: macOS 10.12
  • Firebase SDK version: 4.1.1 (CDN)
  • Firebase Product: all

[REQUIRED] Describe the problem

Steps to reproduce:

It appears that the client is bundled via webpack and uses the CommonsChunkPlugin. My code is also bundled via webpack uses the same plugin. As a result my code defines webpackJsonp on the window and then later when I load Firebase from the CDN it tries to use my webpackJsonp function which won't work because they are different bundles.

<!-- My Wepback bundles -->
<script src="/assets/bundle/common.js"></script>
<script src="/assets/bundle/app.js"></script>
<!-- Firebase -->
<!-- (throws an error) -->
<script src="https://www.gstatic.com/firebasejs/4.1.1/firebase.js"></script>

Firebase should change the name of the jsonp function used to something like webpackJsonpFirebase to avoid conflicts.

https://webpack.js.org/configuration/output/#output-jsonpfunction

This needs to be changed if multiple webpack runtimes (from different compilation) are used on the same webpage.

Relevant Code:

@google-oss-bot
Copy link
Contributor

Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.

@jshcrowthe
Copy link
Contributor

@aputinski Nice find on this and thanks for the issue! I have this fixed in #43

As a workaround in the meantime, if you are already creating a webpack build of your own, I'd encourage you to use the firebase NPM package.

e.g.

var firebase = require("firebase/app");
require("firebase/auth");
require("firebase/database");

// Leave out Storage
//require("firebase/storage");

var config = {
  // ...
};
firebase.initializeApp(config);

@aputinski
Copy link
Author

Thanks for the quick fix! I'm actually using the npm package — I just happened to stumble upon this issue when I was just testing something out.

@jshcrowthe
Copy link
Contributor

Ahh gotcha. Well thank you for pointing it out 👍. Glad it is fixed for users to come.

@rahul-winner
Copy link

I'm facing same issue but with my own projects. Both projects are bundles with webpack 3.x. When I try to load JS files of one project into other. I notice that child project tries to load bundle from 'webpackJsonp' set by parent project.

Could you please suggest how could I fix it? or if I could create custom name for function 'webpackJsonp' my child project.

Thanks a lot !

@firebase firebase locked and limited conversation to collaborators Oct 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants