Skip to content

Commit

Permalink
esm - set type: module top level (microsoft#230210)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Oct 1, 2024
1 parent 990b1fd commit f09184c
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .eslintplugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
14 changes: 11 additions & 3 deletions .vscode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -99,3 +105,5 @@ module.exports = defineConfig(extensions.map(extension => {

return config;
}));

export default config;
2 changes: 1 addition & 1 deletion build/gulpfile.reh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion build/gulpfile.vscode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
3 changes: 3 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions scripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
2 changes: 0 additions & 2 deletions test/unit/node/index.mjs → test/unit/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
File renamed without changes.

0 comments on commit f09184c

Please sign in to comment.