Hi guys,
I am trying to migrate my project to webpack, but I’ve been struggling a lot with this issue:
ERROR in ./app/app.component.ts
Module not found: Error: Can't resolve '@common' in
@ ./app/app.component.ts 16:16-34
@ ./app/app.module.ts
@ ./app/main.ts
I have a custom library that I want to include in my build, this library was created with typescript and AMD modules. I’m also using an index file to re-export stuff and the import everything with something like:
import { a,b,c,d,e,f,g } from '@common'
I have the following project structure:
--app/
-----dir1/
-----app.module.ts
-----app.component.ts
-----main.ts
--scripts/
---_app/
-----common.d.ts
-----common.js
--webpack.config.js
--tsconfig.js
My webpack.config:
entry: {
vendor: './src/vendor',
//util: './scripts/_app/util.js',
//common: './scripts/_app/common.js',
app: './app/main'
},
output: {
filename: "[name].js",
path: __dirname + "/dist",
// Making sure the CSS and JS files that are split out do not break the template cshtml.
publicPath: "/dist/",
// Defining a global var that can used to call functions from within ASP.NET Razor pages.
library: "app",
libraryTarget: "var"
},
resolve: {
// Add ".ts" and ".tsx" as resolvable extensions.
extensions: [".js", ".tsx", ".ts", ".json", ".html"],
modules: [
path.resolve('.'),
path.join(__dirname, "./scripts/_app"),
path.resolve('./node_modules')
]
},
module: {
loaders: [
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
{
test: /\.tsx?$/,
loader: 'ts-loader'
},
I tried with ts-loader and awesome-typescript-loader with no luck.
It looks like you just deleted/ignored our lovely crafted issue template. It was there for good reasons. Please help us solving your issue by answering the questions asked in this template. I’m closing this. Please open a new issue with filled issue template. Also make sure your issue is not a question. Questions should be posted on Stack Overflow.