question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Ionic custom import paths fail in Stencil web app

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

I expect to be able to include ionic in my stencil web app but I have had to roll back ionic to version 6.0.14 instead of using the current latest 6.0.16 in order to not have the error throw.

When running stencil build he error thrown is:

[ WARN  ]  Bundling Warning UNRESOLVED_IMPORT
           '@utils/logging' is imported by ./node_modules/@ionic/core/dist/collection/components/datetime/datetime.js,
           but could not be resolved – treating it as an external dependency

Expected Behavior

I should be able to use the latest version of @ionic/core with stencil as my UI library.

Using stencil version 2.13.0 alongside @ionic/core version 6.0.14, the steps to reproduce the bug work just fine, without error.

Steps to Reproduce

  1. run npm init stencil and follow the steps to create your StencilJS project
  2. cd into your new project folder and then npm i @ionic/core
  3. add import @ionic/core to the global index.ts file
  4. try to run npm run build

If you try to run Stencil with the --prerender flag in order to generate static files, the build fails entirely instead of just warning as it fails to resolve the @utils/logging dependency.

Code Reproduction URL

No response

Ionic Info

I’m not running an ionic project but this is the output from npx ionic info for my setup:

[WARN] You are not in an Ionic project directory. Project context may be missing.

Ionic:

   Ionic CLI : 5.4.16

Utility:

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

System:

   NodeJS : v14.17.6
   npm    : 6.14.15
   OS     : Linux 5.13

Additional Information

I’m using stencil version 2.13.0 because later version of stencil fail to build for reasons relating to stencil typescript definitions.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sean-perkinscommented, Apr 12, 2022

This has been resolved with: https://github.com/ionic-team/ionic-framework/pull/25106 (forgot to mark it as resolved when I did the merge commit).

It will be available in the next release of Ionic.

Thanks!

1reaction
sean-perkinscommented, Apr 12, 2022

Awesome, thanks for the follow-up. I’ll open a PR for that fix. We added an internal tech debt task to investigate why custom alias imports aren’t working in external Stencil projects.

Read more comments on GitHub >

github_iconTop Results From Across the Web

StencilJS error with React output target - You may need an ...
I figured out what the issue. For some reason, the dist folder was not being generated for me every time I ran npm...
Read more >
Vue - Stencil.js
Stencil can generate Vue component wrappers for your web components. This allows your Stencil components to be used within a Vue 3 application....
Read more >
Asset path in React DS output - Stencil - Ionic Forum
I'm trying to import the generated React component in another project, which uses Next.js, but I'm finding that the getAssetPath() call to ...
Read more >
How to create a reusable Web Component with Stencil and ...
Publish this Web Component on NPM. Import it and use it in your Ionic 4 application. Enough talk, more code. Let's make this...
Read more >
@stencil/core | Yarn - Package Manager
@stencil/core. owner ionic-team1.8mMIT2.20.0TS vulns 0 vulnerabilities. A Compiler for Web Components and Progressive Web Apps.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found