Skip to content

Commit a022768

Browse files
committed
fix: computed ref #70
1 parent f0fc5c5 commit a022768

File tree

13 files changed

+786
-710
lines changed

13 files changed

+786
-710
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
types
33
demo
44
dist
5-
swc_build
5+
swc_build
6+
gulpfile.ts

.eslintrc.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,31 @@ module.exports = {
1414
},
1515
plugins: [
1616
'@typescript-eslint',
17-
'prettier'
1817
],
1918
extends: [
2019
'eslint:recommended',
21-
'plugin:@typescript-eslint/eslint-recommended',
2220
'plugin:@typescript-eslint/recommended',
23-
'prettier/@typescript-eslint'
2421
],
2522
globals: {
2623
wx: true,
2724
App: true,
2825
Page: true,
29-
Component: true
26+
Component: true,
27+
Behavior: true,
3028
},
3129
rules: {
32-
'prettier/prettier': 'error',
30+
'no-console': 0,
3331
'@typescript-eslint/ban-ts-ignore': 'off',
3432
'@typescript-eslint/no-empty-function': 'off',
3533
'@typescript-eslint/explicit-function-return-type': 'off',
3634
'@typescript-eslint/no-explicit-any': 'off',
37-
'@typescript-eslint/no-non-null-assertion': 'off'
35+
'@typescript-eslint/no-non-null-assertion': 'off',
36+
"indent": ["error", 2, { "SwitchCase": 1 }],
37+
"comma-spacing": "error",
38+
"semi": ["error", "never"],
39+
"quotes": ["error", "single"],
40+
"object-curly-spacing": ["error", "always"],
41+
"@typescript-eslint/ban-ts-comment": "off",
3842
},
39-
}
43+
}
44+

demo/computed/behavior.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.ts

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import gulp from 'gulp'
2-
import clean from 'gulp-clean'
3-
import tsc from 'gulp-typescript'
4-
import path from 'path'
5-
import swc from 'gulp-swc'
6-
import esbuild from 'gulp-esbuild'
7-
import watch from 'gulp-watch'
1+
import gulp from "gulp";
2+
import clean from "gulp-clean";
3+
import tsc from "gulp-typescript";
4+
import path from "path";
5+
import swc from "gulp-swc";
6+
import esbuild from "gulp-esbuild";
7+
import watch from "gulp-watch";
88

9-
import config from './config'
9+
import config from "./config";
1010

1111
const {
1212
srcPath,
@@ -17,75 +17,79 @@ const {
1717
typesPath,
1818
tsConfigPath,
1919
swcBuildPath,
20-
entry
20+
entry,
2121
} = config;
2222

23+
const genTsc = () => {
24+
return tsc.createProject(tsConfigPath);
25+
};
2326

24-
const gen_tsc = () => {
25-
return tsc.createProject(tsConfigPath)
26-
}
27+
gulp.task("clean-dev-bundle", () => {
28+
return gulp.src(bundleInDemoPath, { allowEmpty: true }).pipe(clean());
29+
});
2730

31+
gulp.task("clean-demo-dev-bundle", () => {
32+
return gulp.src(bundleInDemoPath, { allowEmpty: true }).pipe(clean());
33+
});
2834

29-
gulp.task('clean-dev-bundle', () => {
30-
return gulp.src(bundleInDemoPath, { allowEmpty: true })
31-
.pipe(clean())
32-
})
35+
gulp.task("clean-bundle", () => {
36+
return gulp.src(bundlePath, { allowEmpty: true }).pipe(clean());
37+
});
3338

34-
gulp.task('clean-demo-dev-bundle', () => {
35-
return gulp.src(bundleInDemoPath, { allowEmpty: true })
36-
.pipe(clean())
37-
})
39+
gulp.task("clean-dts", () => {
40+
return gulp.src(typesPath, { allowEmpty: true }).pipe(clean());
41+
});
3842

39-
gulp.task('clean-bundle', () => {
40-
return gulp.src(bundlePath, { allowEmpty: true })
41-
.pipe(clean())
42-
})
43+
gulp.task("gen-dts", () => {
44+
const tsc = genTsc();
45+
return tsc.src().pipe(tsc()).pipe(gulp.dest(typesPath));
46+
});
4347

44-
gulp.task('clean-dts', () => {
45-
return gulp.src(typesPath, { allowEmpty: true })
46-
.pipe(clean())
47-
})
48-
49-
gulp.task('gen-dts', () => {
50-
const tsc = gen_tsc();
51-
return tsc.src().pipe(tsc())
52-
.pipe(gulp.dest(typesPath))
53-
})
54-
55-
gulp.task('swc-ts-2-js', () => {
48+
gulp.task("swc-ts-2-js", () => {
5649
return gulp
5750
.src(path.resolve(srcPath, "*.ts"))
5851
.pipe(swc(swcOptions))
5952
.pipe(gulp.dest(swcBuildPath));
60-
})
53+
});
6154

62-
gulp.task('esbuild-bundle', () => {
55+
gulp.task("esbuild-bundle", () => {
6356
return gulp
6457
.src(path.resolve(swcBuildPath, `${entry}.js`))
6558
.pipe(esbuild(esbuildOptions))
6659
.pipe(gulp.dest(bundlePath));
67-
})
68-
69-
gulp.task('copy-2-demo', () => {
70-
return gulp.src(path.resolve(swcBuildPath, "*.js"))
71-
.pipe(gulp.dest(bundleInDemoPath))
72-
})
60+
});
7361

74-
gulp.task('watch', () => {
75-
const ts_file = path.resolve(srcPath, "*.ts");
76-
const watcher = watch(ts_file, gulp.series('dev'))
77-
watcher.on('change', function (path, stats) {
62+
gulp.task("copy-2-demo", () => {
63+
return gulp
64+
.src(path.resolve(swcBuildPath, "*.js"))
65+
.pipe(gulp.dest(bundleInDemoPath));
66+
});
67+
68+
gulp.task("watch", () => {
69+
const tsFile = path.resolve(srcPath, "*.ts");
70+
const watcher = watch(tsFile, gulp.series("dev"));
71+
watcher.on("change", function (path, stats) {
7872
console.log(`File ${path} was changed`);
7973
});
80-
})
74+
});
8175

8276
// build for develop
83-
gulp.task('dev', gulp.series('clean-dev-bundle', 'clean-demo-dev-bundle', 'swc-ts-2-js', 'copy-2-demo'))
77+
gulp.task(
78+
"dev",
79+
gulp.series(
80+
"clean-dev-bundle",
81+
"clean-demo-dev-bundle",
82+
"swc-ts-2-js",
83+
"copy-2-demo"
84+
)
85+
);
8486

8587
// build for develop & watch
86-
gulp.task('dev-watch', gulp.series('dev', 'watch'))
87-
// generate .d.ts
88-
gulp.task('dts', gulp.series('clean-dts', 'gen-dts'))
88+
gulp.task("dev-watch", gulp.series("dev", "watch"));
89+
// generate .d.ts
90+
gulp.task("dts", gulp.series("clean-dts", "gen-dts"));
8991
// build for publish
90-
gulp.task('default', gulp.series('clean-bundle', 'swc-ts-2-js', 'esbuild-bundle', 'dts'))
91-
92+
gulp.task(
93+
"default",
94+
gulp.series("clean-bundle", "swc-ts-2-js", "esbuild-bundle", "dts")
95+
);

jest.config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
2-
preset: "ts-jest",
2+
preset: 'ts-jest',
33
bail: 1,
44
verbose: true,
5-
testEnvironment: "jsdom",
6-
testURL: "https://jest.test",
7-
moduleFileExtensions: ["js", "ts"],
8-
testMatch: ["<rootDir>/test/**/*.spec.ts"],
9-
collectCoverageFrom: ["<rootDir>/src/**/*.ts", "!**/__test__/**"],
10-
snapshotSerializers: ["miniprogram-simulate/jest-snapshot-plugin"],
11-
};
5+
testEnvironment: 'jsdom',
6+
testURL: 'https://jest.test',
7+
moduleFileExtensions: ['js', 'ts'],
8+
testMatch: ['<rootDir>/test/**/*.spec.ts'],
9+
collectCoverageFrom: ['<rootDir>/src/**/*.ts', '!**/__test__/**'],
10+
snapshotSerializers: ['miniprogram-simulate/jest-snapshot-plugin'],
11+
}

0 commit comments

Comments
 (0)