Skip to content

Getting "TypeError: t is not a function" when trying to replicate script import issue #209

Open
@SMen1

Description

@SMen1

I was getting the following error when trying to use vue.js composables and import a script js file.

'import' and 'export' may appear only with 'sourceType: "module"' (1:0)

I have tried to replicate the solutions here:
#44 and here
#14 (comment)

Specifically this solution:

async getFile(url) {
const res = await fetch(url);
if (!res.ok) throw Object.assign(new Error(url + " " + res.statusText), { res });
let content = await res.text();
content = url.endsWith("/test.js") ? { content: content, type: ".mjs" } : content;
return content;
},

Where the test.js file is :

export const user = {
userName: "root",
password: "zfs1111"
}

is giving me the error: TypeError: t is not a function in the console. I get the same error trying to import a non-test js file.

Is this an old solution that is no longer viable? What is the new solution if yes?

using Vue3.js

Versions

  • Browser (name & version):
  • vue3-sfc-loader:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions