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

chore: use esbuild instead of webpack for building #500

Merged
merged 50 commits into from
Aug 19, 2024
Merged

Conversation

sidvishnoi
Copy link
Member

@sidvishnoi sidvishnoi commented Aug 12, 2024

Context

Closes #360

Changes proposed in this pull request

  • Replaces webpack with esbuild
    • We now get better sourcemaps and build speed.
  • Updates build command syntax a bit
  • Reduced build size by roughly 100KB 20KB (#498 reduced by 80KB with mangling support)

@github-actions github-actions bot added the area: background Improvements or additions to extension background script label Aug 12, 2024
@raducristianpopa
Copy link
Member

raducristianpopa commented Aug 12, 2024

Extension builds preview

Name Link
Latest commit aa89ea7
Latest job logs Run #10450079568
BadgeDownload
BadgeDownload

@github-actions github-actions bot added the area: popup Improvements or additions to extension popup label Aug 13, 2024
@sidvishnoi sidvishnoi changed the title wip: try using esbuild chore: use esbuild instead of webpack for building Aug 13, 2024
@github-actions github-actions bot added area: documentation Improvements or additions to documentation area: ci Improvements or additions to repository workflows labels Aug 13, 2024
Co-authored-by: Radu-Cristian Popa <[email protected]>
@raducristianpopa

This comment was marked as resolved.

- Fixes CSP issues in Firefox
- Reduces bundle size again to webpack-like levels
@raducristianpopa
Copy link
Member

It looks like the esbuild-node-builtin is injecting the Buffer in all entrypoints. This is happening because the plugin is using the inject API for Buffer.

In the built monetization polyfill:

 function mr(t, r) {
    if (g(r)) {
      var n = L(r.length) | 0
      return (t = F(t, n)), t.length === 0 || r.copy(t, 0, 0, n), t
    }
    if (r) {
      if (
        (typeof ArrayBuffer < 'u' && r.buffer instanceof ArrayBuffer) ||
        'length' in r
      )
        return typeof r.length != 'number' || Yr(r.length) ? F(t, 0) : M(t, r)
      if (r.type === 'Buffer' && J(r.data)) return M(t, r.data)
    }
    throw new TypeError(
      'First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.'
    )
  }
  function L(t) {
    if (t >= d())
      throw new RangeError(
        'Attempt to allocate Buffer larger than maximum size: 0x' +
          d().toString(16) +
          ' bytes'
      )
    return t | 0
  }
  a.isBuffer = Lr

scripts/build.ts Outdated Show resolved Hide resolved
Base automatically changed from rp/497/switch-to-proxy-injection to main August 16, 2024 12:41
@sidvishnoi sidvishnoi marked this pull request as ready for review August 19, 2024 08:41
Copy link
Member

@raducristianpopa raducristianpopa left a comment

Choose a reason for hiding this comment

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

Done during pair-programming.

@sidvishnoi sidvishnoi merged commit 139c3d9 into main Aug 19, 2024
8 checks passed
@sidvishnoi sidvishnoi deleted the use-esbuild branch August 19, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: background Improvements or additions to extension background script area: ci Improvements or additions to repository workflows area: documentation Improvements or additions to documentation area: popup Improvements or additions to extension popup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider replacing webpack with esbuild/rollup for better sourcemaps
2 participants