diff --git a/.changes/fix-optional-chdir.md b/.changes/fix-optional-chdir.md new file mode 100644 index 0000000..a23e9c8 --- /dev/null +++ b/.changes/fix-optional-chdir.md @@ -0,0 +1,5 @@ +--- +"tauri-build": patch +--- + +Only change working directory when projectPath is given. \ No newline at end of file diff --git a/package.json b/package.json index 90f6d1a..fbe6ad0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "tauri-build", "version": "0.1.2-beta.2", "description": "TypeScript template action", - "main": "lib/main.js", + "module": "lib/main.js", + "type": "module", "scripts": { "build": "tsc", "format": "prettier --write '**/*.ts'", diff --git a/src/build-project.ts b/src/build-project.ts index a4ac368..c0a9d15 100644 --- a/src/build-project.ts +++ b/src/build-project.ts @@ -13,8 +13,6 @@ interface BuildOptions { } export async function buildProject(options: BuildOptions): Promise { - const projectPath = options.projectPath || process.cwd() - let args: string[] = options.args || [] if (options.configPath) { @@ -25,7 +23,9 @@ export async function buildProject(options: BuildOptions): Promise { args.push('--target', options.target) } - process.chdir(projectPath) + if (options.projectPath) { + process.chdir(options.projectPath) + } if (options.runner) { await execa(options.runner, ['build', ...args], { stdio: 'inherit' }) diff --git a/tsconfig.json b/tsconfig.json index f6e7cb5..3354d4c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "outDir": "./lib", /* Redirect output structure to the directory. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "strict": true, /* Enable all strict type-checking options. */ "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "moduleResolution": "node" }, "exclude": ["node_modules", "**/*.test.ts"] }