esm - backport more changes (#225692)

pull/225702/head
Benjamin Pasero 2024-08-15 14:58:04 +02:00 committed by GitHub
parent 214be4b529
commit 3dfe155b3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 43 additions and 9 deletions

View File

@ -100,7 +100,7 @@ parameters:
displayName: "Skip tests"
type: boolean
default: false
- name: VSCODE_BUILD_ESM # TODO@bpasero remove me once ESM is shipped
- name: VSCODE_BUILD_ESM # TODO@bpasero TODO@esm remove me once ESM is shipped
displayName: "️❗ Build as ESM (!FOR TESTING ONLY!) ️❗"
type: boolean
default: false

View File

@ -15,7 +15,9 @@ const Module = require('module');
// import * as path from 'path';
// import * as fs from 'fs';
// import { fileURLToPath } from 'url';
// import { createRequire } from 'node:module';
//
// const require = createRequire(import.meta.url);
// const module = { exports: {} };
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ESM-uncomment-end
@ -227,7 +229,7 @@ module.exports.enableASARSupport = function () {
/**
* Helper to convert a file path to a URI.
*
* TODO@bpasero check for removal once ESM has landed.
* TODO@bpasero TODO@esm check for removal once ESM has landed.
*
* @param {string} path
* @param {{ isWindows?: boolean, scheme?: string, fallbackAuthority?: string }} config

View File

@ -9,11 +9,20 @@
* The code in this file is generated from files in ./src/
*/
// ESM-uncomment-begin
// let __marked_exports = {};
// (function() {
// function define(deps, factory) {
// factory(__marked_exports);
// }
// define.amd = true;
// ESM-uncomment-end
(function (global, factory) {
typeof define === 'function' && define.amd ? define(['exports'], factory) :
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.marked = {}));
})(this, (function (exports) {
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.marked = {}));
})(this, (function (exports) {
'use strict';
/**
@ -2502,6 +2511,28 @@
exports.setOptions = setOptions;
exports.use = use;
exports.walkTokens = walkTokens;
}));
// 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
//# sourceMappingURL=marked.umd.js.map

View File

@ -12,9 +12,9 @@ import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cance
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
import { request } from 'vs/base/parts/request/browser/request';
import { streamToBuffer } from 'vs/base/common/buffer';
import { flakySuite } from 'vs/base/test/common/testUtils';
suite('Request', () => {
flakySuite('Request', () => {
let port: number;
let server: http.Server;

View File

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

View File

@ -322,7 +322,7 @@ const IGNORE_ENCODINGS = ['ascii', 'utf-16', 'utf-32'];
*/
async function guessEncodingByBuffer(buffer: VSBuffer, candidateGuessEncodings?: string[]): Promise<string | null> {
// TODO@bpasero ESM: this used to be `dist/jschardet.min.js`, but we are running into an issue that
// TODO@bpasero TODO@esm: this used to be `dist/jschardet.min.js`, but we are running into an issue that
// 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');