nklayman / vue-cli-plugin-electron-builder

Easily Build Your Vue.js App For Desktop With Electron
https://nklayman.github.io/vue-cli-plugin-electron-builder/
MIT License
4.12k stars 278 forks source link

Class properties not supported with TypeScript #1833

Open RichardDorian opened 2 years ago

RichardDorian commented 2 years ago

Describe the bug Class propertiesm, when used in the main process are causing a crash because babel doesn't know how to transpile this. There's an official babel plugin for this but I don't know how to apply it to ts-loader

To Reproduce Create a class with class properties and use this class in the main process.

Something like this should do it

class Test {
  public static readonly FOO = 'bar';
}

const test = new Test();

Expected behavior Should transpile this

Environment (please complete the following information):

vue info ``` Environment Info: System: OS: Windows 10 10.0.22000 CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor Binaries: Node: 16.17.0 - D:\Programs\NodeJS\node.EXE Yarn: Not Found npm: 8.15.0 - D:\Programs\NodeJS\npm.CMD Browsers: Chrome: Not Found Edge: Spartan (44.22000.120.0), Chromium (105.0.1343.33) npmPackages: @vue/babel-helper-vue-jsx-merge-props: 1.2.1 @vue/babel-helper-vue-transform-on: 1.0.2 @vue/babel-plugin-jsx: 1.1.1 @vue/babel-plugin-transform-vue-jsx: 1.2.1 @vue/babel-preset-app: 5.0.4 @vue/babel-preset-jsx: 1.2.4 @vue/babel-sugar-composition-api-inject-h: 1.2.1 @vue/babel-sugar-composition-api-render-instance: 1.2.4 @vue/babel-sugar-functional-vue: 1.2.2 @vue/babel-sugar-inject-h: 1.2.2 @vue/babel-sugar-v-model: 1.2.3 @vue/babel-sugar-v-on: 1.2.3 @vue/cli-overlay: 5.0.4 @vue/cli-plugin-babel: ~5.0.0 => 5.0.4 @vue/cli-plugin-router: 5.0.4 @vue/cli-plugin-typescript: ~5.0.0 => 5.0.4 @vue/cli-plugin-vuex: ~5.0.0 => 5.0.4 @vue/cli-service: ~5.0.0 => 5.0.4 @vue/cli-shared-utils: 5.0.4 (4.5.17) @vue/compiler-core: 3.2.36 @vue/compiler-dom: 3.2.36 @vue/compiler-sfc: 3.2.36 @vue/compiler-ssr: 3.2.36 @vue/component-compiler-utils: 3.3.0 @vue/devtools-api: 6.1.4 @vue/reactivity: 3.2.36 @vue/reactivity-transform: 3.2.36 @vue/runtime-core: 3.2.36 @vue/runtime-dom: 3.2.36 @vue/server-renderer: 3.2.36 @vue/shared: 3.2.36 @vue/web-component-wrapper: 1.3.0 typescript: ~4.5.5 => 4.5.5 vue: ^3.2.13 => 3.2.36 vue-class-component: ^8.0.0-0 => 8.0.0-rc.1 vue-cli-plugin-electron-builder: ~2.1.1 => 2.1.1 vue-hot-reload-api: 2.3.4 vue-loader: 17.0.0 (15.9.8) vue-style-loader: 4.1.3 vue-template-es2015-compiler: 1.9.1 vuex: ^4.0.0 => 4.0.2 npmGlobalPackages: @vue/cli: Not Found ``` I am using `nvm` that's why it says @vue/cli isn't installed as global but it is.

Additional context If you know how I can add the babel plugin please tell me, I don't even know if the babel plugin works with ts-loader. It would be cool to already have this since those class properties are very used when using TypeScript.

MatthijsBurgh commented 2 years ago

I don't have the knowledge either.

For other people, please include more information.

RichardDorian commented 2 years ago

This is reproducible with the VueJS 3 TypeScript preset initialized with @vue/cli and running vue add electron-builder. Anything more to do unless of course writing the code that breaks ts-loader

MatthijsBurgh commented 2 years ago

Only V3-alpha use Vue3. As this is an alpha and the main maintainer and I do not have that much time. I can't help you for now.

MatthijsBurgh commented 2 years ago

This is reproducible with the VueJS 3 TypeScript preset initialized with @vue/cli and running vue add electron-builder. Anything more to do unless of course writing the code that breaks ts-loader

I would be really easy for other people to help you, when you create a small example project instead of demanding that from the people that want to help you.

RichardDorian commented 2 years ago

Here is the project: class-properties.zip

I also needed to manually update ts-loader because otherwise it doesn't compile at all. I updated it to ts-loader@^8.4.0

And here is the error: image

MatthijsBurgh commented 1 year ago

Probably similar, not the same, solution required as https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/1924

travislaynewilson commented 1 year ago

This is really hurting me as well.

DMiradakis commented 9 months ago

Yep having serious pain points with this right now, actually.