asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
341 stars 97 forks source link

Can't preview antora references after vscode update #899

Closed alaindresse closed 2 months ago

alaindresse commented 2 months ago

Since my last vscode update, I can no longer preview a page with antora references (e.g. include::partial$...antora documentation since the latest vscode update (even tried to reinstall vscode from scratch).

When I open the developer tools, I see a bunch of errors like

console.ts:137 [Extension Host] Unable to get Antora context for file:///Users/alaindresse/code/twipe-documentation/docs/modules/antora-intro/pages/index.adoc TypeError: A dynamic import callback was not specified.
    at importModuleDynamicallyCallback (node:internal/modules/esm/utils:228:9)
    at getAntoraDocumentContext (/Users/alaindresse/.vscode/extensions/asciidoctor.asciidoctor-vscode-3.3.1/src/features/antora/antoraSupport.ts:319:27)
    at AsciidocIncludeItemsLoader.prepare (/Users/alaindresse/.vscode/extensions/asciidoctor.asciidoctor-vscode-3.3.1/src/asciidocLoader.ts:59:35)
    at AsciidocIncludeItemsLoader.getIncludeItems (/Users/alaindresse/.vscode/extensions/asciidoctor.asciidoctor-vscode-3.3.1/src/asciidocLoader.ts:95:9)
    at LinkProvider.provideDocumentLinks (/Users/alaindresse/.vscode/extensions/asciidoctor.asciidoctor-vscode-3.3.1/src/features/documentLinkProvider.ts:51:41)
    at ae.provideLinks (/Users/alaindresse/Desktop/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:154:126920)

which seem to be related to

[antoraSupport.ts:319] let classifyContent = await import('@antora/content-classifier')

(for reference, initially discussed on Asciidoctor zulip chat

alaindresse commented 2 months ago

Workaround (requires modifying the extension) for those having a similar issue:

With Node 20, I could actually import the content-classifier without await import in antoraSupport.ts:

import * as contentClassifier from '@antora/content-classifier'
const classifyContent = contentClassifier.default || contentClassifier

and comment later in antoraSupport.ts

    // let classifyContent = await import('@antora/content-classifier')
    // if ('default' in classifyContent) {
    //   classifyContent = classifyContent.default // default export
    // }
ggrossetie commented 2 months ago

VS code will eventually support dynamic imports (see https://github.com/microsoft/vscode/issues/226260) but until then we should use a static import.

BcOleks commented 2 months ago

Hi @ggrossetie , can I ask when this issue fix gonna be released? Or how can I apply it without manually changing the extension code?

BcOleks commented 1 month ago

Hi @ggrossetie , can I ask when this issue fix gonna be released? Or how can I apply it without manually changing the extension code?

Can someone please help me with this?

ggrossetie commented 1 month ago

Hello @BcOleks I will try to release a new version this week. In the meantime, you want install the extension from the source code (you can find some guidance here: https://github.com/asciidoctor/asciidoctor-vscode/blob/master/CONTRIBUTING.adoc)