awesome-typescript-loader
awesome-typescript-loader copied to clipboard
Advanced Path Resolution is Adversely Affecting Relative Paths
I have the following project structure:
app
--core
----layout
------layout.component.ts/html/scss
------layout.component.spec.ts
testing
--router-stubs.ts
I have the following tsconfig file:
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "dist",
"typeRoots": [
"node_modules/@types"
]
}
}
In my spec file, I want to be able to reference a relative path, and an absolute path:
import { LayoutComponent } from "./layout.component";
import { RouterOutletStubComponent } from "testing/router-stubs";
So, I tried adding the TSConfigPathsPlugin:
var TsConfigPathsPlugin = require('awesome-typescript-loader').TsConfigPathsPlugin;
resolve: {
plugins: [
new TsConfigPathsPlugin()
]
}
But I always get the following error message:
ERROR in ./app/core/layout/layout.component.spec.ts
Module not found: Error: Can't resolve './layout.component' in 'C:\Code\Storm\Storm.Website\app\core\layout'
@ ./app/core/layout/layout.component.spec.ts 4:25-54
@ ./app \.spec\.ts
I have tried putting in several values for the config into TsConfigPathsPlugin(), but the error message never seems to change. As soon as I take out the TsConfigPathsPlugin() reference and change the "testing" path to be a relative path, then it works just fine.
Also, to rule out Karma interference, I tried running the webpack server with this TSConfigPathsPlugin, and it also fails with some module resolution errors.
Did you manage to solve this?