Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] XXX depends on UNKNOWN service YYY. #2941

Closed
2 tasks done
oldrich-s opened this issue Feb 4, 2022 · 4 comments
Closed
2 tasks done

[Bug] XXX depends on UNKNOWN service YYY. #2941

oldrich-s opened this issue Feb 4, 2022 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority
Milestone

Comments

@oldrich-s
Copy link

oldrich-s commented Feb 4, 2022

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Code

No response

Actual Behavior

No response

Expected Behavior

No response

Additional Context

After update to the latest version 0-32-0 (from yesterday) I get the following errors. I build monaco using esbuild. Version 0-31-1 did not have these crashes. Do you know what could go wrong or how to debug / investigate this issue?

image

EDIT:

this is our build.js script

const esbuild = require('esbuild');
const path = require('path');

build({
	entryPoints: ['./node_modules/monaco-editor/esm/vs/editor/editor.main.js'],
	bundle: true,
	format: 'iife',
	outdir: path.join(__dirname, 'dist'),
	loader: { '.ttf': 'file' },
	globalName: 'monaco',
});

build({
	entryPoints: [
		'./node_modules/monaco-editor/esm/vs/language/json/json.worker.js',
		'./node_modules/monaco-editor/esm/vs/language/css/css.worker.js',
		'./node_modules/monaco-editor/esm/vs/language/html/html.worker.js',
		'./node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js',
		'./node_modules/monaco-editor/esm/vs/editor/editor.worker.js',
	],
	bundle: true,
	format: 'iife',
	outdir: path.join(__dirname, 'dist'),
	loader: { '.ttf': 'file' },
});

function build(opts) {
	esbuild.build(opts).then((result) => {
		if (result.errors.length > 0) {
			console.error(result.errors);
		}
		if (result.warnings.length > 0) {
			console.error(result.warnings);
		}
	});
} 

and this is a minimal example that produces the error:

globalThis.MonacoEnvironment = {
  getWorkerUrl: function (_moduleId: string, label: string) {
    if (label === 'typescript') {
      return Path.join(dirPath, `language/typescript/ts.worker.js`)
    }

    return Path.join(dirPath, 'editor/editor.worker.js')
  },
}

const editor = monaco.editor.create($div, { language: 'typescript' })

editor.setValue('const x = 5')
@hediet
Copy link
Member

hediet commented Feb 4, 2022

This does not make so much sense. I wonder why it says CodeLensContribution2 and not CodeLensContribution, there is no such CodeLensContribution2 in the code base.

Also, the implementation for ICodeLensCache is registered in the same module where the service is defined, thus it shouldn't be unknown.

@hediet hediet added the bug Issue identified by VS Code Team member as probable bug label Feb 4, 2022
@oldrich-s
Copy link
Author

oldrich-s commented Feb 4, 2022

I guess that CodeLensContribution2 is there because esbuild compiles the code into var CodeLensContribution = class CodeLensContribution2 {.

I have just tried to build and run example from /samples/browser-esm-esbuild/ and got the same errors.

EDIT: If run the exact same sample with monaco-editor 0.31.1 then I get no errors - so it looks like something new in 0.32.0.

image

@alexdima
Copy link
Member

alexdima commented Feb 4, 2022

In 0.32.0 we have aligned the service setup in the editor to be based on registering services, while before we would be manually 'newing' up each service. Maybe eslint is removing those classes because it can't find references to new X?

@alexdima
Copy link
Member

alexdima commented Feb 4, 2022

I was able to reproduce. This is because the service collection initialization code executes before the ICodeLensCache service has had a chance to be defined.

@alexdima alexdima added the important Issue identified as high-priority label Feb 4, 2022
sourcegraph-bot pushed a commit to sgtest/megarepo that referenced this issue Feb 4, 2022
…ice descriptors that were registered later

Commit: 44a6c7af673a2634805bbde28485b30da7abafdc
alexdima added a commit to microsoft/vscode that referenced this issue Feb 4, 2022
@alexdima alexdima added this to the January 2022 milestone Feb 4, 2022
camargo added a commit to NASA-AMMOS/aerie-ui that referenced this issue Feb 5, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority
Projects
None yet
Development

No branches or pull requests

3 participants