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(import): detect node built-ins #6609

Merged
merged 4 commits into from
Nov 1, 2024
Merged

Conversation

liady
Copy link
Contributor

@liady liady commented Oct 31, 2024

This PR adds the ability to detect Node built-ins that are being imported.

Notes:

  • We currently detect all imports in project files, without checking if the importing file is in the import chain of the app itself. This may result in false positives, if one of the files in the project that does not belong to the app imports a Node module.
  • For that reason - currently this only triggers a "warning" and not a critical error.
  • We compare the built-ins that we find with the project dependencies, in case some of them are shimmed.
  • We're using a static list taken from here: https://github.com/sindresorhus/builtin-modules. We can't use the package directly since it is an ESM module, and our tests cannot import it, and in any case all it does is exporting this JSON.

If you clone this branch you can test it using http://localhost:8000/p?accessLevel=public&clone=liady/utopia-vite-project - I added an import * as fs from 'fs' there to test this functionality. (don't forget to turn on the Import Wizard feature flag)

image

Manual Tests:
I hereby swear that:

  • I opened a hydrogen project and it loaded
  • I could navigate to various routes in Play mode

Copy link
Contributor

github-actions bot commented Oct 31, 2024

Try me

Copy link

relativeci bot commented Oct 31, 2024

#14993 Bundle Size — 58.04MiB (~+0.01%).

3b26095(current) vs d1d46c1 master#14991(baseline)

Warning

Bundle contains 70 duplicate packages – View duplicate packages

Bundle metrics  Change 3 changes Regression 1 regression
                 Current
#14993
     Baseline
#14991
Regression  Initial JS 41.02MiB(~+0.01%) 41.01MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 18.07% 17.95%
No change  Chunks 20 20
No change  Assets 22 22
Change  Modules 4165(+0.02%) 4164
No change  Duplicate Modules 213 213
No change  Duplicate Code 27.31% 27.31%
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
#14993
     Baseline
#14991
Regression  JS 58.03MiB (~+0.01%) 58.03MiB
Improvement  HTML 7.37KiB (-0.25%) 7.39KiB

Bundle analysis reportBranch feat/server-packages-importProject dashboard


Generated by RelativeCIDocumentationReport issue

editor/pnpm-lock.yaml Outdated Show resolved Hide resolved
@liady liady merged commit 07c6bd8 into master Nov 1, 2024
16 checks passed
@liady liady deleted the feat/server-packages-import branch November 1, 2024 10:53
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.

3 participants