Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

ES6 imports not resolving properly with typescript #311

Open
sploders101 opened this issue Sep 18, 2018 · 0 comments
Open

ES6 imports not resolving properly with typescript #311

sploders101 opened this issue Sep 18, 2018 · 0 comments

Comments

@sploders101
Copy link

sploders101 commented Sep 18, 2018

Long version

When using typescript with electron-compile, the typescript compiler will resolve to commonjs, requiring commonjs variants of ES6-imported modules. Many times, this is acceptable, but for things like vue-router and sfc's, which have separate es6-style variants declared as "module" in their package.json, it is not, because the structure of the exported object is different depending on the javascript standard you use. There is an option in the tsconfig.json's compiler options ("module": "es2015",) that you can use to counter this, but then it exports as es6 javascript, which cannot be sent directly to node, but needs to be compiled again through babel or a similar precompiler. It is possible to write functional code the way it is, but it doesn't play nice with editors that support typescript, which kind of defeats the purpose. It would be nice if we could have a gulp-like configuration, where we can pipe code through multiple compilers before sending it to node, but that's probably overkill.

TLDR

Typescript currently resolves package names to their commonjs variants when using "module": "commonjs". In order to work properly with editors like vscode and atom, we need to use ES6 syntax, so it must be changed to "module": "es6" which outputs code that is not syntactically correct for node, and must be pre-compiled again with babel before being sent to node.

Any help would be appreciated

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

No branches or pull requests

1 participant