Skip to content
This repository was archived by the owner on May 19, 2022. It is now read-only.

compilerOptions.paths must not be set (aliased imports are not supported) #34

Description

@thorlucas

Here's my setup:

// tsconfig.json
{
	"extends": "./tsconfig.paths.json",
	"compilerOptions": {
		"target": "es5",
		"lib": [
			"dom",
			"dom.iterable",
			"esnext"
		],
		"allowJs": true,
		"skipLibCheck": true,
		"esModuleInterop": true,
		"allowSyntheticDefaultImports": true,
		"strict": true,
		"forceConsistentCasingInFileNames": true,
		"noFallthroughCasesInSwitch": true,
		"module": "esnext",
		"moduleResolution": "node",
		"resolveJsonModule": true,
		"isolatedModules": true,
		"noEmit": true,
		"jsx": "react-jsx"
	},
	"include": [
		"src"
	]
}

Then, I created a tsconfig.paths.json:

// tsconfig.paths.json
{
	"compilerOptions": {
		"baseUrl": "./src",
		"paths": {
			"@components/*": ["components/*"]
		}
	}
}

Finally, my craco config:

// craco.config.js
module.exports = {
	style: {
		postcss: {
			plugins: [
				{
					plugin: require('craco-alias'),
					source: "tsconfig",
					baseUrl: "./src",
					tsConfigPath: "./tsconfig.paths.json",
					debug: true,
				},
				require('tailwindcss'),
				require('autoprefixer'),
			],
		},
	},
}

And yet:

-> yarn build
yarn run v1.22.10
$ craco build
The following changes are being made to your tsconfig.json file:
  - compilerOptions.paths must not be set (aliased imports are not supported)

Creating an optimized production build...
Failed to compile.

./src/index.tsx
Cannot find module: '@components/App'. Make sure this package is installed.

You can install this package by running: yarn add @components/App.


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions