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

Cant use asciidoctor in my own extension as soon as i active asciidoctor-vscode extension #881

Open
flobilosaurus opened this issue May 25, 2024 · 7 comments
Labels

Comments

@flobilosaurus
Copy link

flobilosaurus commented May 25, 2024

Hello there,
im the maintainer of a another extension based on asciidoc (https://github.com/flobilosaurus/vscode-asciidoc-slides).

As soon as i active this extension in my vscode, im unable to import asciidoctor in my extension code.

I just started a fresh extension from scratch and this does not work:

import * as vscode from 'vscode'
const asciidoctor = require('asciidoctor')()
export function activate(context: vscode.ExtensionContext) {

	console.log('Congratulations, your extension "helloworld-sample" is now active!');

	// The command has been defined in the package.json file
	// Now provide the implementation of the command with registerCommand
	// The commandId parameter must match the command field in package.json
	const disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
		// The code you place here will be executed every time your command is executed

		// Display a message box to the user
		vscode.window.showInformationMessage(`Hello World!`);
	});
	context.subscriptions.push(disposable);
}

It works if your extension is uninstalled but i doesnt if its activated.
The error message i get is the following:

2024-05-25 23:35:24.054 [error] TypeError: Opal.queue is not a function

I dont know much about Opal the following things seem to happen:
Opal.queue seems to be undefined as soon as you extension is used. But this function seems to be required by asciidoctor.

Would be great if you could help me.

@ggrossetie
Copy link
Member

Hey!
You need to use version 5.1.0 of @asciidoctor/reveal.js which is transpiled using Opal 1.7.3 (compatible with Asciidoctor.js 3.x).

Please ask questions on https://chat.asciidoctor.org/

@ggrossetie ggrossetie closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2024
@flobilosaurus
Copy link
Author

flobilosaurus commented May 27, 2024

Hi @ggrossetie
thanks for this quick reply.
But i was not refering my current state of the repository of my extension. I created a fresh vscode extension from scratch:

npx --package yo --package generator-code -- yo code

And added asciidoctor:

yarn add asciidoctor

require asciidoctor in extension.ts like

import * as vscode from 'vscode'
const asciidoctor = require('asciidoctor')()
export function activate(context: vscode.ExtensionContext) {

	console.log('Congratulations, your extension "helloworld-sample" is now active!');

	// The command has been defined in the package.json file
	// Now provide the implementation of the command with registerCommand
	// The commandId parameter must match the command field in package.json
	const disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
		// The code you place here will be executed every time your command is executed

		// Display a message box to the user
		vscode.window.showInformationMessage(`Hello World!`);
	});
	context.subscriptions.push(disposable);
}

and the "Hello World" example command will fail as soon as your extension is activated and it works if its not.
I hope i could make thinks a little bit clearer here...

@flobilosaurus
Copy link
Author

Hello @ggrossetie, please reopen this issue again and have a second look into it.

@ggrossetie ggrossetie reopened this Jun 13, 2024
@flobilosaurus
Copy link
Author

Hi @ggrossetie, did you have some time to look into this bug again?

@ggrossetie
Copy link
Member

No but my guess is that the Asciidoctor VSCode is using @asciidoctor/core 2.2.7 and this new extension is using @asciidoctor/core 3.x.

Since Opal "mutates" the whole runtime you cannot have a library compiled with Opal version X and another one compiled with Opal version Y.

@flobilosaurus
Copy link
Author

Hi, thanks @ggrossetie for the response. Would it be sufficient if you update asciidoctor/core to 3.x in this extension?

@ggrossetie
Copy link
Member

The rule is that every extension that relies on Opal should use the exact same version. I guess it should work if we are both using the same version of Asciidoctor.js (and thus the same version of Opal).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants