Description
Is this a bug report?
Yes this is a bug.
JS files under a symlinked directory within ./src are not compiled.
If the directory is not sym-linked -- and instead, a regular directory, -- no problems.
Ability to do this often needed when developer wants to share a library across multiple react/react-native projects.
Also I believe this issue is directly related (or a duplicate) of
#3547
It is not clear how 3547 was solved, and there are no user documentation/guide changes that address the problem.
Another similar issue form about 9 months ago:
#2553
Did you try recovering your dependencies?
Not applicable
Which terms did you search for in User Guide?
symlinks, Windows symlinks , module parse failed unexpected token
Environment
node -v
: v9.8.0npm -v
: 5.6.0yarn --version
(if you use Yarn): 1.5.1npm ls react-scripts
(if you haven’t ejected):
[email protected] `-- UNMET DEPENDENCY [email protected]
npm ERR! missing: [email protected], required by [email protected]
(I have not ejected, and app was created by create-react-app )
Then, specify:
- Operating system: windows 10
- Browser and version (if relevant): IE 11
Steps to Reproduce
- create an app with create-react-app
- go to src directory and create a symbolic link (on windows, I use Cygwin ln -s command to do that, as administrator)
- Create any react component file it the symlinked directory
For example, my test file (I use react-native-web) is:
/* global fetch */
import React,{Component} from 'react'
import {View,Text, Platform} from 'react-native'
export class VTestComponent extends React.Component {
constructor (props) {
super (props);
}
render () {
return (
<View >
<Text> VTestComponent </Text>
</View>
);
}
}/*end of VTestComponent class */
-
import the component in your App.js
import {VTestComponent} from './js.app/VTestComponent'; -
run: npm start
You will get an error
module parse failed: Unexpected token (13:6)
You may need an appropriate loader to handle this file type.
| render () {
| return (
|
| VTestComponent
|
it should have compiled. There is no mention in the user documentation that it would not work
(the symlinked directory is under the ./src directory).
Also not clear what configurations to package.json or something else needs to be made -- for this to work.
my package.json (produced by create-react app, plus my own additive changes) is below:
(it also includes, of course react-scripts)
{
"name": "ua1b",
"version": "0.1.0",
"private": true,
"dependencies": {
"create-react-class": "15.6.3",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-native-deprecated-custom-components": "github:facebookarchive/react-native-custom-components",
"react-native-material-kit": "github:xinthink/react-native-material-kit#master",
"react-native-section-list-get-item-layout": "2.2.1",
"react-native-vector-icons": "^4.5.0",
"react-native-web": "^0.5.4",
"react-scripts": "1.1.4",
"tree-model": "^1.0.6"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"babel-plugin-react-native-web": "^0.5.4"
}
}
thank you.