node v8.9.1
const path = require('path');
import typescript from 'rollup-plugin-typescript2';
import alias from 'rollup-plugin-alias';
export default {
input: './src/index.ts',
output: {
file: 'build.js',
format: 'umd',
name: 'build',
},
plugins: [
typescript( ),
alias( {
core: path.resolve( __dirname, './src/core' ),
} ),
],
};
{
"compilerOptions": {
"target": "es2015"
}
}
{
"name": "rollup-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "rollup -c ./rollup.config.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"rollup": "^0.56.5",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-typescript2": "^0.12.0",
"typescript": "^2.7.2"
}
}
// ./src/index.ts
import A from 'core/a';
export { A };
// ./src/core/a.ts
export default function () {
const x = 12;
console.log( x );
};
rollup-demo/src/index.ts(1,15): semantic error TS2307 Cannot find module 'core/a'.
If use rollup-plugin-alias
alone, it will work.
but with rollup-plugin-typescript2
used together, it can't find the module
Did you try placing alias() in front of typescript()?
Can you work around this by using baseUrl
in tsconfig?
See more info here:
https://decembersoft.com/posts/say-goodbye-to-relative-paths-in-typescript-imports/
Likely plugin order thing
I tried this configuration. Set alias in front of typescript2 not helped =(
I met the same problem when using @rollup/plugin-alias
and @rollup/plugin-typescript
.
Moving alias
bebind typescript
solve the problem.
Most helpful comment
I tried this configuration. Set alias in front of typescript2 not helped =(