I have started working on an Electron-Forge/Svelte based application and I'm running into some issues early on with my setup properly referencing modules/stores during runtime.
Specifically this error: svelte.js:9 Uncaught ReferenceError: auth is not defined at svelte.js:9
Which is pointing to this line:
const app = new App({
target: document.body
});
Now, under the src directory I have the following subdirectories: ['src/stores', 'src/models', 'src/api', 'src/routes', 'src/services']
I use these to help break up where I put various things such as interfaces, stores, logic for external services and so on.
I am using VSCode, and at least during development I have no errors that indicate there are any issues resolving modules. That said, I'm not a front end guy, and there are things about the setup which I'm not happy with at the moment...the most important being it doesn't actually work.
So here is my tsconfig.js:
"compilerOptions": {
"allowJs": true,
"module": "commonjs",
"noImplicitAny": true,
"sourceMap": true,
"baseUrl": ".",
"outDir": "dist",
"moduleResolution": "node",
"resolveJsonModule": true,
"paths": {
"*": ["node_modules/*"]
}
},
"include": [
"src/**/*"
]
}
Here is my eslintrc.json:
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"parser": "@typescript-eslint/parser",
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"moduleDirectory": ["node_modules", "src/"]
}
}
}
}
One reason I know things aren't great just from a VSCode perspective is that I'm having to reference the modules from each other like this:
From routes/Home.svelte: import { authStore } from "stores/auth";
From api/service.ts: import { PlayerInterface } from "../models/player";
From stores/auth.ts: import { submitEmailForAuth, syncPlayer } from "../api/server"; import PlayerState from '../models/player'
I don't like the inconsistency with how they are referenced, but this is the way VSCode doesn't complain and I can at least build even if I get a runtime error. If I attempt to change the imports in the modules, other than Home.svelte, to be relative references I can't even compile because I get errors about finding those modules.
I have run out of ideas for why the code can't find auth on startup, and there is absolutely no stack trace for me to even begin to try to figure out what's wrong.