question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

usage with `rollup-plugin-alias` -- put `alias` first and add `.ts` extension

See original GitHub issue

Failed 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:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

23reactions
viT-1commented, Aug 22, 2019

I tried this configuration. Set alias in front of typescript2 not helped =(

6reactions
ezolenkocommented, Jun 22, 2018

Likely plugin order thing

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found