From 0864d30e3a24de6df61ab303de76e0b9e1889970 Mon Sep 17 00:00:00 2001 From: Brandon Scott Date: Mon, 10 May 2021 19:28:41 -0400 Subject: [PATCH] Add esbuild, update build + watch scripts, remove node_modules from vscode packaging to vastly reduce file count --- .vscodeignore | 19 +++++++++++-------- package-lock.json | 6 ++++++ package.json | 12 ++++++++---- .../add-translation-to-culture-files.ts | 2 +- tsconfig.json | 2 +- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.vscodeignore b/.vscodeignore index 517c0ce..e7b4c66 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,13 +1,16 @@ -.vscode/** -.vscode-test/** -*.test.ts -**/test/* -src/** +.github/** .gitignore +.vscode-test/** +.vscode/** .yarnrc -vsc-extension-quickstart.md -**/tsconfig.json +*.test.ts **/.eslintrc.json **/*.map **/*.ts -examples/** \ No newline at end of file +**/test/* +**/tsconfig.json +esbuild.js +examples/** +node_modules +src/** +vsc-extension-quickstart.md diff --git a/package-lock.json b/package-lock.json index cf3852f..24e5c78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -852,6 +852,12 @@ "ansi-colors": "^4.1.1" } }, + "esbuild": { + "version": "0.11.20", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.11.20.tgz", + "integrity": "sha512-QOZrVpN/Yz74xfat0H6euSgn3RnwLevY1mJTEXneukz1ln9qB+ieaerRMzSeETpz/UJWsBMzRVR/andBht5WKw==", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", diff --git a/package.json b/package.json index f4a82a6..ea5495a 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "@types/vscode": "1.54.0", "@typescript-eslint/eslint-plugin": "4.14.1", "@typescript-eslint/parser": "4.14.1", + "esbuild": "0.11.20", "eslint": "7.19.0", "faker": "5.5.3", "glob": "7.1.6", @@ -115,16 +116,19 @@ "url": "https://github.com/brandongregoryscott/kazoo.git" }, "scripts": { - "build": "tsc --pretty --project tsconfig.json", + "esbuild": "./node_modules/esbuild/bin/esbuild src/extension.ts --bundle --outfile=dist/extension.js --platform=node --external:vscode", + "build": "npm run esbuild -- --sourcemap", + "build:dist": "npm run esbuild -- --minify", "clean": "rimraf dist **/tmp/*", "lint": "eslint src --ext ts", "postpublish": "git add -A && git commit -m \"$npm_package_version\" && git push origin main", "prebuild": "npm run clean", "pretest": "npm run build && npm run lint", - "prevscode:publish": "npm run build", + "prevscode:publish": "npm run build:dist", "test": "node ./dist/test/runTest.js", - "vscode:publish": "vsce package && vsce publish", - "watch": "tsc --pretty --watch --project tsconfig.json" + "vscode:pack": "vsce package", + "vscode:publish": "npm run vscode:package && vsce publish", + "watch": "npm run esbuild -- --sourcemap --watch" }, "version": "0.1.0" } diff --git a/src/commands/add-translation-to-culture-files.ts b/src/commands/add-translation-to-culture-files.ts index 0a424c1..36f63a5 100644 --- a/src/commands/add-translation-to-culture-files.ts +++ b/src/commands/add-translation-to-culture-files.ts @@ -10,7 +10,7 @@ import { StringUtils } from "../utilities/string-utils"; import { ConfigUtils } from "../utilities/config-utils"; import { InsertionPosition } from "../enums/insertion-position"; import { WindowUtils } from "../utilities/window-utils"; -import * as translate from "@vitalets/google-translate-api"; +import translate from "@vitalets/google-translate-api"; import { DEFAULT_LANGUAGE_CODE } from "../constants/language-code-map"; import { Property } from "../types/property"; import { SourceFileUtils } from "../utilities/source-file-utils"; diff --git a/tsconfig.json b/tsconfig.json index 5bcccb0..116e582 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "esModuleInterop": false, + "esModuleInterop": true, "lib": ["es6"], "module": "commonjs", "outDir": "dist",