polyipseity / obsidian-modules

Load JavaScript and related languages like TypeScript modules from the vault and the Internet.
GNU Affero General Public License v3.0
68 stars 4 forks source link

TypeScript modules are not transpiled #7

Closed mnaoumov closed 9 months ago

mnaoumov commented 9 months ago

Consider

!Scripts/test.ts

export function sayHello(name: string) {
  console.log(`hello ${name}`);
}

and invoke from the Developer Tools console

const test = await self.require.import("!Scripts/test.ts");

getting the following error

Uncaught SyntaxError: Unexpected token ':' (at b5a75570-0ba1-44db-bdce-bba3945b3b6f:1:265)

The error occurred because the TypeScript code wasn't transpiled and used as it