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
The webframework that I wrote for bun has a function to build frontends. ( url.frontend("nameOfFrontendEntrypoint.tsx") )
It populates an array with the name of the frontend. To build them, the build function imports the backend code that the consumer (/developer) of this webframework wrote. This executes all the invocations of url.frontend and populates the array with all the frontend files that are to be built.
The issue is that if the frontend and the backend use the same library (that is different depending on if it is used in the browser or nodejs. But still the same npm package. @solana/web3.js is an example for that) then the compiled frontend will complain about missing nodejs features like buffer, process, https, global and so on. This is not the case if it is not imported in the backend. If it is just imported in the frontend, the Bun.build works perfectly fine. It seems to only get triggered if it is imported in the same .ts file that runs Bun.build
I made a change now that runs the Bun.build code in a different process: spirobel/mininext@5d45fd9
this change made the issue disappear. So the assumption is, that during Bun.build, imports are cached somehow. I started to read the source code
TLDR: use mininext v 0.5.1 and use @solana/web3.js in both frontend and backend.
What is the expected behavior?
the expected behavior is that Bun.build with target browser produces a bundle that is not dependent on a nodejs library, regardless of if the library is imported in the script that runs Bun.build or not.
The issue is that if the frontend and the backend use the same library (that is different depending on if it is used in the browser or nodejs. But still the same npm package. @solana/web3.js is an example for that) then the compiled frontend will complain about missing nodejs features like buffer, process, https, global and so on. This is not the case if it is not imported in the backend. If it is just imported in the frontend, the Bun.build works perfectly fine. It seems to only get triggered if it is imported in the same .ts file that runs Bun.build
What do you see instead?
The issue is that if the frontend and the backend use the same library (that is different depending on if it is used in the browser or nodejs. But still the same npm package. @solana/web3.js is an example for that) then the compiled frontend will complain about missing nodejs features like buffer, process, https, global and so on. This is not the case if it is not imported in the backend. If it is just imported in the frontend, the Bun.build works perfectly fine. It seems to only get triggered if it is imported in the same .ts file that runs Bun.build
Additional information
I can produce an example repo if necessary. lmk if you can not reproduce / something is unclear
The text was updated successfully, but these errors were encountered:
What version of Bun is running?
1.1.29
What platform is your computer?
Linux 6.8.0-45-generic x86_64 x86_64
What steps can reproduce the bug?
The webframework that I wrote for bun has a function to build frontends. ( url.frontend("nameOfFrontendEntrypoint.tsx") )
It populates an array with the name of the frontend. To build them, the build function imports the backend code that the consumer (/developer) of this webframework wrote. This executes all the invocations of url.frontend and populates the array with all the frontend files that are to be built.
The issue is that if the frontend and the backend use the same library (that is different depending on if it is used in the browser or nodejs. But still the same npm package. @solana/web3.js is an example for that) then the compiled frontend will complain about missing nodejs features like buffer, process, https, global and so on. This is not the case if it is not imported in the backend. If it is just imported in the frontend, the Bun.build works perfectly fine. It seems to only get triggered if it is imported in the same .ts file that runs Bun.build
I made a change now that runs the Bun.build code in a different process:
spirobel/mininext@5d45fd9
this change made the issue disappear. So the assumption is, that during Bun.build, imports are cached somehow. I started to read the source code
bun/src/bun.js/api/JSBundler.zig
Line 538 in 9ab5198
TLDR: use mininext v 0.5.1 and use @solana/web3.js in both frontend and backend.
What is the expected behavior?
the expected behavior is that Bun.build with target browser produces a bundle that is not dependent on a nodejs library, regardless of if the library is imported in the script that runs Bun.build or not.
The issue is that if the frontend and the backend use the same library (that is different depending on if it is used in the browser or nodejs. But still the same npm package. @solana/web3.js is an example for that) then the compiled frontend will complain about missing nodejs features like buffer, process, https, global and so on. This is not the case if it is not imported in the backend. If it is just imported in the frontend, the Bun.build works perfectly fine. It seems to only get triggered if it is imported in the same .ts file that runs Bun.build
What do you see instead?
The issue is that if the frontend and the backend use the same library (that is different depending on if it is used in the browser or nodejs. But still the same npm package. @solana/web3.js is an example for that) then the compiled frontend will complain about missing nodejs features like buffer, process, https, global and so on. This is not the case if it is not imported in the backend. If it is just imported in the frontend, the Bun.build works perfectly fine. It seems to only get triggered if it is imported in the same .ts file that runs Bun.build
Additional information
I can produce an example repo if necessary. lmk if you can not reproduce / something is unclear
The text was updated successfully, but these errors were encountered: