-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
experiment with esbuild/rollup for better modern distro #226
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -27,7 +27,8 @@ const DEFAULT_WORKERS = { | |||
StreamSaver: 'streamsaver.penumbra.serviceworker.js', | |||
}; | |||
|
|||
const SHOULD_LOG_EVENTS = process.env.PENUMBRA_LOG_START === 'true'; | |||
const SHOULD_LOG_EVENTS = | |||
'process' in self && process.env.PENUMBRA_LOG_START === 'true'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'process' in self && process.env.PENUMBRA_LOG_START === 'true'; | |
typeof process !== 'undefined' && process.env.PENUMBRA_LOG_START === 'true'; |
slightly more correct (e.g. globalThis.process
can be different than self.process
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SG! Also, on the right-hand side, should it be globalThis.process.env.PENUMBRA_LOG_START === 'true';
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW this was more of a type issue than a runtime concern, because the global types for node
weren't added in tsconfig. I feel like that's reasonable to omit, but we'd have to update a few things - like this and all the references to the Buffer
type (or we could import type { Buffer } from 'buffer' // feross package
).
In any case, does this file execute in Node? I was confused when I saw it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file executes in the browser. esbuild can inject variables like process.env.*
through its define
API. Here's an example of that: https://github.com/transcend-io/consent-manager-ui/blob/main/src/scripts/build.ts#L70-L75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing a bit of that in #229 (but not for this process.env. var) - i think that branch is better than this one so we could close this out
As browsers gain support for all underlying features of Penumbra, we should modernize and simplify our build output to be usable with PnP, ESM, treeshaking, and reduce the amount of poly/ponyfilling. This would switch us off webpack in favor of esbuild, and build distributions with rollup.
TODO:
Related Issues
Public Changelog
[none]
Security Implications
[none]