@vscode/test-web 0.0.77 → 0.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -65,7 +65,7 @@ export interface Options {
65
65
  */
66
66
  coi?: boolean;
67
67
  /**
68
- * If set, serves the page with ESM usage.
68
+ * If set to true, serves the page with ESM usage, if set to false, serves the page with AMD usage. If not set, ESM is used if the build supports it.
69
69
  */
70
70
  esm?: boolean;
71
71
  /**
@@ -29,7 +29,7 @@ async function runTests(options) {
29
29
  extensionPaths: options.extensionPaths,
30
30
  extensionIds: options.extensionIds,
31
31
  coi: !!options.coi,
32
- esm: !!options.esm,
32
+ esm: options.esm,
33
33
  };
34
34
  const host = options.host ?? 'localhost';
35
35
  const port = options.port ?? 3000;
@@ -95,7 +95,7 @@ async function open(options) {
95
95
  extensionPaths: options.extensionPaths,
96
96
  extensionIds: options.extensionIds,
97
97
  coi: !!options.coi,
98
- esm: !!options.esm,
98
+ esm: options.esm,
99
99
  };
100
100
  const host = options.host ?? 'localhost';
101
101
  const port = options.port ?? 3000;
@@ -179,6 +179,9 @@ function validateBooleanOrUndefined(options, name) {
179
179
  if (value === undefined || typeof value === 'boolean') {
180
180
  return value;
181
181
  }
182
+ if (value === null) {
183
+ return undefined;
184
+ }
182
185
  console.log(`'${name}' needs to be a boolean value.`);
183
186
  showHelp();
184
187
  process.exit(-1);
@@ -372,7 +375,7 @@ function showHelp() {
372
375
  console.log(` --headless: Whether to hide the browser. Defaults to true when an extensionTestsPath is provided, otherwise false. [Optional]`);
373
376
  console.log(` --permission: Permission granted in the opened browser: e.g. 'clipboard-read', 'clipboard-write'. [Optional, Multiple]`);
374
377
  console.log(` --coi: Enables cross origin isolation [Optional]`);
375
- console.log(` --esm: Serve the ESM variant of VS Code [Optional]`);
378
+ console.log(` --esm: If set to true, serves the page with ESM loader, if set to false, serves the page with AMD loader. If not set, ESM is used if the build supports it. [Optional]`);
376
379
  console.log(` --folder-uri: workspace to open VS Code on. Ignored when folderPath is provided. [Optional]`);
377
380
  console.log(` --extensionPath: A path pointing to a folder containing additional extensions to include [Optional, Multiple]`);
378
381
  console.log(` --extensionId: The id of an extension include. The format is '\${publisher}.\${name}'. Append '@prerelease' to use a prerelease version [Optional, Multiple]`);
@@ -396,6 +399,9 @@ async function cliMain() {
396
399
  const options = {
397
400
  string: ['extensionDevelopmentPath', 'extensionTestsPath', 'browser', 'browserOption', 'browserType', 'quality', 'version', 'commit', 'waitForDebugger', 'folder-uri', 'permission', 'extensionPath', 'extensionId', 'sourcesPath', 'host', 'port', 'testRunnerDataDir'],
398
401
  boolean: ['open-devtools', 'headless', 'hideServerLog', 'printServerLog', 'help', 'verbose', 'coi', 'esm'],
402
+ default: {
403
+ esm: null
404
+ },
399
405
  unknown: arg => {
400
406
  if (arg.startsWith('-')) {
401
407
  console.log(`Unknown argument ${arg}`);
@@ -144,7 +144,7 @@ function default_1(config) {
144
144
  if (config.build.type === 'sources') {
145
145
  const builtInExtensions = await (0, extensions_1.getScannedBuiltinExtensions)(config.build.location);
146
146
  const productOverrides = await getProductOverrides(config.build.location);
147
- const esm = config.esm || await isESM(config.build.location);
147
+ const esm = config.esm ?? await isESM(config.build.location);
148
148
  console.log('Using ESM loader:', esm);
149
149
  const devCSSModules = esm ? await getDevCssModules(config.build.location) : [];
150
150
  ctx.state.workbench = new Workbench(`${ctx.protocol}://${ctx.host}/static/sources`, true, esm, devCSSModules, builtInExtensions, {
@@ -155,13 +155,17 @@ function default_1(config) {
155
155
  }
156
156
  else if (config.build.type === 'static') {
157
157
  const baseUrl = `${ctx.protocol}://${ctx.host}/static/build`;
158
- ctx.state.workbench = new Workbench(baseUrl, false, config.esm, [], [], {
158
+ const esm = config.esm ?? await isESM(config.build.location);
159
+ console.log('Using ESM loader:', esm);
160
+ ctx.state.workbench = new Workbench(baseUrl, false, esm, [], [], {
159
161
  webEndpointUrlTemplate: `${ctx.protocol}://{{uuid}}.${ctx.host}/static/build`,
160
162
  webviewContentExternalBaseUrlTemplate: `${ctx.protocol}://{{uuid}}.${ctx.host}/static/build/out/vs/workbench/contrib/webview/browser/pre/`
161
163
  });
162
164
  }
163
165
  else if (config.build.type === 'cdn') {
164
- ctx.state.workbench = new Workbench(config.build.uri, false, config.esm, []);
166
+ const esm = config.esm ?? true;
167
+ console.log('Using ESM loader:', esm);
168
+ ctx.state.workbench = new Workbench(config.build.uri, false, esm, []);
165
169
  }
166
170
  await next();
167
171
  });
@@ -191,13 +195,6 @@ async function getDevCssModules(vsCodeDevLocation) {
191
195
  return glob.glob('**/*.css', { cwd: path.join(vsCodeDevLocation, 'out') });
192
196
  }
