-
Notifications
You must be signed in to change notification settings - Fork 6
Develop #270
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
Merged
Develop #270
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Resgrid/Unit
Length of output: 2824
🏁 Script executed:
Repository: Resgrid/Unit
Length of output: 27528
🏁 Script executed:
Repository: Resgrid/Unit
Length of output: 6805
🏁 Script executed:
Repository: Resgrid/Unit
Length of output: 10028
🏁 Script executed:
Repository: Resgrid/Unit
Length of output: 2591
🌐 Web query:
Hermes JavaScript engine support for URL global and CommonJS require in React Native Metro bundles💡 Result:
The Hermes JavaScript engine does not natively support the global URL API or CommonJS require functionality as part of the engine itself. Their availability in a React Native environment depends on the surrounding infrastructure [1][2][3]. URL Global API Hermes is a JavaScript engine designed primarily for React Native and does not implement the WHATWG URL standard, as it is a web platform API rather than part of the ECMAScript specification [1]. While developers may encounter a global URL object in some React Native environments, it is often a partial implementation provided by the React Native framework's built-in libraries (such as the Blob module) rather than by the engine [4]. These partial implementations are frequently incomplete, often lacking support for various URL accessors (e.g., host, hostname, password) [4]. Developers requiring consistent URL support are advised to use reliable user-space polyfills (like whatwg-url) to ensure cross-platform compatibility [1]. CommonJS require Hermes does not provide a native, production-ready implementation of CommonJS require [5][3]. While Hermes previously contained an experimental, built-in CommonJS/mini-ESM implementation, it was officially deprecated and deactivated because it was not used by the React Native ecosystem [5][3]. In standard React Native development, the Metro bundler handles module resolution and the CommonJS require syntax [5][6]. Metro transforms your code during the build process, replacing require calls and ensuring that dependencies are bundled correctly for the runtime [6]. Consequently, when you use require in a React Native project, you are interacting with Metro's module system, not with a runtime feature provided by the Hermes engine [5]. Developers should rely on Metro's established bundle transformation process rather than attempting to leverage any residual or unofficial CommonJS features within the Hermes engine itself [3].
Citations:
🏁 Script executed:
Repository: Resgrid/Unit
Length of output: 8024
🏁 Script executed:
Repository: Resgrid/Unit
Length of output: 13433
🏁 Script executed:
Repository: Resgrid/Unit
Length of output: 50369
🏁 Script executed:
Repository: Resgrid/Unit
Length of output: 6185
🌐 Web query:
Metro bundler browser field package.json resolver mainFields false core module React Native💡 Result:
In the Metro bundler, the
resolverMainFieldsconfiguration determines which fields in a package.json file are checked to resolve a package's entry point or perform file redirections [1][2][3]. Metro follows the "browser" field specification, meaning it treats the entries inresolverMainFieldsas an ordered list of keys to look for in a package.json [2][3]. When Metro encounters a package, it checks these fields in order; if a field contains a mapping (a redirection), Metro applies that redirection to resolve the path [1][2]. Regarding your specific query: 1. mainFields and false: Metro'sresolverMainFieldsis defined as an array of strings (e.g.,['react-native', 'browser', 'main']) [3][4]. It does not support a literalfalsevalue to disable this behavior globally in the configuration; if you wish to effectively disable the browser field, you would remove it from theresolverMainFieldsarray in yourmetro.config.js[3]. 2. Core Modules and React Native: By default, when using React Native,resolverMainFieldsis set to['react-native', 'browser', 'main'][3][4]. This ensures that native-specific entry points are prioritized [5]. If you are working on a web project using Metro (such as via Expo), you might need to adjust this list to prioritizebrowseroverreact-nativeto ensure that web-compatible code is loaded instead of native code [5][6]. 3. How to modify: You can customize this in yourmetro.config.jsfile:javascript module.exports = { resolver: { resolverMainFields: ['browser', 'main'], // Example: prioritizing browser, omitting react-native }, };If you encounter issues wherebrowserfield redirections are not working as expected, ensure that yourmetroandmetro-resolverversions are consistent, as certain bugs in subpath resolution have been addressed in recent updates [7][8]. Additionally, be aware that Metro's handling of these legacy fields can sometimes conflict with newerexportsconditions inpackage.json[6][9].Citations:
resolverMainFieldsshould include "react-native" react/metro#807browsermodule overrides inpackage.jsonexpo/expo#21896react-dom/servercannot be resolved withunstable_enablePackageExportsand conditionbrowserreact/metro#1135🌐 Web query:
PostCSS React Native Metro bundler fs path url browser field compatibility💡 Result:
Integrating PostCSS, handling
fs/path/urlmodules, and managing thebrowserfield in React Native with the Metro bundler requires careful configuration due to fundamental differences between Node.js and React Native environments. PostCSS in React Native Metro Metro does not support PostCSS by default. To use it, you must configure a custom transformer inmetro.config.js. 1. Use a community-maintained transformer (e.g.,react-native-postcss-transformer) [1][2]. 2. Configuremetro.config.jsto use this transformer for specific extensions (e.g.,.css,.pcss) [1][3]. 3. For Expo projects, modern support for CSS and Tailwind is often built-in or provided via specialized libraries like NativeWind, which abstract much of this manual configuration [4]. Handling Node.js Built-ins (fs, path, url) React Native does not provide nativefs,path, orurlmodules because these are Node.js environment APIs, not browser or mobile runtime APIs. 1. Polyfilling: You must provide your own polyfills (e.g.,path-browserifyforpath, orreact-native-level-fsforfs) [5]. 2. Resolution: You can instruct Metro to resolve these imports to your installed polyfill packages by mapping them in yourmetro.config.jsorpackage.json, though this is often fragile and discouraged for deep dependencies [5]. 3. Architecture: The recommended architectural approach is to avoid libraries that depend on Node.js built-ins in React Native. If a library requires them, check if a browser-compatible or React Native-specific version exists. Browser Field Compatibility Metro's resolver adheres to thebrowserfield specification, which allows packages to define platform-specific entry points [6][7]. 1. Behavior: Metro treats thebrowserfield as a way to replace or ignore files [7]. For React Native, theresolverMainFieldsdefault is['react-native', 'browser', 'main'][7][8]. This means if a package has areact-nativefield in itspackage.json, Metro will prioritize it overbrowserormain[8]. 2. Advanced Control: You can customizeresolverMainFieldsinmetro.config.jsto change the lookup priority if necessary [7]. Additionally, modern Metro support for conditional exports ("exports"field) allows for more granular platform targeting (react-nativevs.browser) which is preferred over the legacy"browser"root field [9]. Summary of Recommendations - PostCSS: Use a transformer for CSS files or a framework-specific solution (e.g., NativeWind/Expo CSS) [1][4]. - Node Built-ins: Do not attempt to usefsorpathdirectly. Use libraries that do not depend on them [5]. - Resolution: Rely on thereact-nativefield inpackage.jsonfor platform-specific code, or use the"exports"condition for modern package resolution [8][9]. If issues arise with resolution, check yourmetro.config.jsresolverMainFieldssettings [7][8].Citations:
Upgrade
sanitize-htmlto 2.17.5 or later and updateyarn.lock. Version 2.17.0 has a known URI-scheme validation vulnerability.🤖 Prompt for AI Agents