Is this a bug report?
Yes
Did you try recovering your dependencies?
Yes
Environment
Environment Info:
System:
OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.15.2 - ~/.yarn/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.15.3/bin/npm
Browsers:
Chrome: 73.0.3683.86
Firefox: 66.0.3
npmPackages:
react: 16.8.6 => 16.8.6
react-dom: 16.8.6 => 16.8.6
react-scripts: 3.0.0 => 3.0.0
npmGlobalPackages:
create-react-app: Not Found
Steps to Reproduce
Given the project structure:
src/
- components/
---- YoutubePlaylist.tsx
---- YoutubePlaylist.module.css
- res/
---- breakpoints.css
tsconfig.json
- Configure baseUrl in tsconfig.json (or jsconfig.json)
{
"compilerOptions": {
"baseUrl": "src",
}
}
- Use the following code snippet anywhere in a CSS module
@value tablet from "res/breakpoints.css";
-
Run npm start
-
See the following error message:
Failed to compile.
./src/components/YoutubePlaylist.module.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-6-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-6-3!./src/components/YoutubePlaylist.module.scss)
Module not found: Can't resolve './res/breakpoints.css' in '/home/jamsch/Documents/test-site/client/src/components'
Expected Behavior
Module resolution should be relative to the src directory.
Actual Behavior
Module resolution attempts to resolve relative to the directory the file is importing from.
Additional info
I had this configured for v2 using aliases, react-app-rewired, & customize-cra
./config-overrides.js
const path = require("path");
const { override, addWebpackAlias } = require("customize-cra");
module.exports = override(
addWebpackAlias({
"~": path.resolve(__dirname, "src")
})
);
./tsconfig.json -- CRA was hard removing paths so I was forced to do this:
{
"extends": "./paths.json",
}
./paths.json
{
"compilerOptions": {
"baseUrl": "src",
"rootDir": ".",
"paths": {
"~/*": ["*"]
}
}
}
./src/components/YoutubePlaylist.module.scss
@value tablet from "~/res/breakpoints.css";
On v2 this works fine, but on v3 it seems to import from the root dir.
Module not found: You attempted to import ../../../../../../../../../res/breakpoints.css which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
Is this a bug report?
Yes
Did you try recovering your dependencies?
Yes
Environment
Steps to Reproduce
Given the project structure:
{ "compilerOptions": { "baseUrl": "src", } }Run
npm startSee the following error message:
Expected Behavior
Module resolution should be relative to the src directory.
Actual Behavior
Module resolution attempts to resolve relative to the directory the file is importing from.
Additional info
I had this configured for v2 using aliases, react-app-rewired, & customize-cra
./config-overrides.js
./tsconfig.json -- CRA was hard removing paths so I was forced to do this:
{ "extends": "./paths.json", }./paths.json
{ "compilerOptions": { "baseUrl": "src", "rootDir": ".", "paths": { "~/*": ["*"] } } }./src/components/YoutubePlaylist.module.scss
On v2 this works fine, but on v3 it seems to import from the root dir.
Module not found: You attempted to import ../../../../../../../../../res/breakpoints.css which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.