Closed martypdx closed 5 months ago
Still an issue, this library won't work when used with node.js' import
.
I tried monkeying with the package.json to use the .es5
build as the main
and set "type": "module"
. But that build (on line 15) uses eval("require")
when Builder.isServer
true. But server doesn't mean cjs anymore
I noticed from this issue on astro that there is some effort to make the builder solid sdk ESM compatible. Any idea when this might land in react sdk?
I noticed from this issue on astro that there is some effort to make the builder solid sdk ESM compatible. Any idea when this might land in react sdk?
@martypdx All of our new SDKs (Vue, Solid, React-Native & Svelte) are ESM compatible, but the React SDK is on a separate architecture. We are planning on migrating the React SDK over to the new format, but we do not have a timeline for when that will happen yet.
Update: our Gen 2 React SDK is now stable at v1.0, and provided as an ES module. https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/react
I'm integrating builder.io/react into an astro project. For the server-side build, it uses straight NodeJS ES Module import, but the builder.io package exposes CJS.
Steps to recreate for vanilla NodeJS:
Create a new directory and run the following setup:
Add the following to
package.json
:Create an
index.js
with this code:Run via:
And gets this error:
Correcting the code as suggested fixes the problem:
But now that import statement doesn't work for bundled React environments. I know you don't want to break your NextJS, CRA, and browser side React builds, but can this library be packaged in a way that works for what is now standard node syntax?