Skip to content

Commit f09184c

Browse files
authoredOct 1, 2024
esm - set type: module top level (#230210)
1 parent 990b1fd commit f09184c

File tree

9 files changed

+25
-9
lines changed

9 files changed

+25
-9
lines changed
 

‎.eslintplugin/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

‎.vscode-test.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55

66
//@ts-check
77

8-
const path = require('path');
8+
import { createRequire } from 'node:module';
9+
import { fileURLToPath } from 'url';
10+
import * as path from 'path';
11+
import * as os from 'os';
12+
13+
const require = createRequire(import.meta.url);
14+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
15+
916
const { defineConfig } = require('@vscode/test-cli');
10-
const os = require('os');
1117

1218
/**
1319
* 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(' ') || [
5763
'--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'
5864
];
5965

60-
module.exports = defineConfig(extensions.map(extension => {
66+
const config = defineConfig(extensions.map(extension => {
6167
/** @type {import('@vscode/test-cli').TestConfiguration} */
6268
const config = typeof extension === 'object'
6369
? { files: `extensions/${extension.label}/out/**/*.test.js`, ...extension }
@@ -99,3 +105,5 @@ module.exports = defineConfig(extensions.map(extension => {
99105

100106
return config;
101107
}));
108+
109+
export default config;

‎build/gulpfile.reh.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ function packageTask(type, platform, arch, sourceFolderName, destinationFolderNa
308308

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

‎build/gulpfile.vscode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
269269
}
270270

271271
const name = product.nameShort;
272-
const packageJsonUpdates = { name, version, ...{ type: 'module', main: 'out/main.js' } }; // TODO@esm this should be configured in the top level package.json
272+
const packageJsonUpdates = { name, version };
273273

274274
// for linux url handling
275275
if (platform === 'linux') {

‎gulpfile.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { createRequire } from 'node:module';
7+
8+
const require = createRequire(import.meta.url);
69
require('./build/gulpfile');

‎package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
"name": "Microsoft Corporation"
77
},
88
"license": "MIT",
9-
"main": "./out/main",
9+
"main": "./out/main.js",
10+
"type": "module",
1011
"private": true,
1112
"scripts": {
1213
"test": "echo Please run any of the test scripts from the scripts folder.",
1314
"test-browser": "npx playwright install && node test/unit/browser/index.js",
1415
"test-browser-no-install": "node test/unit/browser/index.js",
15-
"test-node": "mocha test/unit/node/index.mjs --delay --ui=tdd --timeout=5000 --exit",
16+
"test-node": "mocha test/unit/node/index.js --delay --ui=tdd --timeout=5000 --exit",
1617
"test-extension": "vscode-test",
1718
"preinstall": "node build/npm/preinstall.js",
1819
"postinstall": "node build/npm/postinstall.js",

‎scripts/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

‎test/unit/node/index.mjs ‎test/unit/node/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import * as path from 'path';
1414
import * as fs from 'fs';
1515
import glob from 'glob';
1616
import minimatch from 'minimatch';
17-
// const coverage = require('../coverage');
1817
import minimist from 'minimist';
19-
// const { takeSnapshotAndCountClasses } = require('../analyzeSnapshot');
2018
import * as module from 'module';
2119
import { fileURLToPath, pathToFileURL } from 'url';
2220

File renamed without changes.

0 commit comments

Comments
 (0)