-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(import): detect node built-ins (#6609)
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) <img width="658" alt="image" src="https://github.com/user-attachments/assets/c4ddedef-d863-45fa-89f6-63c7ee6cd4f4"> **Manual Tests:** I hereby swear that: - [X] I opened a hydrogen project and it loaded - [X] I could navigate to various routes in Play mode
- Loading branch information
Showing
3 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
editor/src/core/shared/import/project-health-check/requirements/builtin-modules.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
[ | ||
"assert", | ||
"assert/strict", | ||
"async_hooks", | ||
"buffer", | ||
"child_process", | ||
"cluster", | ||
"console", | ||
"constants", | ||
"crypto", | ||
"dgram", | ||
"diagnostics_channel", | ||
"dns", | ||
"dns/promises", | ||
"domain", | ||
"events", | ||
"fs", | ||
"fs/promises", | ||
"http", | ||
"http2", | ||
"https", | ||
"inspector", | ||
"inspector/promises", | ||
"module", | ||
"net", | ||
"os", | ||
"path", | ||
"path/posix", | ||
"path/win32", | ||
"perf_hooks", | ||
"process", | ||
"punycode", | ||
"querystring", | ||
"readline", | ||
"readline/promises", | ||
"repl", | ||
"stream", | ||
"stream/consumers", | ||
"stream/promises", | ||
"stream/web", | ||
"string_decoder", | ||
"timers", | ||
"timers/promises", | ||
"tls", | ||
"trace_events", | ||
"tty", | ||
"url", | ||
"util", | ||
"util/types", | ||
"v8", | ||
"vm", | ||
"wasi", | ||
"worker_threads", | ||
"zlib" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters