Skip to content

Commit e02c941

Browse files
refactor(tauri): support for building without environmental variables (#850)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent bffbf7d commit e02c941

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1302
-947
lines changed

.changes/config-refactor.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"tauri-utils": minor
3+
"tauri-api": minor
4+
"tauri": minor
5+
---
6+
7+
The Tauri files are now read on the app space instead of the `tauri` create.
8+
Also, the `AppBuilder` `build` function now returns a Result.

.changes/config.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@
178178
"manager": "rust",
179179
"dependencies": ["tauri-utils"]
180180
},
181+
"tauri-macros": {
182+
"path": "./tauri-macros",
183+
"manager": "rust",
184+
"dependencies": ["tauri-utils"]
185+
},
181186
"tauri-updater": {
182187
"path": "./tauri-updater",
183188
"manager": "rust",
@@ -186,7 +191,7 @@
186191
"tauri": {
187192
"path": "./tauri",
188193
"manager": "rust",
189-
"dependencies": ["api", "tauri-api", "tauri-updater"]
194+
"dependencies": ["api", "tauri-api", "tauri-macros", "tauri-updater"]
190195
}
191196
}
192197
}

.changes/tauri-async.md

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@
33
---
44

55
Added `async` support to the Tauri Rust core on commit [#a169b67](https://github.com/tauri-apps/tauri/commit/a169b67ef0277b958bdac97e33c6e4c41b6844c3).
6-
This is a breaking change:
7-
- Change `.setup(|webview, source| {` to `.setup(|webview, _source| async move {`.
8-
- Change `.invoke_handler(|_webview, arg| {` to `.invoke_handler(|_webview, arg| async move {`.
9-
- Add `.await` after `tauri::execute_promise()` calls.

.changes/tauri-cli.md

-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33
---
44

55
The Tauri Node.js CLI package is now `@tauri-apps/cli`.
6-
To use the new CLI, delete the old `tauri` from your `package.json` and install the new package:
7-
`$ yarn remove tauri && yarn add --dev @tauri-apps/cli` or `$ npm uninstall tauri && npm install --save-dev @tauri-apps/cli`.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
members = [
33
"tauri",
44
"tauri-api",
5+
"tauri-macros",
56
"tauri-utils",
67
]
78
exclude = [

api/.eslintrc.js

+30-30
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,54 @@ module.exports = {
33

44
env: {
55
node: true,
6-
jest: true,
6+
jest: true
77
},
88

9-
parser: "@typescript-eslint/parser",
9+
parser: '@typescript-eslint/parser',
1010

1111
extends: [
12-
"standard-with-typescript",
13-
"plugin:@typescript-eslint/recommended-requiring-type-checking",
14-
"plugin:lodash-template/recommended",
12+
'standard-with-typescript',
13+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
14+
'plugin:lodash-template/recommended',
1515
// TODO: make this work with typescript
1616
// 'plugin:node/recommended'
17-
"prettier",
18-
"prettier/@typescript-eslint",
17+
'prettier',
18+
'prettier/@typescript-eslint'
1919
],
2020

21-
plugins: ["@typescript-eslint", "node", "security"],
21+
plugins: ['@typescript-eslint', 'node', 'security'],
2222

2323
parserOptions: {
2424
tsconfigRootDir: __dirname,
25-
project: "./tsconfig.json",
25+
project: './tsconfig.json'
2626
},
2727

2828
globals: {
2929
__statics: true,
30-
process: true,
30+
process: true
3131
},
3232

3333
// add your custom rules here
3434
rules: {
3535
// allow console.log during development only
36-
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
36+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
3737
// allow debugger during development only
38-
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
39-
"no-process-exit": "off",
40-
"security/detect-non-literal-fs-filename": "warn",
41-
"security/detect-unsafe-regex": "error",
42-
"security/detect-buffer-noassert": "error",
43-
"security/detect-child-process": "warn",
44-
"security/detect-disable-mustache-escape": "error",
45-
"security/detect-eval-with-expression": "error",
46-
"security/detect-no-csrf-before-method-override": "error",
47-
"security/detect-non-literal-regexp": "error",
48-
"security/detect-non-literal-require": "warn",
49-
"security/detect-object-injection": "warn",
50-
"security/detect-possible-timing-attacks": "error",
51-
"security/detect-pseudoRandomBytes": "error",
52-
"space-before-function-paren": "off",
53-
"@typescript-eslint/default-param-last": "off",
54-
"@typescript-eslint/strict-boolean-expressions": 0,
55-
},
56-
};
38+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
39+
'no-process-exit': 'off',
40+
'security/detect-non-literal-fs-filename': 'warn',
41+
'security/detect-unsafe-regex': 'error',
42+
'security/detect-buffer-noassert': 'error',
43+
'security/detect-child-process': 'warn',
44+
'security/detect-disable-mustache-escape': 'error',
45+
'security/detect-eval-with-expression': 'error',
46+
'security/detect-no-csrf-before-method-override': 'error',
47+
'security/detect-non-literal-regexp': 'error',
48+
'security/detect-non-literal-require': 'warn',
49+
'security/detect-object-injection': 'warn',
50+
'security/detect-possible-timing-attacks': 'error',
51+
'security/detect-pseudoRandomBytes': 'error',
52+
'space-before-function-paren': 'off',
53+
'@typescript-eslint/default-param-last': 'off',
54+
'@typescript-eslint/strict-boolean-expressions': 0
55+
}
56+
}

