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

Q: Compatibility with typescript #1495

Open
basz opened this issue May 30, 2023 · 10 comments
Open

Q: Compatibility with typescript #1495

basz opened this issue May 30, 2023 · 10 comments

Comments

@basz
Copy link
Contributor

basz commented May 30, 2023

Hi,

I have an working application that I want to convert to typescript.

Looking at https://github.com/electron/forge there is a typescript template that indeed runs when being a stand alone electron app.

However in ember-electron this does not seem to work... I think becuase ember-electron run forge via its 'api' and therefore uses ts config from the enclosing ember app.

This works

cd electron-app
yarn electron-forge start

But this will fail;

ember electron
Starting Electron...
Failed to load: /..../electron-app/forge.config.ts
Cannot use import statement outside a module

Is this even possible? Perhaps any example repositories?

@RobbieTheWagner
Copy link
Member

@basz I use TypeScript for the Ember side, but not the Electron side.

@basz
Copy link
Contributor Author

basz commented May 30, 2023

yeah. now i know why... pita... anyway a bit further

added this to the root tsconfig.json

"target": "ES2020",
"module": "commonjs",

App compiles, and starts. I see a window with

Compiled with problems:
×
ERROR
Module not found: Error: Can't resolve './src/renderer.ts' in '/path/to/app'

Soo it loads the main entry point. Feel like I am really close...

@basz
Copy link
Contributor Author

basz commented May 30, 2023

Yes. I now have the template typescript app running as an ember-electron application! Runs as yarn electron-forge start and as ember electron

trick was to use __dirname inside the forge.config.ts

entryPoints: [
          {
            html: __dirname + '/src/index.html',
            js: __dirname + '/src/renderer.ts',
            name: 'main_window',
            preload: {
              js: __dirname + '/src/preload.ts',
            },
          },
        ],

@bendemboski
Copy link
Member

@basz this is awesome! I've long wanted to figure out how to start writing main process code in typescript. Thanks so much for pioneering! Would you be willing to write up some documentation, like a little how-to or something? I'm happy to support in any way.

@basz
Copy link
Contributor Author

basz commented May 30, 2023

Yes! Ping me if I forget

@basz
Copy link
Contributor Author

basz commented May 31, 2023

@basz
Copy link
Contributor Author

basz commented Jun 5, 2023

not sure if that setup is complete. Although it runs with typescript it is also webpack'ed. That is a whole new beast to configure. The "old" method of loading file://path/to/app/emebr-dist/index.html' seems to work, but the template starter actually uses real url's http://localhost:3000/main_window`. These should have the ember app packed into it I'm guessing. Unfortunately I don't know how to to that properly :-/

@basz
Copy link
Contributor Author

basz commented Jun 6, 2023

@bendemboski any thoughts?

@bendemboski
Copy link
Member

Sorry, I don't really, I haven't had a chance to dig into this at all

@basz
Copy link
Contributor Author

basz commented Jun 14, 2023

for any one that needs a starting point. https://github.com/basz/ember-electron-app/

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

3 participants