U
U
Umouse2020-06-01 13:31:05
JavaScript
Umouse, 2020-06-01 13:31:05

Why doesn't Electronjs see exports after it starts?

Good afternoon, I am currently writing an application using ElectronJS and Typescript.

Here is my application structure: Dependency
files:
tsconfig.json (I wrote tsc --init , changed rootDir value to "./src", and outDir value to "./dist")

package.json - there are two scripts, first just starts the tsc compiler and copies the .html/.css folder to the dist folder, and the second one runs the first script and then runs electron.
Here they are:

"build": "tsc && cp -r public dist",
"devStart": "npm run build && electron ./dist/main.js"


Here is the structure of my application:
src - storage location for .ts files. Inside there are publicScripts - scripts for the frontend
public - a place to store files for the front (namely html and css, not scripts)
dist - files from src are compiled here and public is copied.

5ed4d4269a85c469585902.jpeg

The problem itself:

I have a main.html file, an index.js file (already compiled file) is connected to it.
Here is the line from the "head" of my main.html (the path should be viewed from the ./dist/public folder, not from ./public):
<script defer src="../../publicScripts/index.js"></script>


In this script I have one import:
import {  generateScramble } from './exports/scrambleGenerator';


The scrambleGenerator has this line:
export function generateScramble(scrambleLen: number): string { // какой-то умный код }


The problem is that my IDE sees this import and even prompts to end the line. But when I run the script, my application simply does not see the exports folder and gives the following error:

5ed4d71e4817e177392515.jpeg

There is simply no exports folder in the application sources:

5ed4d756e5f76089599928.png

index.js sees imports when launched through node, but not when working in electron itself.

This is my problem, thanks to everyone who helps!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2020-06-02
@Aetae

Finger to the sky: try in tsconfig module: esnext.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question