eng - use esModuleInterop for extensions

This commit is contained in:
Johannes
2024-10-01 21:57:30 +02:00
parent f09184ceb7
commit e6f315d2fc
15 changed files with 17 additions and 16 deletions

View File

@@ -290,7 +290,7 @@ export class ExtensionLinter {
const text = document.getText(); const text = document.getText();
if (!this.markdownIt) { if (!this.markdownIt) {
this.markdownIt = new (await import('markdown-it')); this.markdownIt = new ((await import('markdown-it')).default);
} }
const tokens = this.markdownIt.parse(text, {}); const tokens = this.markdownIt.parse(text, {});
const tokensAndPositions: TokenAndPosition[] = (function toTokensAndPositions(this: ExtensionLinter, tokens: MarkdownItType.Token[], begin = 0, end = text.length): TokenAndPosition[] { const tokensAndPositions: TokenAndPosition[] = (function toTokensAndPositions(this: ExtensionLinter, tokens: MarkdownItType.Token[], begin = 0, end = text.length): TokenAndPosition[] {

View File

@@ -8,7 +8,7 @@ import * as path from 'path';
import * as os from 'os'; import * as os from 'os';
import * as cp from 'child_process'; import * as cp from 'child_process';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import * as which from 'which'; import which from 'which';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import * as iconv from '@vscode/iconv-lite-umd'; import * as iconv from '@vscode/iconv-lite-umd';
import * as filetype from 'file-type'; import * as filetype from 'file-type';

View File

@@ -6,7 +6,7 @@
import TelemetryReporter from '@vscode/extension-telemetry'; import TelemetryReporter from '@vscode/extension-telemetry';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as picomatch from 'picomatch'; import picomatch from 'picomatch';
import { CancellationError, CancellationToken, CancellationTokenSource, Command, commands, Disposable, Event, EventEmitter, FileDecoration, l10n, LogLevel, LogOutputChannel, Memento, ProgressLocation, ProgressOptions, RelativePattern, scm, SourceControl, SourceControlInputBox, SourceControlInputBoxValidation, SourceControlInputBoxValidationType, SourceControlResourceDecorations, SourceControlResourceGroup, SourceControlResourceState, TabInputNotebookDiff, TabInputTextDiff, TabInputTextMultiDiff, ThemeColor, Uri, window, workspace, WorkspaceEdit } from 'vscode'; import { CancellationError, CancellationToken, CancellationTokenSource, Command, commands, Disposable, Event, EventEmitter, FileDecoration, l10n, LogLevel, LogOutputChannel, Memento, ProgressLocation, ProgressOptions, RelativePattern, scm, SourceControl, SourceControlInputBox, SourceControlInputBoxValidation, SourceControlInputBoxValidationType, SourceControlResourceDecorations, SourceControlResourceGroup, SourceControlResourceState, TabInputNotebookDiff, TabInputTextDiff, TabInputTextMultiDiff, ThemeColor, Uri, window, workspace, WorkspaceEdit } from 'vscode';
import { ActionButton } from './actionButton'; import { ActionButton } from './actionButton';
import { ApiRepository } from './api/api1'; import { ApiRepository } from './api/api1';

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import 'mocha'; import 'mocha';
import * as assert from 'assert'; import assert from 'assert';
import { workspace, commands, window, Uri, WorkspaceEdit, Range, TextDocument, extensions, TabInputTextDiff } from 'vscode'; import { workspace, commands, window, Uri, WorkspaceEdit, Range, TextDocument, extensions, TabInputTextDiff } from 'vscode';
import * as cp from 'child_process'; import * as cp from 'child_process';
import * as fs from 'fs'; import * as fs from 'fs';

View File

@@ -7,7 +7,7 @@ import { Event, Disposable, EventEmitter, SourceControlHistoryItemRef } from 'vs
import { dirname, sep, relative } from 'path'; import { dirname, sep, relative } from 'path';
import { Readable } from 'stream'; import { Readable } from 'stream';
import { promises as fs, createReadStream } from 'fs'; import { promises as fs, createReadStream } from 'fs';
import * as byline from 'byline'; import byline from 'byline';
export const isMacintosh = process.platform === 'darwin'; export const isMacintosh = process.platform === 'darwin';
export const isWindows = process.platform === 'win32'; export const isWindows = process.platform === 'win32';

View File

@@ -2,7 +2,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert'; import assert from 'assert';
import * as words from '../utils/strings'; import * as words from '../utils/strings';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import type * as nbformat from '@jupyterlab/nbformat'; import type * as nbformat from '@jupyterlab/nbformat';
import * as detectIndent from 'detect-indent'; import detectIndent from 'detect-indent';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { getPreferredLanguage, jupyterNotebookModelToNotebookData } from './deserializers'; import { getPreferredLanguage, jupyterNotebookModelToNotebookData } from './deserializers';
import * as fnv from '@enonic/fnv-plus'; import * as fnv from '@enonic/fnv-plus';

View File

@@ -129,7 +129,7 @@ export class MarkdownItEngine implements IMdParser {
if (!this._md) { if (!this._md) {
this._md = (async () => { this._md = (async () => {
const markdownIt = await import('markdown-it'); const markdownIt = await import('markdown-it');
let md: MarkdownIt = markdownIt(await getMarkdownOptions(() => md)); let md: MarkdownIt = markdownIt.default(await getMarkdownOptions(() => md));
md.linkify.set({ fuzzyLink: false }); md.linkify.set({ fuzzyLink: false });
for (const plugin of this._contributionProvider.contributions.markdownItPlugins.values()) { for (const plugin of this._contributionProvider.contributions.markdownItPlugins.values()) {
@@ -143,7 +143,7 @@ export class MarkdownItEngine implements IMdParser {
const frontMatterPlugin = await import('markdown-it-front-matter'); const frontMatterPlugin = await import('markdown-it-front-matter');
// Extract rules from front matter plugin and apply at a lower precedence // Extract rules from front matter plugin and apply at a lower precedence
let fontMatterRule: any; let fontMatterRule: any;
frontMatterPlugin({ frontMatterPlugin.default(<any>{
block: { block: {
ruler: { ruler: {
before: (_id: any, _id2: any, rule: any) => { fontMatterRule = rule; } before: (_id: any, _id2: any, rule: any) => { fontMatterRule = rule; }

View File

@@ -11,7 +11,7 @@ import { NpmScriptsTreeDataProvider } from './npmView';
import { getPackageManager, invalidateTasksCache, NpmTaskProvider, hasPackageJson } from './tasks'; import { getPackageManager, invalidateTasksCache, NpmTaskProvider, hasPackageJson } from './tasks';
import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHover'; import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHover';
import { NpmScriptLensProvider } from './npmScriptLens'; import { NpmScriptLensProvider } from './npmScriptLens';
import * as which from 'which'; import which from 'which';
let treeDataProvider: NpmScriptsTreeDataProvider | undefined; let treeDataProvider: NpmScriptsTreeDataProvider | undefined;

View File

@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import findWorkspaceRoot = require('../node_modules/find-yarn-workspace-root'); import findWorkspaceRoot = require('../node_modules/find-yarn-workspace-root');
import * as findUp from 'find-up'; import findUp from 'find-up';
import * as path from 'path'; import * as path from 'path';
import * as whichPM from 'which-pm'; import whichPM from 'which-pm';
import { Uri, workspace } from 'vscode'; import { Uri, workspace } from 'vscode';
interface PreferredProperties { interface PreferredProperties {

View File

@@ -10,7 +10,7 @@ import {
} from 'vscode'; } from 'vscode';
import * as path from 'path'; import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
import * as minimatch from 'minimatch'; import minimatch from 'minimatch';
import { Utils } from 'vscode-uri'; import { Utils } from 'vscode-uri';
import { findPreferredPM } from './preferred-pm'; import { findPreferredPM } from './preferred-pm';
import { readScripts } from './readScripts'; import { readScripts } from './readScripts';

View File

@@ -5,7 +5,7 @@
import * as cp from 'child_process'; import * as cp from 'child_process';
import { StringDecoder } from 'string_decoder'; import { StringDecoder } from 'string_decoder';
import * as which from 'which'; import which from 'which';
import * as path from 'path'; import * as path from 'path';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { ThrottledDelayer } from './utils/async'; import { ThrottledDelayer } from './utils/async';

View File

@@ -1,5 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"esModuleInterop": true,
"target": "es2020", "target": "es2020",
"lib": [ "lib": [
"ES2016", "ES2016",

View File

@@ -5,7 +5,7 @@
import * as path from 'path'; import * as path from 'path';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import * as assert from 'assert'; import assert from 'assert';
suite('mapped edits provider', () => { suite('mapped edits provider', () => {

View File

@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert'; import assert from 'assert';
import * as fs from 'fs'; import * as fs from 'fs';
import { basename, join, posix } from 'path'; import { basename, join, posix } from 'path';
import * as vscode from 'vscode'; import * as vscode from 'vscode';