You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to get this library to work with a multi-platform RN project running on IOS, Android, and Web, I stumbled upon this error when compiling the web version.
> node_modules/@react-native-segmented-control/segmented-control/js/SegmentedControl.js:18:12: error: Expected "from" but found "{"
18 │ import type {SegmentedControlProps} from './types';
╵ ^
Error: Build failed with 1 error:
node_modules/@react-native-segmented-control/segmented-control/js/SegmentedControl.js:18:12: error: Expected "from" but found "{"
at failureErrorWithLog (/Users/skysail/Documents/Navigraph/charts-rn/node_modules/esbuild/lib/main.js:1449:15)
at /Users/skysail/Documents/Navigraph/charts-rn/node_modules/esbuild/lib/main.js:1131:28
at runOnEndCallbacks (/Users/skysail/Documents/Navigraph/charts-rn/node_modules/esbuild/lib/main.js:921:63)
at buildResponseToResult (/Users/skysail/Documents/Navigraph/charts-rn/node_modules/esbuild/lib/main.js:1129:7)
at /Users/skysail/Documents/Navigraph/charts-rn/node_modules/esbuild/lib/main.js:1236:14
at /Users/skysail/Documents/Navigraph/charts-rn/node_modules/esbuild/lib/main.js:609:9
at handleIncomingPacket (/Users/skysail/Documents/Navigraph/charts-rn/node_modules/esbuild/lib/main.js:706:9)
at Socket.readFromStdout (/Users/skysail/Documents/Navigraph/charts-rn/node_modules/esbuild/lib/main.js:576:7)
at Socket.emit (node:events:369:20)
at Socket.emit (node:domain:470:12) {
errors: [
{
detail: undefined,
location: [Object],
notes: [],
pluginName: '',
text: 'Expected "from" but found "{"'
The project uses Vite, which in turn means that the build process is handled by Rollup and esbuild. After looking at the suggested solution in #242 , I implemented something similar for Vite, but then I realized that it wasn't the compiler that was at fault. Rather, the compiler is having issues interpreting TypeScript (Types/Interfaces) and TSX from the source files, since their extensions seem to suggest that the content is supposed to be JavaScript (.js, not .jsx thus the issue with interpreting the JSX syntax).
Temporary solution
In order to verify my theory, I went ahead and stripped out all the TS syntax and replaced the file extensions with .jsx and it immediately started working.
Question
Are these files intended to be .js files with TSX syntax? It seems wrong, perhaps some compilation step is not working correctly? Or am I doing something wrong here? I am not sure how it is working for anyone else in this configuration, which could very well mean that I am just doing something incorrectly.
The text was updated successfully, but these errors were encountered:
Alright, so I see now that these files use flow, which would explain the types I guess? But even after adding flow support to the compiler, the extensions are still wrong which causes this error:
> node_modules/@react-native-segmented-control/segmented-control/js/SegmentedControl.js:70:4: error: Unexpected "<"
70 │ <View
╵ ^
Error: Build failed with 1 error:
node_modules/@react-native-segmented-control/segmented-control/js/SegmentedControl.js:70:4: error: Unexpected "<"
at failureErrorWithLog (D:\CreativeThings\CodeStuff\Navigraph\chartsrn\node_modules\esbuild\lib\main.js:1449:15)
at D:\CreativeThings\CodeStuff\Navigraph\chartsrn\node_modules\esbuild\lib\main.js:1131:28
at runOnEndCallbacks (D:\CreativeThings\CodeStuff\Navigraph\chartsrn\node_modules\esbuild\lib\main.js:921:63)
at buildResponseToResult (D:\CreativeThings\CodeStuff\Navigraph\chartsrn\node_modules\esbuild\lib\main.js:1129:7)
at D:\CreativeThings\CodeStuff\Navigraph\chartsrn\node_modules\esbuild\lib\main.js:1236:14
at D:\CreativeThings\CodeStuff\Navigraph\chartsrn\node_modules\esbuild\lib\main.js:609:9
at handleIncomingPacket (D:\CreativeThings\CodeStuff\Navigraph\chartsrn\node_modules\esbuild\lib\main.js:706:9)
at Socket.readFromStdout (D:\CreativeThings\CodeStuff\Navigraph\chartsrn\node_modules\esbuild\lib\main.js:576:7)
at Socket.emit (node:events:365:28)
at Socket.emit (node:domain:470:12) {
errors: [
{
detail: undefined,
location: [Object],
notes: [],
pluginName: '',
text: 'Unexpected "<"'
}
],
warnings: []
}
error Command failed with exit code 1.
The compiler that I use does not bother checking .js files for JSX syntax because of performance reasons. Here is a tweet reasoning about this very fact. Even if I wish that this library would use the correct extension, I now at least know the root cause of the issues I was experiencing.
When trying to get this library to work with a multi-platform RN project running on IOS, Android, and Web, I stumbled upon this error when compiling the web version.
The project uses Vite, which in turn means that the build process is handled by Rollup and esbuild. After looking at the suggested solution in #242 , I implemented something similar for Vite, but then I realized that it wasn't the compiler that was at fault. Rather, the compiler is having issues interpreting TypeScript (Types/Interfaces) and TSX from the source files, since their extensions seem to suggest that the content is supposed to be JavaScript (
.js
, not.jsx
thus the issue with interpreting the JSX syntax).Temporary solution
In order to verify my theory, I went ahead and stripped out all the TS syntax and replaced the file extensions with
.jsx
and it immediately started working.Question
Are these files intended to be
.js
files with TSX syntax? It seems wrong, perhaps some compilation step is not working correctly? Or am I doing something wrong here? I am not sure how it is working for anyone else in this configuration, which could very well mean that I am just doing something incorrectly.The text was updated successfully, but these errors were encountered: