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
We presently use rollup-plugin-replace to do static replacement of the pattern if (isNode) with if (true) or if (false) depending on the target platform. This works but is brittle.
A better approach is to remove the replace plugin and have a platform.node.js and platform.browser.js that has export const isNode = true and export const isNode = false respectively. These files are then mapped using the standard browser field in package.json. This will allow Rollup's tree shaker to work regardless of the syntactic pattern used, and would even work should we decide to support additional platform constants like isElectron. It will also work with other bundlers' tree shakers as well, resulting in more optimal bundles for our consumers.
The text was updated successfully, but these errors were encountered:
Any updates on this? It seems like this would address issues we're seeing trying to use the SDKs in an Electron app. We're adding a very kludgey workaround to force isNode to resolve to false in Electron browser windows with nodeIntegration set to true.
Hi @bterlson, we deeply appreciate your input into this project. Regrettably, this issue has remained inactive for over 2 years, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.
We presently use rollup-plugin-replace to do static replacement of the pattern
if (isNode)
withif (true)
orif (false)
depending on the target platform. This works but is brittle.A better approach is to remove the replace plugin and have a
platform.node.js
andplatform.browser.js
that hasexport const isNode = true
andexport const isNode = false
respectively. These files are then mapped using the standard browser field in package.json. This will allow Rollup's tree shaker to work regardless of the syntactic pattern used, and would even work should we decide to support additional platform constants likeisElectron
. It will also work with other bundlers' tree shakers as well, resulting in more optimal bundles for our consumers.The text was updated successfully, but these errors were encountered: