iframe-resizer
iframe-resizer copied to clipboard
How to import in NodeJS?
I can't seem to manage to import it in NodeJS using import x from 'y'
. There's nothing in the docs.
If I do: import { iframeResizer } from 'iframe-resizer'
I get the error that the element is not exported.
And if I just import x
I get the error that there is no default export
.
I'm having the same problem. Could you find a workaround for the issue @el-pol?
When I try import { iframeResize } from 'iframe-resizer';
I get that error,
The requested module './../../../node_modules/iframe-resizer/index.js' does not provide an export named 'iframeResize'
When I try import iframeResize from 'iframe-resizer';
I get that error,
SyntaxError: The requested module './../../../node_modules/iframe-resizer/index.js' does not provide an export named 'default'
When I just try it import 'iframe-resizer';
ReferenceError: module is not defined
Probably I'm doing sth wrong, any help will be appreciated :)
@mutluhanuzmez I got the same. I ended up giving up on this library and writing my own JS code. I'm sure it's something stupid we are missing :)
I tried to import the js files inside of the module directly in the parent page this way and it worked.
import 'iframe-resizer/js/iframeResizer';
also in the iframed page this way
import 'iframe-resizer/js/iframeResizer.contentWindow';
ps: There was also another problem for me while using iFrameResize method. I was using LitElement and it was rendering in the shadow DOM. Therefore sending the target as the iframe id didn't work for me. I took the iframe ref and send it to the method.
const iframe = this.shadowRoot.querySelector('#myIframe');
iFrameResize({log: true}, iframe);
Works perfect now, but I still don't like the import this way.
@mutluhanuzmez happy you solved it! This should be in the docs
For anyone else coming here from react side of things this worked for me. Probably not ideal but for now its a workaround
import 'iframe-resizer/js/iframeResizer';
import 'iframe-resizer/js/iframeResizer.contentWindow';
const Page = () => {
const iframe = useRef()
useEffect(() => {
//@ts-ignore
iFrameResize({}, iframe.current);
}, [])
return <>
<iframe
ref={iframe}
src="bla.com" >
</iframe>
</>
}
This will be address in v5