serverPluginWebWorker.js 514 B

12345678910111213141516
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.webWorkerPlugin = void 0;
  4. exports.webWorkerPlugin = ({ app }) => {
  5. app.use((ctx, next) => {
  6. if (ctx.query.worker != null) {
  7. ctx.type = 'js';
  8. ctx.body = `export default function WrappedWorker() {
  9. return new Worker(${JSON.stringify(ctx.path)}, { type: 'module' })
  10. }`;
  11. return;
  12. }
  13. return next();
  14. });
  15. };
  16. //# sourceMappingURL=serverPluginWebWorker.js.map