api/.prettierrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
singleQuote: true,
3+
semi: false,
4+
trailingComma: 'none'
5+
}

api/babel.config.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module.exports = {
22
presets: [
33
[
4-
"@babel/preset-env",
4+
'@babel/preset-env',
55
{
66
targets: {
7-
node: "current",
7+
node: 'current'
88
},
9-
modules: "commonjs",
10-
},
9+
modules: 'commonjs'
10+
}
1111
],
12-
"@babel/preset-typescript",
13-
],
14-
};
12+
'@babel/preset-typescript'
13+
]
14+
}

api/rollup.config.js

+57-57
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,107 @@
11
// rollup.config.js
2-
import { terser } from "rollup-plugin-terser";
3-
import resolve from "@rollup/plugin-node-resolve";
4-
import commonjs from "@rollup/plugin-commonjs";
5-
import sucrase from "@rollup/plugin-sucrase";
6-
import babel, { getBabelOutputPlugin } from "@rollup/plugin-babel";
7-
import typescript from "@rollup/plugin-typescript";
8-
import pkg from "./package.json";
2+
import { terser } from 'rollup-plugin-terser'
3+
import resolve from '@rollup/plugin-node-resolve'
4+
import commonjs from '@rollup/plugin-commonjs'
5+
import sucrase from '@rollup/plugin-sucrase'
6+
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel'
7+
import typescript from '@rollup/plugin-typescript'
8+
import pkg from './package.json'
99

