diff --git a/.eslintrc.js b/.eslintrc.js index 5a6b0ec2..0d0c7dd1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -228,5 +228,11 @@ module.exports = { '@typescript-eslint/no-require-imports': 'off', '@typescript-eslint/no-var-requires': 'off' } + }, { + files: ['esbuild.js'], + rules: { + '@typescript-eslint/no-require-imports': 'off', + '@typescript-eslint/no-var-requires': 'off' + } }] }; diff --git a/.github/workflows/create-vsix.yml b/.github/workflows/create-vsix.yml index 96d904a0..294ddd69 100644 --- a/.github/workflows/create-vsix.yml +++ b/.github/workflows/create-vsix.yml @@ -7,7 +7,7 @@ on: required: true jobs: create-vsix: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@master - uses: actions/setup-node@master diff --git a/.vscode/tasks.json b/.vscode/tasks.json index eea39dfc..d953fef1 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -14,12 +14,27 @@ "presentation": { "group": "watch", "echo": true, - "reveal": "silent", + "reveal": "always", "focus": false, "panel": "shared" }, "isBackground": true, - "problemMatcher": "$tsc-watch" + "problemMatcher": [ + { + "pattern": { + "regexp": "" + }, + "background": { + "activeOnStart": true, + "beginsPattern": { + "regexp": "\\[watch\\] build started" + }, + "endsPattern": { + "regexp": "\\[watch\\] build finished" + } + } + } + ] }, { "label": "watch-webviews", @@ -28,7 +43,7 @@ "presentation": { "group": "watch", "echo": true, - "reveal": "silent", + "reveal": "always", "focus": false, "panel": "shared" }, @@ -88,4 +103,4 @@ } } ] -} +} \ No newline at end of file diff --git a/esbuild.js b/esbuild.js new file mode 100644 index 00000000..703838eb --- /dev/null +++ b/esbuild.js @@ -0,0 +1,42 @@ +const esbuild = require('esbuild'); +const fsExtra = require('fs-extra'); + +class Plugin { + constructor() { + this.name = 'empty-loader'; + } + setup(build) { + build.onResolve({ filter: /^chokidar$/ }, args => ({ + path: args.path, + namespace: 'empty-loader' + })); + build.onLoad({ filter: /.*/, namespace: 'empty-loader' }, () => ({ + contents: '/*chokidar is not necessary for the language server so we replaced it with an empty object to fix esbuild issues*/\nmodule.exports = {}' + })); + } +} + +esbuild.build({ + entryPoints: { + 'extension': './src/extension.ts', + 'extension-web': './src/extension-web.ts', + 'LanguageServerRunner': './src/LanguageServerRunner.ts', + 'brighterscript': './node_modules/brighterscript/dist/index.js' + }, + bundle: true, + sourcemap: true, + splitting: false, //enable this once esbuild supports commonjs code splitting + treeShaking: true, + watch: process.argv.includes('--watch'), + minify: true, //process.argv.includes('--minify'), + mainFields: ['module', 'main'], + entryNames: '[name]', + outdir: 'dist', + external: [ + 'vscode' + ], + format: 'cjs', + platform: 'node', + logLevel: 'info', + plugins: [new Plugin()] +}).catch((e) => console.error(e)); diff --git a/package-lock.json b/package-lock.json index 6b3a7886..794b64d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -58,6 +58,7 @@ "chalk": "^4.1.2", "changelog-parser": "^2.8.0", "coveralls": "^3.0.11", + "esbuild": "^0.16.4", "eslint": "^8.10.0", "eslint-plugin-github": "^4.3.5", "eslint-plugin-no-only-tests": "^2.6.0", @@ -70,7 +71,7 @@ "rimraf": "^3.0.0", "sinon": "^7.2.3", "source-map-support": "^0.5.21", - "statigen": "^0.4.4", + "statigen": "^0.4.5", "terminal-overwrite": "^2.0.1", "ts-node": "^10.7.0", "tslib": "^2.3.1", @@ -78,6 +79,7 @@ "typescript-json-schema": "^0.50.1", "undent": "^0.1.0", "vsce": "^2.6.7", + "vscode-debugadapter-testsupport": "1.33.0", "vscode-tmgrammar-test": "^0.0.11", "yargs": "^16.2.0" }, @@ -669,6 +671,358 @@ "universalify": "^0.1.0" } }, + "node_modules/@esbuild/android-arm": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.16.4.tgz", + "integrity": "sha512-rZzb7r22m20S1S7ufIc6DC6W659yxoOrl7sKP1nCYhuvUlnCFHVSbATG4keGUtV8rDz11sRRDbWkvQZpzPaHiw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.16.4.tgz", + "integrity": "sha512-VPuTzXFm/m2fcGfN6CiwZTlLzxrKsWbPkG7ArRFpuxyaHUm/XFHQPD4xNwZT6uUmpIHhnSjcaCmcla8COzmZ5Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.16.4.tgz", + "integrity": "sha512-MW+B2O++BkcOfMWmuHXB15/l1i7wXhJFqbJhp82IBOais8RBEQv2vQz/jHrDEHaY2X0QY7Wfw86SBL2PbVOr0g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.16.4.tgz", + "integrity": "sha512-a28X1O//aOfxwJVZVs7ZfM8Tyih2Za4nKJrBwW5Wm4yKsnwBy9aiS/xwpxiiTRttw3EaTg4Srerhcm6z0bu9Wg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.16.4.tgz", + "integrity": "sha512-e3doCr6Ecfwd7VzlaQqEPrnbvvPjE9uoTpxG5pyLzr2rI2NMjDHmvY1E5EO81O/e9TUOLLkXA5m6T8lfjK9yAA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.16.4.tgz", + "integrity": "sha512-Oup3G/QxBgvvqnXWrBed7xxkFNwAwJVHZcklWyQt7YCAL5bfUkaa6FVWnR78rNQiM8MqqLiT6ZTZSdUFuVIg1w==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.16.4.tgz", + "integrity": "sha512-vAP+eYOxlN/Bpo/TZmzEQapNS8W1njECrqkTpNgvXskkkJC2AwOXwZWai/Kc2vEFZUXQttx6UJbj9grqjD/+9Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.16.4.tgz", + "integrity": "sha512-A47ZmtpIPyERxkSvIv+zLd6kNIOtJH03XA0Hy7jaceRDdQaQVGSDt4mZqpWqJYgDk9rg96aglbF6kCRvPGDSUA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.16.4.tgz", + "integrity": "sha512-2zXoBhv4r5pZiyjBKrOdFP4CXOChxXiYD50LRUU+65DkdS5niPFHbboKZd/c81l0ezpw7AQnHeoCy5hFrzzs4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.16.4.tgz", + "integrity": "sha512-uxdSrpe9wFhz4yBwt2kl2TxS/NWEINYBUFIxQtaEVtglm1eECvsj1vEKI0KX2k2wCe17zDdQ3v+jVxfwVfvvjw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.16.4.tgz", + "integrity": "sha512-peDrrUuxbZ9Jw+DwLCh/9xmZAk0p0K1iY5d2IcwmnN+B87xw7kujOkig6ZRcZqgrXgeRGurRHn0ENMAjjD5DEg==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.16.4.tgz", + "integrity": "sha512-sD9EEUoGtVhFjjsauWjflZklTNr57KdQ6xfloO4yH1u7vNQlOfAlhEzbyBKfgbJlW7rwXYBdl5/NcZ+Mg2XhQA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.16.4.tgz", + "integrity": "sha512-X1HSqHUX9D+d0l6/nIh4ZZJ94eQky8d8z6yxAptpZE3FxCWYWvTDd9X9ST84MGZEJx04VYUD/AGgciddwO0b8g==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.16.4.tgz", + "integrity": "sha512-97ANpzyNp0GTXCt6SRdIx1ngwncpkV/z453ZuxbnBROCJ5p/55UjhbaG23UdHj88fGWLKPFtMoU4CBacz4j9FA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.16.4.tgz", + "integrity": "sha512-pUvPQLPmbEeJRPjP0DYTC1vjHyhrnCklQmCGYbipkep+oyfTn7GTBJXoPodR7ZS5upmEyc8lzAkn2o29wD786A==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.16.4.tgz", + "integrity": "sha512-N55Q0mJs3Sl8+utPRPBrL6NLYZKBCLLx0bme/+RbjvMforTGGzFvsRl4xLTZMUBFC1poDzBEPTEu5nxizQ9Nlw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.16.4.tgz", + "integrity": "sha512-LHSJLit8jCObEQNYkgsDYBh2JrJT53oJO2HVdkSYLa6+zuLJh0lAr06brXIkljrlI+N7NNW1IAXGn/6IZPi3YQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.16.4.tgz", + "integrity": "sha512-nLgdc6tWEhcCFg/WVFaUxHcPK3AP/bh+KEwKtl69Ay5IBqUwKDaq/6Xk0E+fh/FGjnLwqFSsarsbPHeKM8t8Sw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.16.4.tgz", + "integrity": "sha512-08SluG24GjPO3tXKk95/85n9kpyZtXCVwURR2i4myhrOfi3jspClV0xQQ0W0PYWHioJj+LejFMt41q+PG3mlAQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.16.4.tgz", + "integrity": "sha512-yYiRDQcqLYQSvNQcBKN7XogbrSvBE45FEQdH8fuXPl7cngzkCvpsG2H9Uey39IjQ6gqqc+Q4VXYHsQcKW0OMjQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.16.4.tgz", + "integrity": "sha512-5rabnGIqexekYkh9zXG5waotq8mrdlRoBqAktjx2W3kb0zsI83mdCwrcAeKYirnUaTGztR5TxXcXmQrEzny83w==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.16.4.tgz", + "integrity": "sha512-sN/I8FMPtmtT2Yw+Dly8Ur5vQ5a/RmC8hW7jO9PtPSQUPkowxWpcUZnqOggU7VwyT3Xkj6vcXWd3V/qTXwultQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@eslint/eslintrc": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", @@ -3586,6 +3940,43 @@ "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", "dev": true }, + "node_modules/esbuild": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.16.4.tgz", + "integrity": "sha512-qQrPMQpPTWf8jHugLWHoGqZjApyx3OEm76dlTXobHwh/EBbavbRdjXdYi/GWr43GyN0sfpap14GPkb05NH3ROA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.16.4", + "@esbuild/android-arm64": "0.16.4", + "@esbuild/android-x64": "0.16.4", + "@esbuild/darwin-arm64": "0.16.4", + "@esbuild/darwin-x64": "0.16.4", + "@esbuild/freebsd-arm64": "0.16.4", + "@esbuild/freebsd-x64": "0.16.4", + "@esbuild/linux-arm": "0.16.4", + "@esbuild/linux-arm64": "0.16.4", + "@esbuild/linux-ia32": "0.16.4", + "@esbuild/linux-loong64": "0.16.4", + "@esbuild/linux-mips64el": "0.16.4", + "@esbuild/linux-ppc64": "0.16.4", + "@esbuild/linux-riscv64": "0.16.4", + "@esbuild/linux-s390x": "0.16.4", + "@esbuild/linux-x64": "0.16.4", + "@esbuild/netbsd-x64": "0.16.4", + "@esbuild/openbsd-x64": "0.16.4", + "@esbuild/sunos-x64": "0.16.4", + "@esbuild/win32-arm64": "0.16.4", + "@esbuild/win32-ia32": "0.16.4", + "@esbuild/win32-x64": "0.16.4" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -10381,6 +10772,23 @@ "vscode-debugprotocol": "1.51.0" } }, + "node_modules/vscode-debugadapter-testsupport": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/vscode-debugadapter-testsupport/-/vscode-debugadapter-testsupport-1.33.0.tgz", + "integrity": "sha512-HusC7JpYQyVGzV08hYgjv+9Cm0v+6/ZbXxAlQLMFXjQNZgbFCrk2kTflurxrQCt+beb05cjin9RbSFWWaYH8PQ==", + "deprecated": "This package has been renamed to @vscode/debugadapter-testsupport, please update to the new name", + "dev": true, + "dependencies": { + "vscode-debugprotocol": "1.33.0" + } + }, + "node_modules/vscode-debugadapter-testsupport/node_modules/vscode-debugprotocol": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/vscode-debugprotocol/-/vscode-debugprotocol-1.33.0.tgz", + "integrity": "sha512-d+l4lrEz6OP2kmGpweqe37x9H7icAMV8S4m8azTWGAIlNJxBP4rlSTnZa7NMLcbgqWkWG9lTGY7fJ+rSPaW7yg==", + "deprecated": "This package has been renamed to @vscode/debugprotocol, please update to the new name", + "dev": true + }, "node_modules/vscode-debugadapter/node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -11378,6 +11786,160 @@ } } }, + "@esbuild/android-arm": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.16.4.tgz", + "integrity": "sha512-rZzb7r22m20S1S7ufIc6DC6W659yxoOrl7sKP1nCYhuvUlnCFHVSbATG4keGUtV8rDz11sRRDbWkvQZpzPaHiw==", + "dev": true, + "optional": true + }, + "@esbuild/android-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.16.4.tgz", + "integrity": "sha512-VPuTzXFm/m2fcGfN6CiwZTlLzxrKsWbPkG7ArRFpuxyaHUm/XFHQPD4xNwZT6uUmpIHhnSjcaCmcla8COzmZ5Q==", + "dev": true, + "optional": true + }, + "@esbuild/android-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.16.4.tgz", + "integrity": "sha512-MW+B2O++BkcOfMWmuHXB15/l1i7wXhJFqbJhp82IBOais8RBEQv2vQz/jHrDEHaY2X0QY7Wfw86SBL2PbVOr0g==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.16.4.tgz", + "integrity": "sha512-a28X1O//aOfxwJVZVs7ZfM8Tyih2Za4nKJrBwW5Wm4yKsnwBy9aiS/xwpxiiTRttw3EaTg4Srerhcm6z0bu9Wg==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.16.4.tgz", + "integrity": "sha512-e3doCr6Ecfwd7VzlaQqEPrnbvvPjE9uoTpxG5pyLzr2rI2NMjDHmvY1E5EO81O/e9TUOLLkXA5m6T8lfjK9yAA==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.16.4.tgz", + "integrity": "sha512-Oup3G/QxBgvvqnXWrBed7xxkFNwAwJVHZcklWyQt7YCAL5bfUkaa6FVWnR78rNQiM8MqqLiT6ZTZSdUFuVIg1w==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.16.4.tgz", + "integrity": "sha512-vAP+eYOxlN/Bpo/TZmzEQapNS8W1njECrqkTpNgvXskkkJC2AwOXwZWai/Kc2vEFZUXQttx6UJbj9grqjD/+9Q==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.16.4.tgz", + "integrity": "sha512-A47ZmtpIPyERxkSvIv+zLd6kNIOtJH03XA0Hy7jaceRDdQaQVGSDt4mZqpWqJYgDk9rg96aglbF6kCRvPGDSUA==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.16.4.tgz", + "integrity": "sha512-2zXoBhv4r5pZiyjBKrOdFP4CXOChxXiYD50LRUU+65DkdS5niPFHbboKZd/c81l0ezpw7AQnHeoCy5hFrzzs4g==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ia32": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.16.4.tgz", + "integrity": "sha512-uxdSrpe9wFhz4yBwt2kl2TxS/NWEINYBUFIxQtaEVtglm1eECvsj1vEKI0KX2k2wCe17zDdQ3v+jVxfwVfvvjw==", + "dev": true, + "optional": true + }, + "@esbuild/linux-loong64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.16.4.tgz", + "integrity": "sha512-peDrrUuxbZ9Jw+DwLCh/9xmZAk0p0K1iY5d2IcwmnN+B87xw7kujOkig6ZRcZqgrXgeRGurRHn0ENMAjjD5DEg==", + "dev": true, + "optional": true + }, + "@esbuild/linux-mips64el": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.16.4.tgz", + "integrity": "sha512-sD9EEUoGtVhFjjsauWjflZklTNr57KdQ6xfloO4yH1u7vNQlOfAlhEzbyBKfgbJlW7rwXYBdl5/NcZ+Mg2XhQA==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ppc64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.16.4.tgz", + "integrity": "sha512-X1HSqHUX9D+d0l6/nIh4ZZJ94eQky8d8z6yxAptpZE3FxCWYWvTDd9X9ST84MGZEJx04VYUD/AGgciddwO0b8g==", + "dev": true, + "optional": true + }, + "@esbuild/linux-riscv64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.16.4.tgz", + "integrity": "sha512-97ANpzyNp0GTXCt6SRdIx1ngwncpkV/z453ZuxbnBROCJ5p/55UjhbaG23UdHj88fGWLKPFtMoU4CBacz4j9FA==", + "dev": true, + "optional": true + }, + "@esbuild/linux-s390x": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.16.4.tgz", + "integrity": "sha512-pUvPQLPmbEeJRPjP0DYTC1vjHyhrnCklQmCGYbipkep+oyfTn7GTBJXoPodR7ZS5upmEyc8lzAkn2o29wD786A==", + "dev": true, + "optional": true + }, + "@esbuild/linux-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.16.4.tgz", + "integrity": "sha512-N55Q0mJs3Sl8+utPRPBrL6NLYZKBCLLx0bme/+RbjvMforTGGzFvsRl4xLTZMUBFC1poDzBEPTEu5nxizQ9Nlw==", + "dev": true, + "optional": true + }, + "@esbuild/netbsd-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.16.4.tgz", + "integrity": "sha512-LHSJLit8jCObEQNYkgsDYBh2JrJT53oJO2HVdkSYLa6+zuLJh0lAr06brXIkljrlI+N7NNW1IAXGn/6IZPi3YQ==", + "dev": true, + "optional": true + }, + "@esbuild/openbsd-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.16.4.tgz", + "integrity": "sha512-nLgdc6tWEhcCFg/WVFaUxHcPK3AP/bh+KEwKtl69Ay5IBqUwKDaq/6Xk0E+fh/FGjnLwqFSsarsbPHeKM8t8Sw==", + "dev": true, + "optional": true + }, + "@esbuild/sunos-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.16.4.tgz", + "integrity": "sha512-08SluG24GjPO3tXKk95/85n9kpyZtXCVwURR2i4myhrOfi3jspClV0xQQ0W0PYWHioJj+LejFMt41q+PG3mlAQ==", + "dev": true, + "optional": true + }, + "@esbuild/win32-arm64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.16.4.tgz", + "integrity": "sha512-yYiRDQcqLYQSvNQcBKN7XogbrSvBE45FEQdH8fuXPl7cngzkCvpsG2H9Uey39IjQ6gqqc+Q4VXYHsQcKW0OMjQ==", + "dev": true, + "optional": true + }, + "@esbuild/win32-ia32": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.16.4.tgz", + "integrity": "sha512-5rabnGIqexekYkh9zXG5waotq8mrdlRoBqAktjx2W3kb0zsI83mdCwrcAeKYirnUaTGztR5TxXcXmQrEzny83w==", + "dev": true, + "optional": true + }, + "@esbuild/win32-x64": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.16.4.tgz", + "integrity": "sha512-sN/I8FMPtmtT2Yw+Dly8Ur5vQ5a/RmC8hW7jO9PtPSQUPkowxWpcUZnqOggU7VwyT3Xkj6vcXWd3V/qTXwultQ==", + "dev": true, + "optional": true + }, "@eslint/eslintrc": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", @@ -13625,6 +14187,36 @@ "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", "dev": true }, + "esbuild": { + "version": "0.16.4", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.16.4.tgz", + "integrity": "sha512-qQrPMQpPTWf8jHugLWHoGqZjApyx3OEm76dlTXobHwh/EBbavbRdjXdYi/GWr43GyN0sfpap14GPkb05NH3ROA==", + "dev": true, + "requires": { + "@esbuild/android-arm": "0.16.4", + "@esbuild/android-arm64": "0.16.4", + "@esbuild/android-x64": "0.16.4", + "@esbuild/darwin-arm64": "0.16.4", + "@esbuild/darwin-x64": "0.16.4", + "@esbuild/freebsd-arm64": "0.16.4", + "@esbuild/freebsd-x64": "0.16.4", + "@esbuild/linux-arm": "0.16.4", + "@esbuild/linux-arm64": "0.16.4", + "@esbuild/linux-ia32": "0.16.4", + "@esbuild/linux-loong64": "0.16.4", + "@esbuild/linux-mips64el": "0.16.4", + "@esbuild/linux-ppc64": "0.16.4", + "@esbuild/linux-riscv64": "0.16.4", + "@esbuild/linux-s390x": "0.16.4", + "@esbuild/linux-x64": "0.16.4", + "@esbuild/netbsd-x64": "0.16.4", + "@esbuild/openbsd-x64": "0.16.4", + "@esbuild/sunos-x64": "0.16.4", + "@esbuild/win32-arm64": "0.16.4", + "@esbuild/win32-ia32": "0.16.4", + "@esbuild/win32-x64": "0.16.4" + } + }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -18801,6 +19393,23 @@ } } }, + "vscode-debugadapter-testsupport": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/vscode-debugadapter-testsupport/-/vscode-debugadapter-testsupport-1.33.0.tgz", + "integrity": "sha512-HusC7JpYQyVGzV08hYgjv+9Cm0v+6/ZbXxAlQLMFXjQNZgbFCrk2kTflurxrQCt+beb05cjin9RbSFWWaYH8PQ==", + "dev": true, + "requires": { + "vscode-debugprotocol": "1.33.0" + }, + "dependencies": { + "vscode-debugprotocol": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/vscode-debugprotocol/-/vscode-debugprotocol-1.33.0.tgz", + "integrity": "sha512-d+l4lrEz6OP2kmGpweqe37x9H7icAMV8S4m8azTWGAIlNJxBP4rlSTnZa7NMLcbgqWkWG9lTGY7fJ+rSPaW7yg==", + "dev": true + } + } + }, "vscode-debugprotocol": { "version": "1.51.0", "resolved": "https://registry.npmjs.org/vscode-debugprotocol/-/vscode-debugprotocol-1.51.0.tgz", diff --git a/package.json b/package.json index 0384b0d1..765872b5 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ "name": "Bronley Plumb", "email": "bronley@gmail.com" }, + "main": "./dist/extension", + "browser": "./dist/extension-web", "icon": "images/logo.png", "license": "MIT", "keywords": [ @@ -26,18 +28,18 @@ }, "scripts": { "postinstall": "cd webviews && npm install", - "preversion": "npm run build && npm run lint && npm run test && npm run check-extraneous", + "preversion": "npm run build && npm run typecheck && npm run lint && npm run test", "vscode:prepublish": "npm run build", "copy-schema": "cpx ./node_modules/brighterscript/bsconfig.schema.json ./dist -L", - "build": "npm run copy-schema && tsc -p ./ && npm run build-webviews", + "build": "npm run copy-schema && node ./esbuild.js && npm run build-webviews", "build-webviews": "cd ./webviews && npm run build && cd ..", "lint": "eslint \"./src/**/*.ts\"", - "watch": "npm run copy-schema && tsc -w -p ./", + "typecheck": "tsc --noEmit", + "watch": "npm run copy-schema && node ./esbuild.js --watch", "watch-webviews": "cd ./webviews && npm run watch", "test": "nyc mocha", "test:nocover": "mocha", "publish-coverage": "nyc report --reporter=text-lcov | coveralls", - "check-extraneous": "npm list --production --parseable --depth=99999", "package": "vsce package", "package-local": "node scripts/package-local.js", "publish": "vsce publish", @@ -98,6 +100,7 @@ "chalk": "^4.1.2", "changelog-parser": "^2.8.0", "coveralls": "^3.0.11", + "esbuild": "^0.16.4", "eslint": "^8.10.0", "eslint-plugin-github": "^4.3.5", "eslint-plugin-no-only-tests": "^2.6.0", @@ -110,7 +113,7 @@ "rimraf": "^3.0.0", "sinon": "^7.2.3", "source-map-support": "^0.5.21", - "statigen": "^0.4.4", + "statigen": "^0.4.5", "terminal-overwrite": "^2.0.1", "ts-node": "^10.7.0", "tslib": "^2.3.1", @@ -118,14 +121,13 @@ "typescript-json-schema": "^0.50.1", "undent": "^0.1.0", "vsce": "^2.6.7", + "vscode-debugadapter-testsupport": "1.33.0", "vscode-tmgrammar-test": "^0.0.11", "yargs": "^16.2.0" }, "optionalDependencies": { "fsevents": "~2.3.2" }, - "main": "./dist/extension", - "browser": "./dist/extension-web", "activationEvents": [ "onDebug", "onLanguage:brightscript", @@ -3345,4 +3347,4 @@ "Debuggers", "Snippets" ] -} \ No newline at end of file +} diff --git a/scripts/preversion.js b/scripts/preversion.js deleted file mode 100644 index 709d96a8..00000000 --- a/scripts/preversion.js +++ /dev/null @@ -1,79 +0,0 @@ - -var fs = require('fs'); -var changelogParser = require('changelog-parser'); - -/** - * Perform various checks that should block a release until resolved - */ -class PreversionValidator { - async run() { - this.errors = []; - this.checkLocalPackages(); - await this.checkChangelog(); - - if (this.errors.length > 0) { - this.errors.map(x => console.log(x)); - process.exit(-1); - } - } - - checkLocalPackages() { - var packageJson = JSON.parse(fs.readFileSync('package.json').toString()); - for (let name in packageJson.dependencies) { - let version = packageJson.dependencies[name]; - if (version.startsWith('file:')) { - this.errors.push(`package.json dependency '${name}' references local package '${version}'`); - } - } - for (let name in packageJson.devDependencies) { - let version = packageJson.devDependencies[name]; - if (version.startsWith('file:')) { - this.errors.push(`package.json devDependency '${name}' references local package '${version}'`); - } - } - } - - async checkChangelog() { - var links = {}; - var changelog = fs.readFileSync('CHANGELOG.md').toString(); - var lines = changelog.split(/\r?\n/g); - //walk backwards in the file until we find the first non-link line - for (var i = lines.length - 1; i >= 0; i--) { - //skip empty lines - if (!lines[i].trim()) { - continue; - } - var match = /^\[(.*)\]\:\s*(.*)$/.exec(lines[i]); - if (match) { - links[match[1]] = match[2]; - } else { - break; - } - } - - var parsedChangelog = await changelogParser('CHANGELOG.md'); - for (var version of parsedChangelog.versions) { - if (version.title.startsWith('[') === false) { - this.errors.push(`Changelog version in header is not a link: '${version.title}'`); - continue; - } - //ensure the title has a version number link - var match = /^\[(\d+\.\d+\.\d+.*)\]/.exec(version.title) - if (!match) { - this.errors.push(`Changlog contains invalid version number in header '${version.title}'`); - } - var versionNumber = match ? match[1] : undefined; - if (!links[versionNumber]) { - this.errors.push(`Changelog is missing link for version '${versionNumber}'`); - } - - //header must end with date - if (/\d\d\d\d\-\d\d\-\d\d$/gi.test(version.title) === false) { - this.errors.push(`Changelog is missing date in header '${version.title}'`); - } - - } - } -} - -new PreversionValidator().run(); diff --git a/src/ActiveDeviceManager.ts b/src/ActiveDeviceManager.ts index 8d292c72..4d69747e 100644 --- a/src/ActiveDeviceManager.ts +++ b/src/ActiveDeviceManager.ts @@ -2,7 +2,7 @@ import * as backoff from 'backoff'; import { EventEmitter } from 'events'; import * as xmlParser from 'fast-xml-parser'; import * as http from 'http'; -import * as NodeCache from 'node-cache'; +import NodeCache from 'node-cache'; import type { SsdpHeaders } from 'node-ssdp'; import { Client } from 'node-ssdp'; import { URL } from 'url'; diff --git a/src/LanguageServerManager.spec.ts b/src/LanguageServerManager.spec.ts index 06225aa0..3d76f9eb 100644 --- a/src/LanguageServerManager.spec.ts +++ b/src/LanguageServerManager.spec.ts @@ -10,10 +10,11 @@ import { standardizePath as s } from 'brighterscript'; import * as fsExtra from 'fs-extra'; import URI from 'vscode-uri'; import { languageServerInfoCommand } from './commands/LanguageServerInfoCommand'; - const Module = require('module'); const sinon = createSandbox(); +const cwd = s`${__dirname}/../`; + //override the "require" call to mock certain items const { require: oldRequire } = Module.prototype; Module.prototype.require = function hijacked(file) { @@ -109,7 +110,7 @@ describe('extension', () => { }); describe('getBsdkPath', () => { - const embeddedPath = path.resolve(s`${__dirname}/../node_modules/brighterscript`); + const embeddedPath = 'brighterscript.js'; function setConfig(filePath: string, settings: any) { if (filePath.endsWith('.code-workspace')) { diff --git a/src/LanguageServerManager.ts b/src/LanguageServerManager.ts index a7a1eb9a..22956d63 100644 --- a/src/LanguageServerManager.ts +++ b/src/LanguageServerManager.ts @@ -25,14 +25,16 @@ import type { DefinitionRepository } from './DefinitionRepository'; import { util } from './util'; import { LanguageServerInfoCommand, languageServerInfoCommand } from './commands/LanguageServerInfoCommand'; import * as fsExtra from 'fs-extra'; +// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires +const embeddedBrighterscriptVersion = require('brighterscript/package.json').version; export class LanguageServerManager { constructor() { this.deferred = new Deferred(); this.embeddedBscInfo = { - path: require.resolve('brighterscript').replace(/[\\\/]dist[\\\/]index.js/i, ''), + path: './brighterscript.js', // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires - version: require('brighterscript/package.json').version + version: embeddedBrighterscriptVersion }; //default to the embedded bsc version this.selectedBscInfo = this.embeddedBscInfo; @@ -288,7 +290,6 @@ export class LanguageServerManager { if (bsdkPath !== this.selectedBscInfo.path) { await this.disableLanguageServer(); } - //try to load the package version. try { this.selectedBscInfo = { diff --git a/src/autoIndent.spec.ts b/src/autoIndent.spec.ts index 9317b392..9ddb2106 100644 --- a/src/autoIndent.spec.ts +++ b/src/autoIndent.spec.ts @@ -1,5 +1,5 @@ import { readFileSync } from 'fs-extra'; -import * as glob from 'glob'; +import glob from 'glob'; import { expect } from 'chai'; import undent from 'undent'; interface IndentationRulesJSON { diff --git a/src/commands/LanguageServerInfoCommand.ts b/src/commands/LanguageServerInfoCommand.ts index 1cef7961..70a90946 100644 --- a/src/commands/LanguageServerInfoCommand.ts +++ b/src/commands/LanguageServerInfoCommand.ts @@ -60,7 +60,7 @@ export class LanguageServerInfoCommand { detail: bscPath }); } - } finally { } + } catch { } } let selection = await vscode.window.showQuickPick(versions, { placeHolder: `Select the BrighterScript version used for BrightScript and BrighterScript language features` }); if (selection) { diff --git a/src/extension.ts b/src/extension.ts index 293e9325..01f86859 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode'; -import * as prettyBytes from 'pretty-bytes'; +import prettyBytes from 'pretty-bytes'; import { extensions } from 'vscode'; import * as rta from 'roku-test-automation'; import * as path from 'path'; @@ -322,8 +322,8 @@ export class Extension { } } } - } + export const extension = new Extension(); export async function activate(context: vscode.ExtensionContext) { await extension.activate(context); diff --git a/src/util.spec.ts b/src/util.spec.ts index 67b07cf7..9e4db28f 100644 --- a/src/util.spec.ts +++ b/src/util.spec.ts @@ -1,7 +1,7 @@ import * as assert from 'assert'; import { expect } from 'chai'; import * as fsExtra from 'fs-extra'; -import * as getPort from 'get-port'; +import getPort from 'get-port'; import * as net from 'net'; import * as path from 'path'; import * as sinonActual from 'sinon'; diff --git a/src/viewProviders/RendezvousViewProvider.ts b/src/viewProviders/RendezvousViewProvider.ts index 27ce3df1..afcd06f2 100644 --- a/src/viewProviders/RendezvousViewProvider.ts +++ b/src/viewProviders/RendezvousViewProvider.ts @@ -1,4 +1,4 @@ -import * as arraySort from 'array-sort'; +import arraySort from 'array-sort'; import * as vscode from 'vscode'; import type { RendezvousHistory } from 'roku-debug'; import { isRendezvousEvent } from 'roku-debug'; diff --git a/tsconfig.json b/tsconfig.json index ca7673ab..7d47a999 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,6 +14,7 @@ "strictNullChecks": false, "noUnusedParameters": false, "allowSyntheticDefaultImports": true, + "esModuleInterop": true, "forceConsistentCasingInFileNames": true }, "include": [