mirror of
https://github.com/tauri-apps/tauri-vscode.git
synced 2026-01-31 00:35:18 +01:00
fix: bundle extension using tsup (#268)
* fix: bundle extension using tsup closes #267 * deps
This commit is contained in:
5
.changes/bundle-tsup.md
Normal file
5
.changes/bundle-tsup.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'tauri-vscode': patch
|
||||
---
|
||||
|
||||
Fix extension failing to active due missing dependencies
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,6 +6,6 @@
|
||||
npm-debug.log
|
||||
Thumbs.db
|
||||
node_modules/
|
||||
out/
|
||||
dist/
|
||||
.vs/
|
||||
.vscode-test/
|
||||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -15,7 +15,7 @@
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
|
||||
"outFiles": ["${workspaceFolder}/out/**/*.js"],
|
||||
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
|
||||
"preLaunchTask": "${defaultBuildTask}"
|
||||
}
|
||||
]
|
||||
|
||||
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
@@ -9,9 +9,7 @@
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "watch",
|
||||
"problemMatcher": "$tsc-watch",
|
||||
"isBackground": true,
|
||||
"script": "compile",
|
||||
"presentation": {
|
||||
"reveal": "never"
|
||||
},
|
||||
|
||||
@@ -4,10 +4,14 @@
|
||||
|
||||
.vscode/**
|
||||
.vscode-test/**
|
||||
out/test/**
|
||||
dist/test/**
|
||||
src/**
|
||||
.gitignore
|
||||
vsc-extension-quickstart.md
|
||||
**/tsconfig.json
|
||||
**/*.map
|
||||
**/*.ts
|
||||
.changes
|
||||
.github
|
||||
renovate.json
|
||||
.prettierrc
|
||||
13
package.json
13
package.json
@@ -38,7 +38,7 @@
|
||||
"workspaceContains:**/tauri.*.conf.json5",
|
||||
"onFileSystem:tauri"
|
||||
],
|
||||
"main": "./out/extension.js",
|
||||
"main": "./dist/extension.js",
|
||||
"contributes": {
|
||||
"jsonValidation": [
|
||||
{
|
||||
@@ -82,20 +82,19 @@
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "pnpm run compile",
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"compile": "tsup src/extension.ts --clean --format cjs --external vscode",
|
||||
"watch": "pnpm run compile --watch",
|
||||
"format": "prettier ./**/*.{json,ts,js} -w --ignore-path .gitignore"
|
||||
},
|
||||
"dependencies": {
|
||||
"devDependencies": {
|
||||
"axios": "1.7.7",
|
||||
"glob": "11.0.0",
|
||||
"run-in-terminal": "0.0.3",
|
||||
"strip-ansi": "7.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"strip-ansi": "7.1.0",
|
||||
"@types/node": "18.19.31",
|
||||
"@types/vscode": "1.75.0",
|
||||
"prettier": "3.3.3",
|
||||
"tsup": "^8.2.4",
|
||||
"typescript": "5.5.4"
|
||||
},
|
||||
"packageManager": "pnpm@9.9.0"
|
||||
|
||||
1082
pnpm-lock.yaml
generated
1082
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -5,14 +5,11 @@
|
||||
import * as vscode from 'vscode'
|
||||
import { exec, execSync, ChildProcess } from 'child_process'
|
||||
import { runInTerminal } from 'run-in-terminal'
|
||||
import { join } from 'path'
|
||||
import { existsSync, readFileSync } from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import axios from 'axios'
|
||||
|
||||
const stripAnsi = require('strip-ansi')
|
||||
const glob = require('glob')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
import stripAnsi from 'strip-ansi'
|
||||
import { glob } from 'glob'
|
||||
|
||||
interface Process {
|
||||
process: ChildProcess
|
||||
@@ -71,7 +68,7 @@ function registerSchemasHandler(context: vscode.ExtensionContext) {
|
||||
)
|
||||
)[0]
|
||||
|
||||
if (schemaFile) return readFileSync(schemaFile.fsPath, 'utf-8')
|
||||
if (schemaFile) return fs.readFileSync(schemaFile.fsPath, 'utf-8')
|
||||
|
||||
async function getSchemaFromRelease(version: string) {
|
||||
const filename = version.startsWith('1')
|
||||
@@ -89,7 +86,7 @@ function registerSchemasHandler(context: vscode.ExtensionContext) {
|
||||
await vscode.workspace.findFiles('**/Cargo.lock')
|
||||
)[0]
|
||||
if (cargoLockPath) {
|
||||
const cargoLock = readFileSync(cargoLockPath.fsPath, 'utf-8')
|
||||
const cargoLock = fs.readFileSync(cargoLockPath.fsPath, 'utf-8')
|
||||
const matches =
|
||||
/\[\[package\]\]\nname = "tauri-build"\nversion = "(.*)"/g.exec(
|
||||
cargoLock
|
||||
@@ -105,7 +102,7 @@ function registerSchemasHandler(context: vscode.ExtensionContext) {
|
||||
await vscode.workspace.findFiles('**/Cargo.toml')
|
||||
)[0]
|
||||
if (cargoTomlPath) {
|
||||
const cargoToml = readFileSync(cargoTomlPath.fsPath, 'utf-8')
|
||||
const cargoToml = fs.readFileSync(cargoTomlPath.fsPath, 'utf-8')
|
||||
|
||||
for (const regex of [
|
||||
// specifying a dependency in Cargo.toml can be done in 4 ways
|
||||
@@ -172,7 +169,7 @@ function runTauriInit(): void {
|
||||
: `${__getNpmBin()} install @tauri-apps/cli --save-dev`
|
||||
onInstall = () => {
|
||||
const packageJson = JSON.parse(
|
||||
fs.readFileSync(`${projectPath}/package.json`)
|
||||
fs.readFileSync(`${projectPath}/package.json`, 'utf8')
|
||||
)
|
||||
if (!packageJson.scripts) {
|
||||
packageJson.scripts = {}
|
||||
@@ -232,7 +229,7 @@ function __isVueCliApp(cwd: string): boolean {
|
||||
}
|
||||
|
||||
function __isNodeProject(cwd: string): boolean {
|
||||
return existsSync(join(cwd, 'package.json'))
|
||||
return fs.existsSync(path.join(cwd, 'package.json'))
|
||||
}
|
||||
|
||||
interface PackageJson {
|
||||
@@ -244,10 +241,10 @@ interface PackageJson {
|
||||
}
|
||||
}
|
||||
|
||||
function __getPackageJson(path: string): PackageJson | null {
|
||||
const packagePath = join(path, 'package.json')
|
||||
if (existsSync(packagePath)) {
|
||||
const packageStr = readFileSync(packagePath).toString()
|
||||
function __getPackageJson(packageJsonPath: string): PackageJson | null {
|
||||
const packagePath = path.join(packageJsonPath, 'package.json')
|
||||
if (fs.existsSync(packageJsonPath)) {
|
||||
const packageStr = fs.readFileSync(packageJsonPath).toString()
|
||||
return JSON.parse(packageStr) as PackageJson
|
||||
} else {
|
||||
return null
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"module": "commonjs",
|
||||
"target": "es2020",
|
||||
"lib": ["es2020"],
|
||||
"outDir": "out",
|
||||
"outDir": "dist",
|
||||
"sourceMap": true,
|
||||
"skipLibCheck": true,
|
||||
"allowJs": false,
|
||||
|
||||
Reference in New Issue
Block a user