Skip to content

Webpack 5: import declarations may only appeaar at the top level of a module #105

Open
@dandansoysauce

Description

@dandansoysauce

For some reason, I can't import anything on my worker file.

SyntaxError: import declarations may only appear at top level of a module

I have this simple worker:

import { InitMe } from "../lib/Helper";

addEventListener("message", event => {
    console.log(event.data);
})

being called here:

const worker = new Worker(new URL("./test.worker.js", import.meta.url));

Commenting out the import line will make it work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions