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

Use node module resolution #6425

Merged
merged 12 commits into from
Oct 11, 2024
Merged

Use node module resolution #6425

merged 12 commits into from
Oct 11, 2024

Conversation

Rheeseyb
Copy link
Contributor

@Rheeseyb Rheeseyb commented Sep 27, 2024

Problem
Utopia's module resolution logic is based on the 2019 node module resolution, but that logic has significantly evolved since then. This means that there are plenty of cases where the module resolution whilst running a project in Utopia would not match that whilst running elsewhere, causing certain projects to break in unexpected ways.

Fix:
I've implemented the latest node.js module resolution logic from https://nodejs.org/api/modules.html#all-together. Since this is of course running in the browser, this also still needs to take into account the browser field of the package.json, which was already implemented but I wanted to call it out as that is one area where this differs from the node.js spec.

There is still a remaining FIXME in here about partial path matching when checking the imports and exports fields. I'll tackle that in a followup PR.

Fixes #6187

Copy link
Contributor

github-actions bot commented Sep 27, 2024

Try me

Copy link

relativeci bot commented Sep 27, 2024

#14708 Bundle Size — 57.94MiB (+0.01%).

ab16941(current) vs 916e8b9 master#14701(baseline)

Warning

Bundle contains 70 duplicate packages – View duplicate packages

Bundle metrics  Change 3 changes Regression 1 regression
                 Current
#14708
     Baseline
#14701
Regression  Initial JS 40.95MiB(+0.02%) 40.94MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 18.46% 17.91%
No change  Chunks 21 21
No change  Assets 23 23
Change  Modules 4147(+0.05%) 4145
No change  Duplicate Modules 213 213
No change  Duplicate Code 27.32% 27.32%
No change  Packages 477 477
No change  Duplicate Packages 70 70
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#14708
     Baseline
#14701
Regression  JS 57.94MiB (+0.01%) 57.93MiB
Improvement  HTML 7.37KiB (-0.25%) 7.39KiB

Bundle analysis reportBranch fix/node-module-resolutionProject dashboard


Generated by RelativeCIDocumentationReport issue

@Rheeseyb Rheeseyb changed the title (WIP) Use node module resolution Use node module resolution Oct 1, 2024
@Rheeseyb Rheeseyb marked this pull request as ready for review October 1, 2024 11:11
@Rheeseyb Rheeseyb merged commit da6bf80 into master Oct 11, 2024
17 checks passed
@Rheeseyb Rheeseyb deleted the fix/node-module-resolution branch October 11, 2024 10:48
balazsbajorics added a commit that referenced this pull request Oct 11, 2024
balazsbajorics added a commit that referenced this pull request Oct 11, 2024
This reverts commit da6bf80.

**Problem:**
When loading the Hydrogen demo store, an infinite recursion happens:

![image](https://github.com/user-attachments/assets/ee1a761d-c950-43c3-a633-f62ec580d722)
liady pushed a commit that referenced this pull request Dec 13, 2024
**Problem**
Utopia's module resolution logic is based on the [2019 node module
resolution](https://web.archive.org/web/20190213102857/https://nodejs.org/api/modules.html#modules_all_together),
but that logic has significantly evolved since then. This means that
there are plenty of cases where the module resolution whilst running a
project in Utopia would not match that whilst running elsewhere, causing
certain projects to break in unexpected ways.

**Fix:**
I've implemented the latest node.js module resolution logic from
https://nodejs.org/api/modules.html#all-together. Since this is of
course running in the browser, this also still needs to take into
account the [`browser` field of the
`package.json`](https://github.com/defunctzombie/package-browser-field-spec),
which was already implemented but I wanted to call it out as that is one
area where this differs from the node.js spec.

There is still a remaining `FIXME` in here about partial path matching
when checking the `imports` and `exports` fields. I'll tackle that in a
followup PR.

Fixes #6187
liady pushed a commit that referenced this pull request Dec 13, 2024
This reverts commit da6bf80.

**Problem:**
When loading the Hydrogen demo store, an infinite recursion happens:

![image](https://github.com/user-attachments/assets/ee1a761d-c950-43c3-a633-f62ec580d722)
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.

we have trouble importing import splideStyle from '@splidejs/react-splide/css/core';
5 participants