RogueManR
Denoβ€’14mo agoβ€’
10 replies
RogueMan

Executable having trouble with types

I'm encountering a syntax error when trying to import files when running an executable, specifically with type imports.
I have included the entire ./src/modules/test directory into the binary

When running a compiled binary, I'm getting a SyntaxError related to type imports.

Here's the specific code causing issues:
path: ./src/modules/test/commands/testing.ts
import { type Config } from '@types';

const config = {} as Config;
console.log('Hello, world!');


Function used to import files:
this is the code that imports the files:
/**
 * Dynamically import all files matching the glob pattern
 * @param globPath - The glob pattern to match files
 */
export async function importer(globPath: string) {
    if (Deno.args.includes('--is_compiled_binary')) {
        // Import the manifest file and import all files listed in it
        const { default: manifest } = await import(import.meta.resolve('../../../manifest.json'));

        for (const module of manifest.modules) {
            for await (const commandFiles of Deno.readDir(${join(import.meta.dirname!, '../../../')}${module}/commands)) {
                await import(import.meta.resolve(`file:///${join(import.meta.dirname!, '../../../')}${module}\\commands\\${commandFiles.name}\));
            }
        }
    }
}


Full Error Message:
SyntaxError: Unexpected identifier 'Config' at file:///C:/Users/renor/AppData/Local/Temp/deno-compile-bot.exe/deno-discord-bot-template/src/modules/testing/commands/testing.ts:1:15
    at async importer (file:///C:/Users/renor/AppData/Local/Temp/deno-compile-bot.exe/deno-discord-bot-template/src/utils/functions/files.ts:12:52)
    at async Function.main (file:///C:/Users/renor/AppData/Local/Temp/deno-compile-bot.exe/deno-discord-bot-template/src/main.ts:55:7) {
  code: "ERR_MODULE_NOT_FOUND"
}


Deno Version: 2.1.2
Was this page helpful?