Skip to content

Commit 729d907

Browse files
committed
fix: #3 修复 windows/mac 的 ENOENT 错误
1 parent 1f16241 commit 729d907

File tree

8 files changed

+403
-514
lines changed

8 files changed

+403
-514
lines changed

README.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,17 @@ definePage({
153153

154154
函数
155155
```ts
156+
import type { HelloWorld } from './utils';
157+
156158
definePage(() => {
157-
const hello = 'hello';
158-
const world = 'world';
159+
const words: HelloWorld = {
160+
hello: 'hello',
161+
world: 'world',
162+
};
159163

160164
return {
161165
style: {
162-
navigationBarTitleText: [hello, world].join(' '),
166+
navigationBarTitleText: [words.hello, words.world].join(' '),
163167
},
164168
middlewares: [
165169
'auth',
@@ -189,16 +193,16 @@ definePage(() => {
189193
});
190194
```
191195

192-
引入外部函数、变量
196+
引入外部函数、变量 (***注意:仅支持引入纯 JavaScript 或仅 TypeScript 的类型声明。***)
193197
```ts
194-
import { randamText } from './utils';
198+
import { parse as yamlParser } from 'yaml';
195199

196200
definePage(() => {
197-
return {
198-
style: {
199-
navigationBarTitleText: randamText(),
200-
},
201-
};
201+
const yml = `
202+
style:
203+
navigationBarTitleText: "yaml test"
204+
`;
205+
return yamlParser(yml);
202206
});
203207
```
204208

build.config.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import process from 'node:process';
12
import { defineBuildConfig } from 'unbuild';
23

4+
const isDev = process.env.NODE_ENV === 'development';
5+
36
export default defineBuildConfig({
47
entries: ['src/index'],
58
declaration: true,
@@ -8,9 +11,10 @@ export default defineBuildConfig({
811
emitCJS: true,
912
inlineDependencies: true,
1013
esbuild: {
11-
minify: true,
14+
minify: !isDev,
1215
},
1316
},
1417
externals: ['vite'],
1518
failOnWarn: false,
19+
sourcemap: isDev,
1620
});

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"clean": "rimraf dist",
4747
"build": "unbuild",
4848
"stub": "unbuild --stub",
49-
"debug": "unbuild --sourcemap && cd playground && pnpm dev:h5",
49+
"debug": "cross-env NODE_ENV=development unbuild && cd playground && pnpm dev:h5",
5050
"watch": "tsup --watch",
5151
"typecheck": "tsc -p . --noEmit",
5252
"lint": "eslint .",
@@ -63,7 +63,7 @@
6363
"debug": "^4.3.4",
6464
"fast-glob": "^3.3.2",
6565
"magic-string": "^0.30.8",
66-
"tsx": "^4.7.1",
66+
"typescript": "^5.4.5",
6767
"unconfig": "^0.3.11"
6868
},
6969
"devDependencies": {
@@ -82,13 +82,13 @@
8282
"@vue-macros/common": "^1.10.1",
8383
"ast-walker-scope": "^0.6.1",
8484
"bumpp": "^9.4.0",
85+
"cross-env": "^7.0.3",
8586
"debug": "^4.3.4",
8687
"eslint": "^9.17.0",
8788
"husky": "^9.0.11",
8889
"lint-staged": "^15.2.2",
8990
"magic-string": "^0.30.8",
9091
"rimraf": "^5.0.5",
91-
"typescript": "^5.4.2",
9292
"unbuild": "^3.3.1",
9393
"unconfig": "^0.3.11",
9494
"unplugin": "^1.10.0",

playground/src/pages/define-page/function.vue

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<script lang="ts" setup>
2-
definePage(() => {
3-
const hello = 'hello';
2+
import type { HelloWorld } from './utils';
43
5-
const world = 'world';
4+
definePage(() => {
5+
const words: HelloWorld = {
6+
hello: 'hello',
7+
world: 'world',
8+
};
69
710
return {
811
style: {
9-
navigationBarTitleText: [hello, world].join(' '),
12+
navigationBarTitleText: [words.hello, words.world].join(' '),
1013
},
1114
middlewares: [
1215
'auth',

playground/src/pages/define-page/import.vue

-16
This file was deleted.
+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
export function randamText() {
2-
return Math.random().toString(36).slice(-8);
1+
export interface HelloWorld {
2+
hello: string;
3+
world: string;
34
}

0 commit comments

Comments
 (0)