Description
I'm currently facing problems with importing files from symlinked folders.
Consider this example filestructure
app/
├── core/
│ ├── configuration/
│ ├── Player.js
│ └── GameServer.js
├── client/ << create-react-app
│ ├── build/
│ ├── public/
│ └── src/
│ ├── components/
│ │ └── Game.js
│ └── lib/
│ └── core/ -> ../../../core/ (SYMLINK)
/core/Player.js
export default class Player {
constructor(
name,
color,
position={x:0, y:0, z:0},
velocity={x:0, y:0, z:0},
rotation={x:0, y:0, z:0}
) {}
[...]
/client/src/components/Game.js
import React, { Component } from 'react';
import Player from '../../../lib/core/Player';
class Game extends Component {
constructor(props) {
console.log(Player);
}
}
export default Game;
When having this file in /client/src/lib everything works fine, but when moving the file to the subfolder core, which is a symlink to the root of the project, things start to break.
I'm unfortunately still trying to figure out, what exactly goes wrong, but it must have to do with the webpack configuration, I think. Importing normal configuration objects from this symlink work like a charm, but something is happening (or not happening), when importing classes.
When importing from /client/src/lib console.log outputs the following:
function Player(name, color) {
var position = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { x: 0, y: 0, z: 0 };
var velocity = arguments.length > 3 && arguments[3] !== …
While, when importing from the symlink /client/src/lib/core console.log outputs the following:
class Player {
constructor(name, color, position={x:0, y:0, z:0}, velocity={x:0, y:0, z:0}, rotation={x:0, y:0, z:0}) {....}
Expected behavior
Since I'm technically still in /src I would expect that the code is treated the same way, even though I'm importing from a symlinked folder.
Actual behavior
So some compiling doesn't happen, when importing from symlinks. Is this correct? Should this happen?
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts (if you haven’t ejected):
xxx@0.1.0 /WebstormProjects/xxx/client
└── react-scripts@1.0.7
node -v: v6.11.0
npm -v: 3.10.10
Then, specify:
- Operating system: macOS 10.12.5
- Browser and version: Google Chrome Version 58.0.3029.110 (64-bit)
Reproducible Demo
Will provide a demo if needed.
Description
I'm currently facing problems with importing files from symlinked folders.
Consider this example filestructure
/core/Player.js
/client/src/components/Game.js
When having this file in
/client/src/libeverything works fine, but when moving the file to the subfoldercore, which is a symlink to the root of the project, things start to break.I'm unfortunately still trying to figure out, what exactly goes wrong, but it must have to do with the webpack configuration, I think. Importing normal configuration objects from this symlink work like a charm, but something is happening (or not happening), when importing classes.
When importing from
/client/src/libconsole.log outputs the following:While, when importing from the symlink
/client/src/lib/coreconsole.log outputs the following:Expected behavior
Since I'm technically still in
/srcI would expect that the code is treated the same way, even though I'm importing from a symlinked folder.Actual behavior
So some compiling doesn't happen, when importing from symlinks. Is this correct? Should this happen?
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts(if you haven’t ejected):node -v:v6.11.0npm -v:3.10.10Then, specify:
Reproducible Demo
Will provide a demo if needed.