Change:
We lost changes that where ESM relevant. I am trying to fix it in our ESM branch, maybe backport it from there: The old code also had this line, which I am not sure is needed: cc
Sorry about that. Is this for Monaco or the esm work? I'd love to get a point where we can just have this as a normal dependency instead of copying it into our sources. Marked now publishes both a commonjs and esm builds too. Is there some way VS Code could use Marked as a normal dependency in a way that would also work for Monaco? If I recall we've tried to avoid adding real dependencies to Monaco
I only noticed for our work, not sure about Monaco ESM. Would be great to get it working again on .
I think the ESM work will unblock this. esbuild will be able to bring in and include node modules into our bundle, the AMD bundler we currently use can only bundle AMD modules and not commonjs modules.
I would have hoped that the Monaco Editor checks would have caught this. Is there something we should improve there?
For monaco-editor-core, these are the only tests: It does not test markdown features.

Discussion:
displayName: "Skip tests" type: boolean default: false <del> - name: VSCODE_BUILD_ESM # TODO@bpasero remove me once ESM is shipped </del> <ins> - name: VSCODE_BUILD_ESM # TODO@bpasero TODO@esm remove me once ESM is shipped </ins> displayName: "️❗ Build as ESM (!FOR TESTING ONLY!) ️❗" type: boolean default: false

// import * as path from 'path'; // import * as fs from 'fs'; // import { fileURLToPath } from 'url'; <ins> // import { createRequire } from 'node:module'; </ins> // <ins> // const require = createRequire(import.meta.url); </ins> // const module = { exports: {} }; // const __dirname = path.dirname(fileURLToPath(import.meta.url)); // ESM-uncomment-end

/** * Helper to convert a file path to a URI. * <del> * TODO@bpasero check for removal once ESM has landed. </del> <ins> * TODO@bpasero TODO@esm check for removal once ESM has landed. </ins> * * @param {string} path * @param {{ isWindows?: boolean, scheme?: string, fallbackAuthority?: string }} config

* The code in this file is generated from files in ./src/ */ <ins> // ESM-uncomment-begin // let __marked_exports = {}; // (function() { //   function define(deps, factory) { //     factory(__marked_exports); //   } //   define.amd = true; // ESM-uncomment-end </ins> (function (global, factory) { <ins> typeof define === 'function' && define.amd ? define(['exports'], factory) : </ins> typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : <del> typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.marked = {})); })(this, (function (exports) { </del> <ins> (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.marked = {})); })(this, (function (exports) { </ins> 'use strict'; /**

exports.setOptions = setOptions; exports.use = use; exports.walkTokens = walkTokens; })); <ins> // ESM-uncomment-begin // })(); // export var Hooks = (__marked_exports.Hooks || exports.Hooks); // export var Lexer = (__marked_exports.Lexer || exports.Lexer); // export var Marked = (__marked_exports.Marked || exports.Marked); // export var Parser = (__marked_exports.Parser || exports.Parser); // export var Renderer = (__marked_exports.Renderer || exports.Renderer); // export var TextRenderer = (__marked_exports.TextRenderer || exports.TextRenderer); // export var Tokenizer = (__marked_exports.Tokenizer || exports.Tokenizer); // export var defaults = (__marked_exports.defaults || exports.defaults); // export var getDefaults = (__marked_exports.getDefaults || exports.getDefaults); // export var lexer = (__marked_exports.lexer || exports.lexer); // export var marked = (__marked_exports.marked || exports.marked); // export var options = (__marked_exports.options || exports.options); // export var parse = (__marked_exports.parse || exports.parse); // export var parseInline = (__marked_exports.parseInline || exports.parseInline); // export var parser = (__marked_exports.parser || exports.parser); // export var setOptions = (__marked_exports.setOptions || exports.setOptions); // export var use = (__marked_exports.use || exports.use); // export var walkTokens = (__marked_exports.walkTokens || exports.walkTokens); // ESM-uncomment-end </ins> //# sourceMappingURL=marked.umd.js.map

import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils'; import { request } from 'vs/base/parts/request/browser/request'; import { streamToBuffer } from 'vs/base/common/buffer'; <ins> import { flakySuite } from 'vs/base/test/common/testUtils'; </ins> <del> suite('Request', () => { </del> <ins> flakySuite('Request', () => { </ins> let port: number; let server: http.Server;

function loadCode(moduleId: string): Promise<SimpleWorkerModule> { // ESM-uncomment-begin <ins> // if (typeof loadAMDLoader === 'function') { /* fixes unused import, remove me */} </ins> // const moduleUrl = new URL(`${moduleId}.js`, globalThis._VSCODE_FILE_ROOT); // return import(moduleUrl.href); // ESM-uncomment-end

*/ async function guessEncodingByBuffer(buffer: VSBuffer, candidateGuessEncodings?: string[]): Promise<string | null> { <del> // TODO@bpasero ESM: this used to be `dist/jschardet.min.js`, but we are running into an issue that </del> <ins> // TODO@bpasero TODO@esm: this used to be `dist/jschardet.min.js`, but we are running into an issue that </ins> // https://github.com/aadsm/jschardet/pull/96 mitigates. Long-term we should just add minification // of dependencies into our build process so that we do not depend on how others are doing it. const jschardet = await importAMDNodeModule<typeof import('jschardet')>('jschardet', isESM ? 'dist/jschardet.js' : 'dist/jschardet.min.js');