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

bug: TypeError: Failed to construct 'URL': Invalid base URL #28497

Closed
3 tasks done
muuvmuuv opened this issue Nov 9, 2023 · 4 comments
Closed
3 tasks done

bug: TypeError: Failed to construct 'URL': Invalid base URL #28497

muuvmuuv opened this issue Nov 9, 2023 · 4 comments
Labels

Comments

@muuvmuuv
Copy link

muuvmuuv commented Nov 9, 2023

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

When using Angular with esbuild (application or browser-esbuild) Ionicons are not shown but instead this error.

index.js:32 Uncaught TypeError: Failed to construct 'URL': Invalid base URL
    at getAssetPath (index.js:32:22)
    at getNamedUrl (icon.js:46:10)
    at getUrl2 (icon.js:27:12)
    at Icon2.loadIcon (icon.js:296:19)
    at icon.js:257:12
    at Icon2.waitUntilVisible (icon.js:291:7)
    at Icon2.connectedCallback (icon.js:255:10)
    at Icon2.connectedCallback (index.js:3115:43)
    at DefaultDomRenderer2.insertBefore (platform-browser.mjs:648:20)
    at nativeInsertBefore (core.mjs:8470:14)

I think this here is related but was for other frameworks #22924. It talks a lot about no dynamic require in ionicons but I could not find any relation to that in the docs nor to "enable" it.

Expected Behavior

No dynamic icon require.

Steps to Reproduce

  1. Create new app with ionic start
  2. Use Angular 16 or 17
  3. Use an ion-icon standalone component anywhere
  4. Use application builder (angular 17) or browser-esbuild

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 7.1.5 (/...../@ionic/cli)
Ionic Framework : @ionic/angular 7.5.4
@angular-devkit/build-angular : 17.0.0
@angular-devkit/schematics : 17.0.0
@angular/cli : 17.0.0
@ionic/angular-toolkit : 10.0.0

Capacitor:

Capacitor CLI : 5.5.1
@capacitor/android : 5.5.1
@capacitor/core : 5.5.1
@capacitor/ios : 5.5.1

Utility:

cordova-res : not installed globally
native-run : not installed globally

System:

NodeJS : v20.9.0 (/..../nodejs/20.9.0/bin/node)
npm : 10.1.0
OS : macOS

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Nov 9, 2023
@mamillastre
Copy link

I think it's because you do not import the icons with the new addIcons method. You can follow this guide: https://ionicframework.com/docs/angular/build-options#usage-with-standalone-based-applications

But with a manual import of the icons (to avoid to call the addIcons method), it does not work. I create a bug report for this specific error: ionic-team/ionicons#1302

@muuvmuuv
Copy link
Author

muuvmuuv commented Nov 9, 2023

Oh, I didn't know that, thanks I will try it out!

@muuvmuuv
Copy link
Author

muuvmuuv commented Nov 9, 2023

Ok this works but is not ideal since the name of the icon is coming from our backend so I need all available...

@muuvmuuv muuvmuuv closed this as completed Nov 9, 2023
Copy link

ionitron-bot bot commented Dec 9, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants