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

Multiple declarations of "goog.string" with webpack and Soy #251

Closed
pipiobjo opened this issue Jul 26, 2017 · 5 comments
Closed

Multiple declarations of "goog.string" with webpack and Soy #251

pipiobjo opened this issue Jul 26, 2017 · 5 comments

Comments

@pipiobjo
Copy link

Hi,
I evaluating metaljs for our liferay project and we try to build liferay independent metal components.
And we struggling with placing multiple metal components on one page.

I get following error:

LoadingAnimator.js:7893 Uncaught Error: Namespace "goog.string" already declared. at Object.goog.provide (LoadingAnimator.js:7893) at LoadingAnimator.js:9817 at Object.<anonymous> (LoadingAnimator.js:12259) at Object.defineProperty.value (LoadingAnimator.js:12260) at __webpack_require__ (LoadingAnimator.js:21) at Object._typeof (LoadingAnimator.js:7329) at __webpack_require__ (LoadingAnimator.js:21) at Object.defineProperty.value (LoadingAnimator.js:62) at __webpack_require__ (LoadingAnimator.js:21) at Object.defineProperty.value (LoadingAnimator.js:41)

I started with the sample project from here https://github.com/metal/metal-examples/tree/master/custom-build/webpack

  • Define a second component
  • Importing them on the index.html and there is the error.

I provide a sample project for reproduction:
https://github.com/pipiobjo/metaljs-webpack

I didnt test if this also appears with other build mechanism.
If you need more information, I will try to help ;-)

@eduardolundgren
Copy link
Contributor

/cc @jbalsas @brunobasto

@jbalsas
Copy link
Contributor

jbalsas commented Jul 26, 2017

Hey @pipiobjo, both entries in your configuration Modal and LoadingAnimator are including IncrementalDOM in their bundles, which will cause the error you're seeing when loaded in the same page.

You should be able to either extract IncrementalDOM as a vendor bundle that can be shared, or build all the app together in just one bundle.

I'll work to provide a working scenario tomorrow morning, but maybe this can get you going.

@jbalsas
Copy link
Contributor

jbalsas commented Jul 27, 2017

Hey @pipiobjo, I've sent you a simple PR showing how to use the commonsChunk plugin to dedupe the IncrementalDOM dependency. Also, you can simply use metal-tools-soy to compile the soy files, which should make your build lighter 😉

Please, let us know if that works for you!

@brunobasto
Copy link

Hey @pipiobjo, did the solution provided by @jbalsas work?

@jbalsas
Copy link
Contributor

jbalsas commented Sep 4, 2017

Closing as we're using this across projects. Please, @pipiobjo, let us know if this didn't work for you so we can better help you with it!

@jbalsas jbalsas closed this as completed Sep 4, 2017
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

4 participants