-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to load tsconfig.json: Missing baseUrl in compilerOptions #32
Comments
Oops, I realised what's going on. There is another tsconfig in the same dir as
|
Uh... Actually I have no idea what's going on. :-( resolve: {
plugins: [
new TsconfigPathsPlugin({
baseUrl: __dirname,
configFile: path.join(appRoot, "tsconfig.json"),
extensions: [".js", ".ts", ".tsx"],
}),
],
}, output:
|
@Ky6uk is right, I just added Although the file I use to compile my Webpack config file extends from the same config that I use in the plugin. I guess TypeScript's extend config funcionality is not supported, yet. |
Another option: // helpers.ts
import { endsWith } from "lodash"
import * as path from "path"
function fromTsAlias(tsAlias: string) {
return endsWith(tsAlias, "/*")
? tsAlias.substring(0, tsAlias.length - 2)
: `${tsAlias}$`
}
function fromTsPath(tsPath: string) {
return endsWith(tsPath, "/*")
? tsPath.substring(0, tsPath.length - 2)
: tsPath
}
export function tsPathsToAlias(
appRoot: string,
paths: Record<string, ReadonlyArray<string>>
) {
return Object.entries(paths).reduce<Record<string, string>>(
(acc, [key, value]) => {
if (value.length !== 1) {
throw new TypeError(
`Unsupported TS alias ${key} has length ${value.length}`
)
}
acc[fromTsAlias(key)] = path.join(appRoot, fromTsPath(value[0]))
return acc
},
{}
)
} const config: Configuration = {
// ...
resolve: {
// ...
alias: tsPathsToAlias(appRoot, tsConfig.compilerOptions.paths),
}, |
I solve this problem by below code 👍 |
Ok now i have below one ..
:( |
Okey i got it to work. I was in a hurry and i didn't figured that i put my plugin initilization under resolve: {} property. I was configuring it under root plugin: [] property. So moving my configuration to resolve: {} fixes everything. const config: webpack.Configuration = {
plugins: [],
resolve: [
plugins: [
new TsconfigPathsPlugin({
configFile: path.resolve(__dirname, './tsconfig.json'),
extensions: ['.ts', '.tsx', '.js'],
logLevel: 'INFO',
baseUrl: path.resolve(__dirname, '.'),
mainFields: ['browser', 'main'],
}),
]
],
}``` |
i have same issue, but |
Can we have a fix for this? Also having the same problem. It simply doesn't work if you have |
Do you fancy having a go at working on this? PRs are generally gratefully received 🥰 |
@johnnyreilly Yes. Sorry about the tone. I will try to look into it over the weekend as I'm trying to use more of TS paths. |
I've got this problem when trying to setup Storybook with angular. I can't modify the |
I've filed dividab/tsconfig-paths#143 for this, but one place this will pop up again is in TS 4.1 and above, which don't require |
No idea what's going on here. My tsconfig.json:
project/tsonfig.json
webpack.config.ts
This error doesn't make sense because, firstly, tsconfig.json has a baseUrl, and secondly, it doesn't need one because I've included it in the options.
Also, this should kill the build rather than just logging. If it can't find the file then what's the point of continuing to run? The paths will not resolve.
The text was updated successfully, but these errors were encountered: