esm - set type: module top level (#230210)

This commit is contained in:
Benjamin Pasero 2024-10-01 20:48:56 +02:00 committed by GitHub
parent 990b1fdb91
commit f09184ceb7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 25 additions and 9 deletions

View File

@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View File

@ -5,9 +5,15 @@
//@ts-check
const path = require('path');
import { createRequire } from 'node:module';
import { fileURLToPath } from 'url';
import * as path from 'path';
import * as os from 'os';
const require = createRequire(import.meta.url);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const { defineConfig } = require('@vscode/test-cli');
const os = require('os');
/**
* A list of extension folders who have opted into tests, or configuration objects.
@ -57,7 +63,7 @@ const defaultLaunchArgs = process.env.API_TESTS_EXTRA_ARGS?.split(' ') || [
'--disable-telemetry', '--skip-welcome', '--skip-release-notes', `--crash-reporter-directory=${__dirname}/.build/crashes`, `--logsPath=${__dirname}/.build/logs/integration-tests`, '--no-cached-data', '--disable-updates', '--use-inmemory-secretstorage', '--disable-extensions', '--disable-workspace-trust'
];
module.exports = defineConfig(extensions.map(extension => {
const config = defineConfig(extensions.map(extension => {
/** @type {import('@vscode/test-cli').TestConfiguration} */
const config = typeof extension === 'object'
? { files: `extensions/${extension.label}/out/**/*.test.js`, ...extension }
@ -99,3 +105,5 @@ module.exports = defineConfig(extensions.map(extension => {
return config;
}));
export default config;

View File

@ -308,7 +308,7 @@ function packageTask(type, platform, arch, sourceFolderName, destinationFolderNa
let packageJsonContents;
const packageJsonStream = gulp.src(['remote/package.json'], { base: 'remote' })
.pipe(json({ name, version, dependencies: undefined, optionalDependencies: undefined, ...{ type: 'module' } })) // TODO@esm this should be configured in the top level package.json
.pipe(json({ name, version, dependencies: undefined, optionalDependencies: undefined, type: 'module' }))
.pipe(es.through(function (file) {
packageJsonContents = file.contents.toString();
this.emit('data', file);

View File

@ -269,7 +269,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
}
const name = product.nameShort;
const packageJsonUpdates = { name, version, ...{ type: 'module', main: 'out/main.js' } }; // TODO@esm this should be configured in the top level package.json
const packageJsonUpdates = { name, version };
// for linux url handling
if (platform === 'linux') {

View File

@ -3,4 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
require('./build/gulpfile');

View File

@ -6,13 +6,14 @@
"name": "Microsoft Corporation"
},
"license": "MIT",
"main": "./out/main",
"main": "./out/main.js",
"type": "module",
"private": true,
"scripts": {
"test": "echo Please run any of the test scripts from the scripts folder.",
"test-browser": "npx playwright install && node test/unit/browser/index.js",
"test-browser-no-install": "node test/unit/browser/index.js",
"test-node": "mocha test/unit/node/index.mjs --delay --ui=tdd --timeout=5000 --exit",
"test-node": "mocha test/unit/node/index.js --delay --ui=tdd --timeout=5000 --exit",
"test-extension": "vscode-test",
"preinstall": "node build/npm/preinstall.js",
"postinstall": "node build/npm/postinstall.js",

3
scripts/package.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View File

@ -14,9 +14,7 @@ import * as path from 'path';
import * as fs from 'fs';
import glob from 'glob';
import minimatch from 'minimatch';
// const coverage = require('../coverage');
import minimist from 'minimist';
// const { takeSnapshotAndCountClasses } = require('../analyzeSnapshot');
import * as module from 'module';
import { fileURLToPath, pathToFileURL } from 'url';