RogueMan
RogueMan
DDeno
Created by RogueMan on 12/2/2024 in #help
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!');
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}\));
}
}
}
}
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"
}
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
11 replies
DDeno
Created by RogueMan on 11/30/2024 in #help
Root path when compiled
Is it possible to get the "root" path when running an executable? I can't seem to get it to work... So for example I would like to get the following: C:\Users\Admin\AppData\Local\Temp\deno-compile-test.exe\deno-testing\src\
1 replies
DDeno
Created by RogueMan on 11/12/2024 in #help
Dynamic import at compile time
I am trying to import files dynamically based on a glob pattern. These files are not imported correctly when I compile the application. It only works with a static string. Is there any way to make it work with the glob pattern? or is there a workaround? Or do I just have to import the files using static strings
20 replies