Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

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

@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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions