I'm trying to rollup an Angular 2 app but I have:
Could not resolve 'app/components/xxx/xxxxx.component' from xxxx\wwwroot\angular\app\app.module.js
The app.module have a reference to xxxxx.component like this:
import { xxxxx } from 'app/components/xxx/xxxxx.component'
so the tsconfig.js has:
"compilerOptions": {
...
"paths": {
"app/*": [ "./app/*" ],
...
},
"outDir": "wwwroot",
...
},
How can I resolve path aliases like typescript in rollup?
I tried with
1) https://github.com/frostney/rollup-plugin-alias
rollup-config.js:
export default {
entry: 'wwwroot/angular/app/main-aot.js',
dest: 'wwwroot/dist/build.js',
sourceMap: false,
format: 'iife',
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: 'node_modules/rxjs/**',
}),
alias({
'app': '.' // asuming "wwwroot/angular/app/" is the working dir
}),
uglify()
]
}
2) https://github.com/dot-build/rollup-plugin-includepaths
rollup-config.js:
let includePathOptions = {
include: {},
paths: ['../'], // asuming "wwwroot/angular/app/" is the working dir
external: [],
extensions: ['.js']
};
export default {
entry: 'wwwroot/angular/app/main-aot.js',
dest: 'wwwroot/dist/build.js',
sourceMap: false,
format: 'iife',
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: 'node_modules/rxjs/**',
}),
includePaths(includePathOptions),
uglify()
]
}
But none of those works. Any idea? Thanks in advance!!!
have you tried using the typescript plugin for rollup?
https://github.com/rollup/rollup-plugin-typescript
install with
npm install --save-dev rollup-plugin-typescriptimport in your rollup-config.js
import typescript from 'rollup-plugin-typescript';and be sure to add it into the plugins section like
plugins: [ typescript() ]depending on your project setup u might need to change dependency to use local typescript installation like