Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit41cf917

Browse files
committed
Improve errors when resolveRequest has been overridden
1 parent92fb011 commit41cf917

File tree

9 files changed

+175
-121
lines changed

9 files changed

+175
-121
lines changed

‎.changeset/warm-kings-wait.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"react-native-css-interop":patch
3+
"nativewind":patch
4+
---
5+
6+
Improve errors when resolveRequest has been overridden

‎apps/website/docs/guides/troubleshooting.md‎

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import Tabs from "@theme/Tabs";
2+
import TabItem from "@theme/TabItem";
3+
import CodeBlock from "@theme/CodeBlock";
4+
15
#Troubleshooting
26

37
:::tip
@@ -9,36 +13,13 @@ While troubleshooting, always start your application without the cache!
913

1014
:::
1115

12-
Before troubleshooting NativeWind, it's crucial to ensure that Tailwind CSS itself is functioning correctly. NativeWind uses the Tailwind CLI to compile your styles, so any issues with Tailwind CLI should be resolved first. You can inspect the Tailwind CSS output at the following location:`node_modules/.cache/nativewind/<input-css-filename>.<platform>.css`, or by simply running`npx tailwindcss --input <input.css>`.
13-
14-
For instance, if you've observed that a custom class`text-brand` isn't behaving as expected. You can proceed as follows:
15-
16-
1. First, ensure that your`tailwind.config.js` has the necessary configurations for the color.
17-
2. Navigate to`node_modules/.cache/nativewind/<input-css-filename>.<platform>.css` and search for the CSS class`.text-brand {}`
18-
19-
If you cannot locate the`.text-brand` CSS rule, it hints at an issue with your`tailwind.config.js`. To further validate this, run the command
20-
21-
```bash
22-
npx tailwindcss --input<input.css>
23-
```
24-
25-
If this output also lacks`.text-brand`, it confirms the misconfiguration.
26-
27-
To troubleshoot Tailwind CSS, refer to their[Troubleshooting Guide](https://tailwindcss.com/docs/content-configuration#troubleshooting).
28-
29-
**Only once you see the expected CSS being generated should you start this troubleshooting guide.**
16+
Before troubleshooting NativeWind, it's crucial to ensure that Tailwind CSS itself is functioning correctly. NativeWind uses the Tailwind CLI to compile your styles, so any issues with Tailwind CLI should be resolved first. Using the command`npx tailwindcss --input <input.css> --output output.css`, Tailwind CLI will generate an`output.css` file. If you are troubleshooting a class that is not working, ensure that the css rule is present in the`output.css` file.
3017

3118
##Verifying NativeWind Installation
3219

33-
NativeWind provides a utility function,`verifyInstallation()`, designed to help confirm that the package has been correctly installed.
34-
35-
Import the`verifyInstallation` function from the NativeWind package and run within the scope of a React component.**It's crucial to ensure that you do not invoke this function on the global scope.**
36-
37-
:::tip
20+
NativeWind provides a utility function`verifyInstallation()` designed to help confirm that the package has been correctly installed.
3821

39-
`verifyInstallation()` will`warn` on success and`error` on failure. If you do not see any output check the function is being executed correctly.
40-
41-
:::
22+
Import the`verifyInstallation` function from the NativeWind package and run within the scope of a React component.**Do not invoke this function on the global scope**, it should be run within a component.
4223

4324
```tsx
4425
importReactfrom'react';
@@ -56,6 +37,36 @@ function App() {
5637
exportdefaultApp;
5738
```
5839

40+
##Enabling debug mode
41+
42+
NativeWind supports the`DEBUG` environment variable and will output various debug information while your server is running.
43+
44+
<TabsgroupId="Troubleshooting">
45+
<TabItemvalue="osx"label="Mac / Linux">
46+
<CodeBlock language="bash">{`DEBUG=nativewind <start-command>`}</CodeBlock>
47+
</TabItem>
48+
<TabItemvalue="windows"label="Windows">
49+
<CodeBlock language="bash">{`set "DEBUG=nativewind" <start-command>`}</CodeBlock>
50+
</TabItem>
51+
</Tabs>
52+
53+
:::warning
54+
55+
@react-native-community/cli may create multiple terminal sessions. You will need to ensure all sessions have`DEBUG=nativewind` set.
56+
57+
:::
58+
59+
By itself, this information may or may not be useful to you, but it is extremely useful when reporting to the developers on GitHub. You can record the terminal output by redirecting the output to a file.
60+
61+
<TabsgroupId="Troubleshooting">
62+
<TabItemvalue="osx"label="Mac / Linux">
63+
<CodeBlock language="bash">{`DEBUG=nativewind script output.log <start-command>`}</CodeBlock>
64+
</TabItem>
65+
<TabItemvalue="windows"label="Windows">
66+
If you know how to record the terminal command in a one-liner script, please open a PR to add it here.
67+
</TabItem>
68+
</Tabs>
69+
5970
##Common Issues
6071

6172
###Your cache is loading old data

‎apps/website/src/pages/v4/troubleshooting.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
importTabsfrom"@theme/Tabs";
22
importTabItemfrom"@theme/TabItem";
3+
importCodeBlockfrom"@theme/CodeBlock";
34

45
#Troubleshooting
56

@@ -17,7 +18,7 @@ module.exports = function (api) {
1718
};
1819
```
1920

20-
If you are stillrecieving this error after including the preset, you most likely have another preset or plugin overriding the`jsxImportSource`. If so, explictly set the options of`@babel/plugin-transform-react-jsx` within your`plugins` array.
21+
If you are stillreceiving this error after including the preset, you most likely have another preset or plugin overriding the`jsxImportSource`. If so, explictly set the options of`@babel/plugin-transform-react-jsx` within your`plugins` array.
2122

2223
```diff title=babel.config.js
2324
module.exports = function (api) {

‎packages/nativewind/src/metro/index.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ export function withNativeWind(
5757
...options,
5858
inlineRem,
5959
selectorPrefix:typeofimportant==="string" ?important :undefined,
60-
debugNamespace:"nativewind",
6160
input,
61+
parent:{
62+
name:"nativewind",
63+
debug:"nativewind",
64+
},
6265
getCSSForPlatform:(platform,onChange)=>{
6366
debug(`getCSSForPlatform:${platform}`);
6467
returncli.getCSSForPlatform({

‎packages/react-native-css-interop/src/css-to-rn/index.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ export type { CssToReactNativeRuntimeOptions };
6666
*/
6767
exportfunctioncssToReactNativeRuntime(
6868
code:Buffer|string,
69-
{
70-
debug=debugFn("react-native-css-interop"),
71-
...options
72-
}:CssToReactNativeRuntimeOptions={},
69+
options:CssToReactNativeRuntimeOptions={},
70+
debug=debugFn("react-native-css-interop"),
7371
):StyleSheetRegisterCompiledOptions{
7472
constfeatures=Object.assign({},defaultFeatureFlags,options.features);
7573

‎packages/react-native-css-interop/src/doctor.native.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ export function verifyJSX() {
66
}
77

88
exportfunctionverifyData(){
9+
if(process.env.NODE_ENV!=="test"){
10+
if(require("./interop-poison.pill")===false){
11+
thrownewError(
12+
`Your 'metro.config.js' has overridden the 'config.resolver.resolveRequest' config setting in a non-composable manner. Your styles will not work until this issue is resolved. Note that 'require('metro-config').mergeConfig' is a shallow merge and does not compose existing resolveRequest functions together.`,
13+
);
14+
}
15+
}
16+
917
returnflags.has("enabled");
1018
}
1119

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file should never be imported
2+
module.exports=false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp