webdriverio / query-selector-shadow-dom

querySelector that can pierce Shadow DOM roots without knowing the path through nested shadow roots. Useful for automated testing of Web Components. Production use is not advised, this is for test environments/tools such as Web Driver, Playwright, Puppeteer
MIT License
241 stars 25 forks source link

Error "cannot use import statement outside a module" with React #63

Open thisistaimur opened 3 years ago

thisistaimur commented 3 years ago

Getting an error when importing the module into a React script. Same works fine in a Node app or plain HTML. Does anyone have a fix?

Screen Shot 2021-06-03 at 12 23 41 Screen Shot 2021-06-03 at 12 23 22

Georgegriff commented 3 years ago

This is because this module ships as native modules and the React ecoystem is some what legacy in this respect,

I've got a PR to try to address this but i havent had time to test it properly, and would need to be a breaking change.

https://github.com/Georgegriff/query-selector-shadow-dom/pull/53/files

If you want to experiment with this you should be able to change your package.json entry for this package to:

"query-selector-shadow-dom": "git://Georgegriff/query-selector-shadow-dom.git#consider_essm"

If you have any time to help contribute/test t would be appreciated

thisistaimur commented 3 years ago

Cheers, will look into it and definitely contribute if I come up with a solution :)

JohnHardy commented 2 years ago

Did this solution get implemented? Is there a fork that can be used instead?

Thanks!

Georgegriff commented 2 years ago

There isn't I would be open to contributions I started a pr but didn't get around to following it up, not sure when I will next get a chance to investigate https://github.com/Georgegriff/query-selector-shadow-dom/pull/53

JohnHardy commented 2 years ago

Thanks for your time following up with me - I really appreciate it. Sorry, I thought the PR above was fully finished.

kazaff commented 2 years ago

This is because this module ships as native modules and the React ecoystem is some what legacy in this respect,

I've got a PR to try to address this but i havent had time to test it properly, and would need to be a breaking change.

https://github.com/Georgegriff/query-selector-shadow-dom/pull/53/files

If you want to experiment with this you should be able to change your package.json entry for this package to:

"query-selector-shadow-dom": "git://Georgegriff/query-selector-shadow-dom.git#consider_essm"

If you have any time to help contribute/test t would be appreciated

Could you tell me the mean of "change your package.json entry"?

jiefugong commented 1 year ago

Bump on this -- also running into this issue!