Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript import from file works only once. #342

Closed
thunderkid opened this issue Mar 14, 2019 · 2 comments
Closed

Typescript import from file works only once. #342

thunderkid opened this issue Mar 14, 2019 · 2 comments

Comments

@thunderkid
Copy link

thunderkid commented Mar 14, 2019

Issue description or question

I am importing a typescript function from a local folder. When I choose
Quokka | Start On Current File,
it works fine, but only once. If I then start making changes to the main.ts file it tries to automatically rerun, but fails with an 'Emit Skipped' error.
I have ts-node installed, and ts-paths, and I've tried it with and without alias-quokka-plugin.

Sample code

// Imports from installed modules run fine on every keystroke
import { sha256 } from 'js-sha256';
const xs = sha256('here we go');   // changing the text here makes xs change instantly
xs

// But this stuff only runs the first time I explicitly run quokka. Then it gives 'Emit Skipped' error.

import { to2dp2 } from './common/ts/utils2';

const ss = to2dp2(3.81239415926);
ss

I'm importing from this file (utils2.ts):

export function to2dp2(x: number): number {
    return Math.round((x + 0.00001) * 100) / 100;
}

This is my .quokka file:

{
  "pro": true,
  "babel": true,
}

Quokka.js Console Output

The first time it runs fine. On subsequent keystrokes it gives this:

​​​​Quokka 'quokkatest.ts' (node: v10.15.1, TypeScript: v3.3.3333, plugins: alias-quokka-plugin)​​​​
 
common\ts\utils2.ts: Emit skipped 
  at ​​​getOutput​​​ ​./node_modules/ts-node/src/index.ts:337​
  at ​​​Object.compile​​​ ​./node_modules/ts-node/src/index.ts:367​
  at ​​​Module.m._compile​​​ ​./node_modules/ts-node/src/index.ts:413​
  at ​​​Module._extensions..js​​​ ​internal/modules/cjs/loader.js:700​
  at ​​​Object.require.extensions.(anonymous function) [as .ts]​​​ ​./node_modules/ts-node/src/index.ts:416​
  at ​​​Module.load​​​ ​internal/modules/cjs/loader.js:599​
  at ​​​tryModuleLoad​​​ ​internal/modules/cjs/loader.js:538​
  at ​​​Module._load​​​ ​internal/modules/cjs/loader.js:530​
  at ​​​Function.Module._load.rest [as _load]​​​ ​./node_modules/alias-quokka-plugin/src/main.js:34​
  at ​​​require​​​ ​internal/modules/cjs/helpers.js:22​
  at ​​​Object.<anonymous>​​​ ​quokkatest.ts:10​
  at ​​​Module._compile​​​ ​internal/modules/cjs/loader.js:689​
 
8f03973c6b88d93330eaf35c1e18baa6261c6b74a23c2b07d958ba0cca2eeec0 
  at ​​​xs​​​ ​quokkatest.ts:6:0​

Code editor version

Visual Studio Code v1.32.2

OS name and version

Windows 10Pro build 17134

@thunderkid
Copy link
Author

Ok, after much fiddling, I think I've solved the problem. My tsconfig contained:

"noEmitOnError": true

When I removed this line, the problem went away.

So I guess my much more minor question is whether it's possible to just turn off noEmitOnError for quokka, without affecting my existing tsconfig. And I didn't see any mention of noEmitOnError in the docs, so perhaps a comment about this could be added there?

@smcenlly
Copy link
Member

@thunderkid, it's definitely possible to override your tsconfig for quokka. You can read more about how to do this in our docs. In short, you'll need to override the settings you don't want for Quokka in your Quokka configuration (you can read more in the docs about how to configure Quokka).

Please find an example override below:

{
    "ts": {
        "compilerOptions": {
            "noEmitOnError": false
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants