question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline worker build without any output files or error message.

See original GitHub issue

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

I am using monaco editor with inline worker, vite build output nothing. (exit at ✓ 739 modules transformed.) (When I used vite 1, it worked as expected.

Reproduction

https://github.com/meowtec/vite-worker-bug-reproduce

System Info

  • vite version: 2.0.0-beta.65
  • Operating System: macOS Catalina
  • Node version: v12.18.0
  • Package manager (npm/yarn/pnpm) and version: npm 6.14.10

Logs (Optional if provided reproduction)

building for production...
transforming (14) node_modules/monaco-editor/esm/vs/editor/editor.worker.jsThe 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
transforming (105) node_modules/monaco-editor/esm/vs/editor/common/services/editorSimpleWorker.jsThe 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
transforming (297) node_modules/monaco-editor/esm/vs/language/json/_deps/vscode-json-languageservice/seThe 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
✓ 736 modules transformed.
✓ 739 modules transformed.
<----- vite exit here

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
kena0kicommented, Mar 24, 2021

build: worker throws with Uncaught ReferenceError: window is not defined (anothor issue to fix)

In my case, the above error is resolved by build.rollupOptions.output.manualChunks.

// vite.config.js
import { defineConfig } from 'vite';
const prefix = `monaco-editor/esm/vs`;
export default defineConfig({
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          jsonWorker: [`${prefix}/language/json/json.worker`],
          cssWorker: [`${prefix}/language/css/css.worker`],
          htmlWorker: [`${prefix}/language/html/html.worker`],
          tsWorker: [`${prefix}/language/typescript/ts.worker`],
          editorWorker: [`${prefix}/editor/editor.worker`],
        },
      },
    },
  },
});
5reactions
meowteccommented, Feb 7, 2021

Additional:

Using ?worker&inline:

dev: it works build: output nothing

Using ?worker:

dev: it works too build: worker throws with Uncaught ReferenceError: window is not defined (anothor issue to fix)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web workers without a separate Javascript file? - Stack Overflow
I'm working on it (or rather on minimising the problem): DynWorker. You can do: var worker = new DynWorker(); worker.inject("foo", function(){...}); ...
Read more >
Understanding and Using Web Workers - CODE Magazine
Miguel Castro teaches you the how to use Web Workers to do multi-threaded development in Web applications using JavaScript.
Read more >
worker-loader - webpack - JS.ORG
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Angular compiler options
ts file is supplied without a libraryIndex , an error is produced. A flat module index .d.ts and .js is created with the...
Read more >
Worker threads | Node.js v19.3.0 Documentation
The node:worker_threads module enables the use of threads that execute ... If no message is available, undefined is returned, otherwise an object with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found