Worker not bundling imported files
See original GitHub issueI am trying to load a Worker in the following way:
const url = new URL('./path/to/worker.ts', import.meta.url);
const worker = new Worker(url);
In the worker file I am trying to do an import:
import { someFunction } from './functions';
someFunction();
If I don’t provide { type: 'module' }
to the Worker constructor, the import doesn’t get bundled with the worker and the following error is displayed in the console:
Uncaught SyntaxError: Cannot use import statement outside a module
If I do provide { type: 'module' }
to the Worker constructor then it request the file without the extension: http://localhost:8080/functions
which then returns a 404
due to the fact that a file without the extension doesn’t exist.
I would expect this to be bundled similar to the way that it is bundled when creating a webpage that uses imports as well where everything is in one file. Is there something I am doing wrong or is this a missing Webpack feature?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:18 (12 by maintainers)
Top GitHub Comments
@debo07 don’t worry, it is in my TODO list, sorry for delay, a lot of tasks
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.