How can I load a library which uses window object? #6424
Unanswered
MarcosCunhaLima
asked this question in
Q&A
Replies: 3 comments 5 replies
-
Two options
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I would like to know why Remix "opens" each library or what it does in
order to generate this error? Is there any documentation regarding this?
Even better, we have 15-20 libraries in our project, how do we know if we
have a "client" library which relies internally on "window" or "document"
or not?
Em sex., 19 de mai. de 2023 às 15:29, Sergio Xalambrí <
***@***.***> escreveu:
… Two options
1. Use import("print-js") in an effect or event emitter, so it's only
imported client-side
2. Create a client-only file (.client.tsx) to import it, then use
Remix Utils's ClientOnly component to avoid rendering the component from
your .client.tsx file.
—
Reply to this email directly, view it on GitHub
<#6424 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGH5LM3ZA7QJ6TXSEMIQFDXG63Z3ANCNFSM6AAAAAAYG6THQE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Marcos Cunha Lima
*Futura Tecnologia*
(11) 3864-9092
***@***.***
<http://www.futuranet.com.br>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
What I expected from "bundle it" was that it would just copy the library
(minimizing it, etc) but wouldn't run any code inside it, right? So, if I
protect my code with some guard clause which assures that my code would run
only at browsers, I wouldn't have any problems using a client-side library.
Em sáb., 20 de mai. de 2023 às 12:33, Michael Carter <
***@***.***> escreveu:
… Remix/esbuild doesn't really "open" the package. It simply bundles it. The
error will appear if the code with client-only objects tries to execute
during SSR. Most React packages will work without any issues. The ones that
typically break are highly interactive components.
—
Reply to this email directly, view it on GitHub
<#6424 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGH5LPIDN7W7DACGYXUEGTXHDP6HANCNFSM6AAAAAAYG6THQE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Marcos Cunha Lima
*Futura Tecnologia*
(11) 3864-9092
***@***.***
<http://www.futuranet.com.br>
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Simple project which imports a library that references window object.
It builds OK but when I refresh the page, I get this error:
Beta Was this translation helpful? Give feedback.
All reactions