1010
export default [
1111
{
1212
input: {
13-
fs: "./src/fs.ts",
14-
path: "./src/path.ts",
15-
dialog: "./src/dialog.ts",
16-
event: "./src/event.ts",
17-
http: "./src/http.ts",
18-
index: "./src/index.ts",
19-
process: "./src/process.ts",
20-
tauri: "./src/tauri.ts",
21-
window: "./src/window.ts",
22-
cli: "./src/cli.ts",
23-
notification: "./src/notification.ts",
13+
fs: './src/fs.ts',
14+
path: './src/path.ts',
15+
dialog: './src/dialog.ts',
16+
event: './src/event.ts',
17+
http: './src/http.ts',
18+
index: './src/index.ts',
19+
process: './src/process.ts',
20+
tauri: './src/tauri.ts',
21+
window: './src/window.ts',
22+
cli: './src/cli.ts',
23+
notification: './src/notification.ts'
2424
},
2525
treeshake: true,
2626
perf: true,
2727
output: [
2828
{
29-
dir: "dist/",
30-
entryFileNames: "[name].js",
31-
format: "cjs",
32-
exports: "named",
33-
globals: {},
29+
dir: 'dist/',
30+
entryFileNames: '[name].js',
31+
format: 'cjs',
32+
exports: 'named',
33+
globals: {}
3434
},
3535
{
36-
dir: "dist/",
37-
entryFileNames: "[name].mjs",
38-
format: "esm",
39-
exports: "named",
40-
globals: {},
41-
},
36+
dir: 'dist/',
37+
entryFileNames: '[name].mjs',
38+
format: 'esm',
39+
exports: 'named',
40+
globals: {}
41+
}
4242
],
4343
plugins: [
4444
commonjs({}),
4545
resolve({
4646
// pass custom options to the resolve plugin
4747
customResolveOptions: {
48-
moduleDirectory: "node_modules",
49-
},
48+
moduleDirectory: 'node_modules'
49+
}
5050
}),
5151
typescript({
52-
tsconfig: "./tsconfig.json",
52+
tsconfig: './tsconfig.json'
5353
}),
5454
babel({
5555
configFile: false,
56-
presets: [["@babel/preset-env"], ["@babel/preset-typescript"]],
56+
presets: [['@babel/preset-env'], ['@babel/preset-typescript']]
5757
}),
58-
terser(),
58+
terser()
5959
],
6060
external: [
6161
...Object.keys(pkg.dependencies || {}),
62-
...Object.keys(pkg.peerDependencies || {}),
62+
...Object.keys(pkg.peerDependencies || {})
6363
],
6464
watch: {
6565
chokidar: true,
66-
include: "src/**",
67-
exclude: "node_modules/**",
68-
},
66+
include: 'src/**',
67+
exclude: 'node_modules/**'
68+
}
6969
},
7070
{
7171
input: {
72-
bundle: "./src/bundle.ts",
72+
bundle: './src/bundle.ts'
7373
},
7474
output: [
7575
{
76-
name: "__TAURI__",
77-
dir: "dist/", // if it needs to run in the browser
78-
entryFileNames: "tauri.bundle.umd.js",
79-
format: "umd",
76+
name: '__TAURI__',
77+
dir: 'dist/', // if it needs to run in the browser
78+
entryFileNames: 'tauri.bundle.umd.js',
79+
format: 'umd',
8080
plugins: [
8181
getBabelOutputPlugin({
82-
presets: [["@babel/preset-env", { modules: "umd" }]],
83-
allowAllFormats: true,
82+
presets: [['@babel/preset-env', { modules: 'umd' }]],
83+
allowAllFormats: true
8484
}),
85-
terser(),
85+
terser()
8686
],
87-
globals: {},
88-
},
87+
globals: {}
88+
}
8989
],
9090
plugins: [
9191
sucrase({
92-
exclude: ["node_modules"],
93-
transforms: ["typescript"],
92+
exclude: ['node_modules'],
93+
transforms: ['typescript']
9494
}),
9595
resolve({
9696
// pass custom options to the resolve plugin
9797
customResolveOptions: {
98-
moduleDirectory: "node_modules",
99-
},
100-
}),
98+
moduleDirectory: 'node_modules'
99+
}
100+
})
101101
],
102102
external: [
103103
...Object.keys(pkg.dependencies || {}),
104-
...Object.keys(pkg.peerDependencies || {}),
105-
],
106-
},
107-
];
104+
...Object.keys(pkg.peerDependencies || {})
105+
]
106+
}
107+
]

api/src/bundle.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import "regenerator-runtime/runtime";
2-
import * as cli from "./cli";
3-
import * as dialog from "./dialog";
4-
import * as event from "./event";
5-
import * as fs from "./fs";
6-
import * as path from "./path";
7-
import http from "./http";
8-
import * as process from "./process";
9-
import * as tauri from "./tauri";
10-
import * as window from "./window";
11-
import * as notification from "./notification";
1+
import 'regenerator-runtime/runtime'
2+
import * as cli from './cli'
3+
import * as dialog from './dialog'
4+
import * as event from './event'
5+
import * as fs from './fs'
6+
import * as path from './path'
7+
import http from './http'
8+
import * as process from './process'
9+
import * as tauri from './tauri'
10+
import * as window from './window'
11+
import * as notification from './notification'
1212

1313
export {
1414
cli,
@@ -20,5 +20,5 @@ export {
2020
process,
2121
tauri,
2222
window,
23-
notification,
24-
};
23+
notification
24+
}

0 commit comments

Comments
 (0)