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

Bundlephobia does not support modern language features. #530

Closed
Lakuna opened this issue Jun 16, 2021 · 6 comments
Closed

Bundlephobia does not support modern language features. #530

Lakuna opened this issue Jun 16, 2021 · 6 comments
Assignees

Comments

@Lakuna
Copy link

Lakuna commented Jun 16, 2021

See comments for further details. I have unpublished the packages that the original post mentioned.

No details are given in the error aside from "Failed to build this package."

@Lakuna
Copy link
Author

Lakuna commented Jun 20, 2021

I did some testing and have discovered that three aspects of my code were causing the build error.

The "static" keyword:

class Foo {
  static bar = 0;
}

Private class fields:

class Foo {
  #bar;

  constructor() {
    this.#bar = 0;
  }
}

Arrow function expression methods:

class Foo {
  bar = () => console.log('Hello, world!');
}

All three are supported by the newest version of Terser.

@Lakuna
Copy link
Author

Lakuna commented Jun 20, 2021

The package I linked in the original example has been renamed and changes were made within the code so that it would bundle correctly. It would still be nice for this to work for other packages, though.

@Lakuna
Copy link
Author

Lakuna commented Jun 22, 2021

It seems like the nullish coalescing operator:

const foo = (bar) => bar ?? 0;

and optional chaining:

foo?.bar?.();

also cause build errors. Both are also supported by the newest version of Terser.

@Lakuna Lakuna changed the title BuildError: @umbra-engine/ulin fails to build. Bundlephobia does not support modern language features. Jun 22, 2021
aabounegm added a commit to illright/attractions that referenced this issue Oct 12, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
It was causing Bundlephobia build errors:
pastelsky/bundlephobia#530
@arthurfiorette
Copy link

The issue comes from the package-build-stats package. An issue there (pastelsky/package-build-stats#33) already exists.

Most recent PR: pastelsky/package-build-stats#35

@pastelsky
Copy link
Owner

pastelsky commented Jan 1, 2022

Update on supporting modern language features:
This is taking a lot longer than I expected primarily because this is a big change. Firstly, I'd have to change bundlephobia's bundler. Secondly, any change in bundler means that all existing results need to be refreshed since a change in bundler is likely to cause a change in baseline (e.g. Webpack 5 does much better tree shaking). There are two ways of going about this —

  1. Upgrade to Webpack 5: is a large upgrade from Webpack 4 and all existing tooling (including composition calculation etc) needs to be ported over. I'd done a prototype for this, but turns out to my surprise that Webpack 5 is in general, 20-30% slower than Webpack 4 for large packages. This means slower package build or me bumping up server capacity by that amount — both of which aren't very desirable. Also, given how painful webpack upgrades are, and how tonnes of loaders and plugins, each with their own upgrade paths is required, I'm less excited about choosing this.
  2. Switch to a faster modern bundler: I've been eyeing moving to Parcel 2, and did a prototype that gave some very promising results. The configuration is much easier to manage, and bundling is a lot faster. This is my current choice, and will continue to port over bundlephobia's features to Parcel — it will take time though.

All of this is going to take a month or so, given holidays and my work schedule. Apologies for not responding on the thread sooner, but I thought I'd share an update because it's not like I've not been thinking about this problem — its just a lot of work.

@pastelsky
Copy link
Owner

Note: Bundlephobia should now support new javascript syntax — all that's supported by the latest version of Acorn and Terser — reasonably well, while I continue to work on replacing our bundler under the hood.

This was long due — thanks a lot for all of your patience!

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

No branches or pull requests

3 participants