usage with `rollup-plugin-alias` -- put `alias` first and add `.ts` extension
See original GitHub issueFailed to find the modules
Environment
node v8.9.1
Versions
- typescript: 2.7.2
- rollup: 0.56.5
- rollup-plugin-typescript2: 0.12.0
rollup.config.js
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' ),
} ),
],
};
tsconfig.json
{
"compilerOptions": {
"target": "es2015"
}
}
package.json
{
"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"
}
}
TS files
// ./src/index.ts
import A from 'core/a';
export { A };
// ./src/core/a.ts
export default function () {
const x = 12;
console.log( x );
};
Error
rollup-demo/src/index.ts(1,15): semantic error TS2307 Cannot find module 'core/a'.
Problem
If use rollup-plugin-alias
alone, it will work.
but with rollup-plugin-typescript2
used together, it can’t find the module
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Rollup Angular 2 with typescript 2 path alias - Stack Overflow
I am using Angular 4 in an ASP.NET MVC environment and ran into the same problem when using "paths" in my tsconfig.json file....
Read more >Module Resolution or Import Alias: The Final Guide - Raul Melo
The first step is installing @rollup/plugin-alias. After that, in your rollup.config.js you import it and set it up:.
Read more >Alias Plugin + Rollup + Typescript - YouTube
If you try adding alias to your svelte + typescript project, you may run into a bug like.. [!] Error: Could not load...
Read more >@rollup/plugin-alias - npm
Start using @rollup/plugin-alias in your project by running `npm i ... in front of an import and append an extension, use a pattern...
Read more >Top 5 @rollup/plugin-alias Code Examples - Snyk
}), ignore(packageConfig.ignore || []), ts({ check: !hasTSChecked, tsconfig: path.resolve(__dirname, 'tsconfig.json') ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried this configuration. Set alias in front of typescript2 not helped =(
Likely plugin order thing