193
197
  async function isESM(vsCodeDevLocation) {
194
- try {
195
- const packageJSON = await fs_1.promises.readFile(path.join(vsCodeDevLocation, 'out', 'package.json'));
196
- return JSON.parse(packageJSON.toString()).type === 'module';
197
- }
198
- catch (e) {
199
- // ignore
200
- }
201
198
  try {
202
199
  const packageJSON = await fs_1.promises.readFile(path.join(vsCodeDevLocation, 'package.json'));
203
200
  return JSON.parse(packageJSON.toString()).type === 'module';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vscode/test-web",
3
- "version": "0.0.77",
3
+ "version": "0.0.78",
4
4
  "scripts": {
5
5
  "install-extensions": "npm i --prefix=fs-provider && npm i --prefix=sample",
6
6
  "compile": "tsc -b ./ && npm run compile-fs-provider",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@koa/cors": "^5.0.0",
27
- "@koa/router": "^15.0.0",
27
+ "@koa/router": "^15.2.0",
28
28
  "@playwright/browser-chromium": "^1.57.0",
29
29
  "tinyglobby": "^0.2.15",
30
30
  "gunzip-maybe": "^1.4.2",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@eslint/eslintrc": "^3.3.3",
44
- "@eslint/js": "^9.39.1",
44
+ "@eslint/js": "^9.39.2",
45
45
  "@types/gunzip-maybe": "^1.4.3",
46
46
  "@types/koa": "^3.0.1",
47
47
  "@types/koa__router": "^12.0.5",
@@ -51,9 +51,9 @@
51
51
  "@types/minimist": "^1.2.5",
52
52
  "@types/node": "^20.16.13",
53
53
  "@types/tar-fs": "^2.0.4",
54
- "@typescript-eslint/eslint-plugin": "^8.48.1",
55
- "@typescript-eslint/parser": "^8.48.1",
56
- "eslint": "^9.39.1",
54
+ "@typescript-eslint/eslint-plugin": "^8.52.0",
55
+ "@typescript-eslint/parser": "^8.52.0",
56
+ "eslint": "^9.39.2",
57
57
  "@tony.ganchev/eslint-plugin-header": "^3.1.11",
58
58
  "typescript": "^5.9.3"
59
59
  },
@@ -26,7 +26,7 @@
26
26
  <link rel="icon" href="{{WORKBENCH_WEB_BASE_URL}}/favicon.ico" type="image/x-icon" />
27
27
  <link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/manifest.json">
28
28
 
29
- <link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.css" />
29
+ <link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.internal.css" />
30
30
  <style id="vscode-css-modules" type="text/css" media="screen"></style>
31
31
  </head>
32
32