Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

bencmbrook
Copy link
Member

@bencmbrook bencmbrook commented Jun 15, 2022

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.

Screen Shot 2022-06-15 at 12 55 25 PM

TODO:

  • Drop webpack and babel
  • Update demo/example to import under new dist (can also update to type="module" while at it)
  • A little more thinking on web worker best practice
  • Reduce poly/ponyfilling and document poly/ponyfill instructions for package consumers (likely a separate PR)

Related Issues

  • [none]

Public Changelog

[none]

Security Implications

[none]

@vercel
Copy link

vercel bot commented Jun 15, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
penumbra-example ✅ Ready (Inspect) Visit Preview Jun 15, 2022 at 11:59PM (UTC)

@@ -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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'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)

Copy link
Member Author

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';?

Copy link
Member Author

@bencmbrook bencmbrook Jun 16, 2022

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

Copy link
Member

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

Copy link
Member Author

@bencmbrook bencmbrook Jun 17, 2022

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

@bencmbrook bencmbrook mentioned this pull request Jun 16, 2022
@eligrey eligrey closed this Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants