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

Fix importComponent #2070

Merged
merged 10 commits into from
Feb 16, 2022
Merged

Fix importComponent #2070

merged 10 commits into from
Feb 16, 2022

Conversation

ZauberNerd
Copy link
Contributor

@ZauberNerd ZauberNerd commented Jan 31, 2022

Ref: #1632, #1976

Todo:

  • What happens if we import the same file from different files? I suspect our babel plugin will generate different chunk names which should in fact not be different. So maybe our hash should not include the filepath of the importing component but only the filepath of the imported component.
    • seems to create separate entries in the namedChunkGroups which point to the same asset.
Bors merge bot cheat sheet

We are using bors-ng to automate merging of our pull requests. The following table provides a summary of commands that are available to reviewers (members of this repository with push access) and delegates (in case of bors delegate+ or bors delegate=[list]).

Syntax Description
bors merge Run the test suite and push to master if it passes. Short for "reviewed: looks good."
bors merge- Cancel an r+, r=, merge, or merge=
bors try Run the test suite without pushing to master.
bors try- Cancel a try
bors delegate+ Allow the pull request author to merge their changes.
bors delegate=[list] Allow the listed users to r+ this pull request's changes.
bors retry Run the previous command a second time.

This is a short collection of opinionated commands. For a full list of the commands read the bors reference.

@ZauberNerd ZauberNerd added 📦 master Apply this label to a pull request, if it has to be cherry-picked to the maste-branch. 📦 v15 Apply this label to a pull request, if it has to be cherry-picked to the v15.x-branch after merging. labels Jan 31, 2022
@ZauberNerd ZauberNerd changed the title Fix importcomponent Fix importComponent Jan 31, 2022
ZauberNerd and others added 4 commits February 2, 2022 14:48
We observed that in some cases the generated module ids differe between
the browser and server build.
This happens when one of the builds is able to concatenate modules into
one chunk while the other build can't (e.g. because the modules live in
different chunks because of code splitting).
Because we did not want to split the server build into chunks and then
load them manually, we decided to generate stable chunk names, that do
not differ between browser/server, in our importComponent babel plugin.

We tried to work around this issue previously via #1976 but with a later
webpack version our workaround stopped working.
Furthermore, our previous workaround had other issues, which impacted
tree-shaking and therefore the bundle size.

Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>
Co-authored-by: Robert Kowalski <robert.kowalski@new-work.se>
In case the `--experimental-esbuild` mode is used, we have a small
webpack loader to handle the `importComponent` transformation.
This had been introduced in #1632 to be a quick & dirty regex based
replacer.
With this commit we now have a webpack loader that has a fast-exit
path in case `importComponent` is not used. Otherwise it will transpile
the source code using the proper babel plugin.

Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>
Co-authored-by: Robert Kowalski <robert.kowalski@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>
Co-authored-by: Robert Kowalski <robert.kowalski@new-work.se>
in the current setup, webpack builds where still running when the
puppeteer tests would start, which leads to timeout issues,
especially on slow machines like CI servers.

This commit waits for the build to finish before continuing with
`getUrl`, which is called by the integration tests upfront

Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
@robertkowalski robertkowalski marked this pull request as ready for review February 15, 2022 12:14
robertkowalski
robertkowalski previously approved these changes Feb 15, 2022
Copy link
Contributor

@robertkowalski robertkowalski left a comment

Choose a reason for hiding this comment

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

boom!

@ZauberNerd ZauberNerd force-pushed the fix-importcomponent branch 2 times, most recently from 680bb5b to 6886295 Compare February 15, 2022 16:12
ZauberNerd and others added 2 commits February 15, 2022 16:31
Co-authored-by: Robert Kowalski <robert.kowalski@new-work.se>
@ZauberNerd
Copy link
Contributor Author

We've got a flaky test:

FAIL packages/spec/integration/redux/__tests__/mocked.js (10.453 s)
  ● development server with msw mocks › Adding up to 12 › will show the mocked counter values 5 and 12

    expect(received).resolves.toBe(expected) // Object.is equality

    Expected: "5"
    Received: "42"

      120 |       await registerBrowserMocks(page, mockGetRequest('/api', { value: 7 }));
      121 |
    > 122 |       await expect(getInnerText('counter')).resolves.toBe('5');
          |                                                      ^
      123 |
      124 |       const btn = await getElementByText('async +');
      125 |

      at Object.toBe (../../../../node_modules/expect/build/index.js:242:22)
      at Object.<anonymous> (__tests__/mocked.js:122:54)

ZauberNerd and others added 2 commits February 15, 2022 17:17
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
@ZauberNerd
Copy link
Contributor Author

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 16, 2022

Build succeeded:

@bors bors bot merged commit 44b8899 into master Feb 16, 2022
@bors bors bot deleted the fix-importcomponent branch February 16, 2022 08:54
@hops-release-bot hops-release-bot bot mentioned this pull request Feb 16, 2022
1 task
@hops-release-bot
Copy link

Cherry-pick failed on branch v15.x!

Please check out PR #2078 & resolve the conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 master Apply this label to a pull request, if it has to be cherry-picked to the maste-branch. 📦 v15 Apply this label to a pull request, if it has to be cherry-picked to the v15.x-branch after merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants