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

feat: add esbuild-why plugin #304

Merged
merged 10 commits into from
Feb 12, 2023
Merged

feat: add esbuild-why plugin #304

merged 10 commits into from
Feb 12, 2023

Conversation

unional
Copy link
Contributor

@unional unional commented Dec 6, 2022

fixes #302

@unional
Copy link
Contributor Author

unional commented Dec 6, 2022

Seems like the check.esbuildMetafile I added in esbuild didn't reach esbuild-why for some reason.

@ai
Copy link
Owner

ai commented Dec 6, 2022

I am on vacation and will review it a little later

@unional
Copy link
Contributor Author

unional commented Dec 6, 2022

Sure, enjoy your vacation! 🍹

async step81(config, check) {
if (config.why && check.esbuildMetafile) {
if (!config.saveBundle) {
console.warn('`--why` option requires `--save-bundle` option')
Copy link
Owner

Choose a reason for hiding this comment

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

We need a test for this line

@unional
Copy link
Contributor Author

unional commented Dec 16, 2022

Welcome back! I'll need to do some update to this PR, like updating the dependency as now the function is properly exposed, and other things.

btw, is the step[81] looks ok? I saw the code accepts 1-99 steps and there are some conventions, but I don't know where should this fit into (step 61 or 81 is my guess).

@ai
Copy link
Owner

ai commented Dec 16, 2022

btw, is the step[81] looks ok?

There is no system. And since there is not a lot of plugins, just put it between necessary steps.

@ai
Copy link
Owner

ai commented Jan 7, 2023

Can we improve test coverage to fix CI?

@unional
Copy link
Contributor Author

unional commented Jan 7, 2023

Can we improve test coverage to fix CI?

Sure, but right now I'm trying to see how to use it locally. i.e. how to set the --why and --saveBundle so that I can see it actually working.

I'll try to do a pnpm link to one of my repos locally to test it out.

In the doc, it mention about the config for webpack but not the config for esbuild. And maybe that's also something to improve upon.

@ai
Copy link
Owner

ai commented Jan 7, 2023

Sure, but right now I'm trying to see how to use it locally.

  1. Install dependencies pnpm install
  2. Create a test project in fixtures/ with all plugins in dependencies
  3. Call local size-limit script by ../package/size-limit/bin.js

@unional
Copy link
Contributor Author

unional commented Jan 9, 2023

Install dependencies pnpm install
Create a test project in fixtures/ with all plugins in dependencies
Call local size-limit script by ../package/size-limit/bin.js

thx. I tried that but don't know if I'm doing it correctly.

I have added this in /fixtures/esbuild-why/package.json:

{
  "name": "esbuild-why",
  "private": true,
  "devDependencies": {
    "@size-limit/esbuild-why": ">= 0.0.0",
    "@size-limit/file": ">= 0.0.0",
    "size-limit": ">= 0.0.0"
  },
  "size-limit": [
    {
      "path": "index.js"
    }
  ]
}

with an empty index.js.

Call local size-limit script by ../package/size-limit/bin.js

I can't find where should I do this. From the path, seems like you are referring to calling size-limit from /packages/esbuild-why?

I'll find some time to work on this PR this week.

btw, I always get this timeout error when running the tests. I'm using WSL in Windows:

packages/time/test/get-running-time.test.js (15.731 s)
  ● calculates running time

    thrown: "Exceeded timeout of 15000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      15 | })
      16 |
    > 17 | it('calculates running time', async () => {
         | ^
      18 |   let runTime = await getRunningTime(EXAMPLE)
      19 |   expect(runTime).toBeGreaterThan(0.01)
      20 |   expect(runTime).toBeLessThan(0.5)

      at Object.it (packages/time/test/get-running-time.test.js:17:1)

@ai
Copy link
Owner

ai commented Jan 9, 2023

I can't find where should I do this.

You should be in the fixture folder and call:

$ cd
size-limit/fixtures/integration
$ ../../packages/size-limit/bin.js
✔ Adding to empty webpack project
✔ Running JS in headless Chrome
  
  Package size is 58 B less than limit
  Size limit:   200 B
  Size:         142 B with all dependencies, minified and gzipped
  Loading time: 10 ms on slow 3G
  Running time: 84 ms on Snapdragon 410
  Total time:   94 ms

@ai
Copy link
Owner

ai commented Jan 9, 2023

btw, I always get this timeout error when running the tests. I'm using WSL in Windows:

I don’t have a Windows to investigate the reason without your help. But let’s ignore this test until we will not finish this PR.

@unional
Copy link
Contributor Author

unional commented Jan 9, 2023

I don’t have a Windows to investigate the reason without your help. But let’s ignore this test until we will not finish this PR.

Sure, I'm ignoring that. :)

@unional
Copy link
Contributor Author

unional commented Feb 11, 2023

Hi @ai, sorry for the long wait.

I have updated the code a bit to better handle the error message.

I have tested it and it will create a report.html at the folder.
To get the same behavior as webpack-why, we need to either save the file at a temp folder and open the file in the browser.

remove not used test code
@ai
Copy link
Owner

ai commented Feb 11, 2023

Nice. I fixed CI. Will review PR tomorrow (need to run to a party)

@ai ai merged commit a626b2f into ai:main Feb 12, 2023
@ai
Copy link
Owner

ai commented Feb 12, 2023

Thanks! Released in 8.2.

@unional
Copy link
Contributor Author

unional commented Feb 12, 2023

🎉

@unional unional deleted the esbuild-why branch February 12, 2023 18:01
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.

Supporting --why for esbuild
2 participants