You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current behavior:
I tried to upgrade to the latest version of Stencil however I'm getting the following error:
[ ERROR ] Rollup: Missing Export: ./src/components/accordion/accordion.tsx:2:20
'Element' is not exported by ./node_modules/@stencil/core/internal/client/index.mjs?app-data=conditional,
imported by ./src/components/accordion/accordion.tsx
L1: import {
L2: Component, Element, Event, EventEmitter, forceUpdate, h, JSX, Method
L3: } from '@stencil/core';
[23:22.4] build failed, watching for changes... in 8.68 s
Expected behavior:
I'm upgrading from stencil @1.9.2 where everything worked just fine. It seems like I can only upgrade to stencil @1.13.0 where everything works, but as soon as I jump to v1.14 or higher then I get this error saying that Element is no longer exported.
Steps to reproduce:
To reproduce,
import { Element } from '@stencil/core'
Reacted by Réda Housni Alaoui, Valentin Mirchev, Wang Weihua and David H
Sorry it took me so long to come back around to this, but I solved my issue, it looks like someone had used Event as a constructor in a file somewhere, and this really confused roll up.
// Offending code example
this.textarea.dispatchEvent(new Event('input));
Not entirely sure how it was slipped into the code base, but cleaning that up fixed my issue
It is strange because I have a bunch of stencil components that use:
import { Element } from '@stencil/core'
but only the first component is failing.... If I add the workaround code shown above to the first component file, then everything works, and I don't have to change any of the Element imports in any of my other component files.
Rollup: Missing Export: ./src/global/store.ts:7:9
'Event' is not exported by ./node_modules/@stencil/core/internal/client/index.js?app-data=conditional,
imported by ./src/global/store.ts
Sorry it took me so long to come back around to this, but I solved my issue, it looks like someone had used Event as a constructor in a file somewhere, and this really confused roll up.
// Offending code example
this.textarea.dispatchEvent(new Event('input));
Not entirely sure how it was slipped into the code base, but cleaning that up fixed my issue
This is indeed the cause of this error, at least in every case I've seen it. A workaround is posted above but another one is to rename the import:
Using an import alias import { Event as ComponentEvent } from '@stencil/core' causes:
[51:56.4] generate custom elements bundle finished in 8.61 s
[ ERROR ] Rollup: Missing Export: ./src/components/button/button.tsx:12:29
'Event' is not exported by
./node_modules/@stencil/core/internal/client/index.js?app-data=conditional, imported by
./src/components/button/button.tsx
[51:56.4] build failed in 11.21 s
Rollup: Missing Export: ./src/components/tree-item.tsx:7:25
'Element' is not exported by
./node_modules/@stencil/core/internal/client/index.js?app-data=conditional, imported by
./src/components/tree/tree-item.tsx
Still ran into this. I wonder why this has been closed …
However, I found a workaround:
/**
* Workaround to allow for Stencil `Element` decorator usage while still having access to the DOM Element type.
*/
export const DOMElement = Element;
export interface DOMElement extends Element {}
Simply import these from anywhere in your app. Then use DOMElement instead of Element. (except for the actual @element() decorator usage ofc.)
Activity
Trendy commentedon Jul 9, 2020
I'm experiencing a similar issue, but with
Eventinstead ofElement. It started happening after upgrading from 1.12.2chrisweight commentedon Jul 16, 2020
I'm having exactly the same issue with
Eventon1.16.2- I'm guessing this is down to the rollup dependency bump to 2.xvalentinmirchev commentedon Jul 24, 2020
I'm experiencing the same
Eventproblem with version 1.16.5Trendy commentedon Aug 12, 2020
Sorry it took me so long to come back around to this, but I solved my issue, it looks like someone had used
Eventas a constructor in a file somewhere, and this really confused roll up.Not entirely sure how it was slipped into the code base, but cleaning that up fixed my issue
mmakrzem commentedon Sep 9, 2020
My workaround to the problem is to remove 'Element' from the import statement and instead add the following to the source code where the import fails:
mmakrzem commentedon Sep 9, 2020
It is strange because I have a bunch of stencil components that use:
but only the first component is failing.... If I add the workaround code shown above to the first component file, then everything works, and I don't have to change any of the Element imports in any of my other component files.
adrian2x commentedon Sep 13, 2020
I'm getting that same error with Event on 2.0.3:
Krzyrok commentedon Nov 24, 2020
#2563 (comment)
On [email protected] I had the same issue with error when importing Event decorator. The reason in my case was rename during import:
Removing this rename solved the issue:
(but I cannot use
Eventfrom global typings in the same file now...)claviska commentedon Nov 24, 2020
This is indeed the cause of this error, at least in every case I've seen it. A workaround is posted above but another one is to rename the import:
dougestey commentedon Nov 30, 2020
I am still experiencing this issue.
Using an import alias
import { Event as ComponentEvent } from '@stencil/core'causes:Stencil version 2.3.0.
lufonius commentedon May 20, 2021
this error is shown to me when i change the srcDir option in the config to anything else than src.
stencil version: 2.5.2
reproduce:
what works though if you set the srcDir option to something like src/webcomponents, and adjust the srcDir config option accordingly.
lufonius commentedon May 20, 2021
ah i just found out ... faster than i expected :)
adjusting only the srcDir option is not enough, in the tsconfig.json the include section must also be changed.
change
"include": [ "src" ],to
"include": [ "webcomponents" ],now the error makes sense. would be nice to mention it in the docs under the config srcDir option.
aztack commentedon Jun 28, 2021
same problem here:
{ "dependencies": { "@stencil/core": "^2.6.0", "@stencil/stylus": "^1.0.1" } }kerryj89 commentedon Apr 10, 2022
Ran into this when upgrading components from Stencil 1 to Stencil 2.
There were some conditionals in the components like:
Changing
Elementtowindow.Elementseemed to fix this, i.e.hettiger commentedon Jan 16, 2023
Still ran into this. I wonder why this has been closed …
However, I found a workaround:
Simply import these from anywhere in your app. Then use DOMElement instead of Element. (except for the actual @element() decorator usage ofc.)