Skip to content

Commit 3cde453

Browse files
committed
WIP attempt at making "type":"module" work
1 parent 2032e16 commit 3cde453

18 files changed

+21
-17
lines changed
File renamed without changes.

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function (api) {
1+
export default function (api) {
22
api.cache(true);
33
return {
44
presets: ['@babel/preset-typescript'],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@webgpu/cts",
33
"version": "0.1.0",
44
"description": "WebGPU Conformance Test Suite",
5+
"type": "module",
56
"scripts": {
67
"test": "grunt all",
78
"all": "grunt all",

src/common/runtime/helper/sys.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint no-process-exit: "off" */
22
/* eslint @typescript-eslint/no-namespace: "off" */
33

4-
function node() {
5-
const { existsSync } = require('fs');
4+
async function node() {
5+
const { existsSync } = await import('fs');
66

77
return {
88
type: 'node',
@@ -41,6 +41,6 @@ function deno() {
4141
};
4242
}
4343

44-
const sys = typeof globalThis.process !== 'undefined' ? node() : deno();
44+
const sys = typeof globalThis.process !== 'undefined' ? await node() : deno();
4545

4646
export default sys;

src/common/tools/commonjs/package.json

Whitespace-only changes.

src/common/tools/setup-ts-in-node.js renamed to src/common/tools/commonjs/setup-ts-in-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require('path');
33
// Automatically transpile .ts imports
44
require('ts-node').register({
55
// Specify the project file so ts-node doesn't try to find it itself based on the CWD.
6-
project: path.resolve(__dirname, '../../../tsconfig.json'),
6+
project: path.resolve(__dirname, '../../../../tsconfig.json'),
77
compilerOptions: {
88
module: 'commonjs',
99
},

src/common/tools/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const version = require('child_process')
1+
export const version = (await import('child_process'))
22
.execSync('git describe --always --abbrev=0 --dirty')
33
.toString()
44
.trim();

tools/checklist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
// and every query in it is valid (e.g. renames have been applied, and new tests added
88
// to the spreadsheet have also been added to the CTS).
99

10-
require('../src/common/tools/setup-ts-in-node.js');
10+
require('../src/common/tools/commonjs/setup-ts-in-node.js');
1111
require('../src/common/tools/checklist.ts');

tools/dev_server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env node
22

3-
require('../src/common/tools/setup-ts-in-node.js');
3+
require('../src/common/tools/commonjs/setup-ts-in-node.js');
44
require('../src/common/tools/dev_server.ts');

tools/gen_cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env node
22

3-
require('../src/common/tools/setup-ts-in-node.js');
3+
require('../src/common/tools/commonjs/setup-ts-in-node.js');
44
require('../src/common/tools/gen_cache.ts');

0 commit comments

Comments
 (0)