diff --git a/.eslintplugin/package.json b/.eslintplugin/package.json new file mode 100644 index 00000000000..a0df0c86778 --- /dev/null +++ b/.eslintplugin/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/.vscode-test.js b/.vscode-test.js index 89e1b855ee0..1e5de54470c 100644 --- a/.vscode-test.js +++ b/.vscode-test.js @@ -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; diff --git a/build/gulpfile.reh.js b/build/gulpfile.reh.js index 6538ce7e3f1..61cb0da0e50 100644 --- a/build/gulpfile.reh.js +++ b/build/gulpfile.reh.js @@ -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); diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 03f446fdc2b..194fbef8f3f 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -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') { diff --git a/gulpfile.js b/gulpfile.js index 9691ba80607..4dce0234239 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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'); diff --git a/package.json b/package.json index 2bc50f10061..c3924ca1441 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 00000000000..a0df0c86778 --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/test/unit/node/index.mjs b/test/unit/node/index.js similarity index 98% rename from test/unit/node/index.mjs rename to test/unit/node/index.js index 80fae48b4fb..79d5ee1a1ec 100644 --- a/test/unit/node/index.mjs +++ b/test/unit/node/index.js @@ -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'; diff --git a/src/package.json b/test/unit/node/package.json similarity index 100% rename from src/package.json rename to test/unit/node/package.json