@tarojs/cli 4.0.0-canary.8 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/LICENSE +17 -3
  2. package/dist/cli.js +34 -24
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/customCommand.js.map +1 -1
  5. package/dist/create/creator.js +1 -1
  6. package/dist/create/creator.js.map +1 -1
  7. package/dist/create/fetchTemplate.d.ts +1 -0
  8. package/dist/create/fetchTemplate.js +33 -27
  9. package/dist/create/fetchTemplate.js.map +1 -1
  10. package/dist/create/page.d.ts +7 -0
  11. package/dist/create/page.js +15 -10
  12. package/dist/create/page.js.map +1 -1
  13. package/dist/create/plugin.js +1 -1
  14. package/dist/create/plugin.js.map +1 -1
  15. package/dist/create/project.js +33 -31
  16. package/dist/create/project.js.map +1 -1
  17. package/dist/presets/commands/build.js +53 -35
  18. package/dist/presets/commands/build.js.map +1 -1
  19. package/dist/presets/commands/config.js +1 -1
  20. package/dist/presets/commands/config.js.map +1 -1
  21. package/dist/presets/commands/create.js +6 -0
  22. package/dist/presets/commands/create.js.map +1 -1
  23. package/dist/presets/commands/global-config.js +9 -3
  24. package/dist/presets/commands/global-config.js.map +1 -1
  25. package/dist/presets/commands/help.js +2 -2
  26. package/dist/presets/commands/help.js.map +1 -1
  27. package/dist/presets/commands/info.js +3 -3
  28. package/dist/presets/commands/info.js.map +1 -1
  29. package/dist/presets/commands/init.js +2 -1
  30. package/dist/presets/commands/init.js.map +1 -1
  31. package/dist/presets/commands/inspect.js +6 -6
  32. package/dist/presets/commands/inspect.js.map +1 -1
  33. package/dist/presets/commands/update.js +3 -3
  34. package/dist/presets/commands/update.js.map +1 -1
  35. package/dist/presets/constant/hooks.d.ts +1 -0
  36. package/dist/presets/constant/hooks.js +2 -1
  37. package/dist/presets/constant/hooks.js.map +1 -1
  38. package/dist/presets/files/generateFrameworkInfo.js.map +1 -1
  39. package/dist/presets/files/generateProjectConfig.js +1 -1
  40. package/dist/presets/files/generateProjectConfig.js.map +1 -1
  41. package/dist/presets/files/writeFileToDist.js +1 -1
  42. package/dist/presets/files/writeFileToDist.js.map +1 -1
  43. package/dist/presets/hooks/build.js +1 -0
  44. package/dist/presets/hooks/build.js.map +1 -1
  45. package/dist/presets/index.js +1 -1
  46. package/dist/presets/index.js.map +1 -1
  47. package/dist/presets/platforms/plugin.js +14 -4
  48. package/dist/presets/platforms/plugin.js.map +1 -1
  49. package/dist/presets/platforms/rn.js +8 -9
  50. package/dist/presets/platforms/rn.js.map +1 -1
  51. package/dist/util/createPage.js +1 -1
  52. package/dist/util/createPage.js.map +1 -1
  53. package/dist/util/defineConfig.d.ts +1 -1
  54. package/dist/util/index.d.ts +1 -0
  55. package/dist/util/index.js +7 -3
  56. package/dist/util/index.js.map +1 -1
  57. package/package.json +28 -35
  58. package/src/__tests__/__mocks__/presets.ts +1 -1
  59. package/src/__tests__/build-config.spec.ts +2 -1
  60. package/src/__tests__/cli.spec.ts +12 -1
  61. package/src/__tests__/config.spec.ts +2 -1
  62. package/src/__tests__/doctor-config.spec.ts +2 -2
  63. package/src/__tests__/doctor-eslint.spec.ts +2 -28
  64. package/src/__tests__/doctor-recommand.spec.ts +2 -1
  65. package/src/__tests__/dotenv-parse.spec.ts +2 -2
  66. package/src/__tests__/fixtures/default/config/index.js +6 -0
  67. package/src/__tests__/info.spec.ts +2 -2
  68. package/src/__tests__/inspect.spec.ts +8 -3
  69. package/src/__tests__/update.spec.ts +3 -4
  70. package/src/__tests__/utils/index.ts +2 -1
  71. package/src/cli.ts +27 -17
  72. package/src/create/creator.ts +2 -1
  73. package/src/create/fetchTemplate.ts +39 -31
  74. package/src/create/page.ts +31 -16
  75. package/src/create/plugin.ts +2 -1
  76. package/src/create/project.ts +40 -40
  77. package/src/index.ts +2 -1
  78. package/src/presets/commands/build.ts +49 -33
  79. package/src/presets/commands/config.ts +1 -1
  80. package/src/presets/commands/create.ts +6 -0
  81. package/src/presets/commands/global-config.ts +17 -14
  82. package/src/presets/commands/info.ts +2 -1
  83. package/src/presets/commands/init.ts +2 -1
  84. package/src/presets/commands/inspect.ts +3 -2
  85. package/src/presets/commands/update.ts +3 -2
  86. package/src/presets/constant/hooks.ts +1 -0
  87. package/src/presets/files/generateProjectConfig.ts +1 -1
  88. package/src/presets/files/writeFileToDist.ts +1 -1
  89. package/src/presets/hooks/build.ts +1 -0
  90. package/src/presets/index.ts +1 -1
  91. package/src/presets/platforms/plugin.ts +13 -2
  92. package/src/presets/platforms/rn.ts +17 -6
  93. package/src/util/createPage.ts +1 -2
  94. package/src/util/defineConfig.ts +1 -1
  95. package/src/util/index.ts +6 -1
  96. package/templates/default/{_env.dev → _env.development} +1 -1
  97. package/templates/default/_env.production +1 -0
  98. package/templates/default/_env.test +1 -1
  99. package/templates/default/_eslintrc +1 -1
  100. package/templates/default/package.json.tmpl +66 -73
  101. package/templates/default/src/app.js +14 -12
  102. package/templates/default/src/pages/index/index.jsx +1 -2
  103. package/templates/default/src/pages/index/index.vue +0 -7
  104. package/templates/default/template_creator.js +22 -17
  105. package/templates/default/tsconfig.json +3 -3
  106. package/templates/default/types/global.d.ts +2 -2
  107. package/templates/plugin-compile/README.md +1 -1
  108. package/templates/plugin-compile/package.json.tmpl +3 -4
  109. package/templates/plugin-compile/src/index.ts +1 -1
  110. package/templates/plugin-compile/tsconfig.json +0 -1
  111. package/dist/config/babylon.d.ts +0 -3
  112. package/dist/config/babylon.js +0 -16
  113. package/dist/config/babylon.js.map +0 -1
  114. package/src/__tests__/fixtures/nerv/babel.config.js +0 -10
  115. package/src/__tests__/fixtures/nerv/config/dev.js +0 -9
  116. package/src/__tests__/fixtures/nerv/config/index.js +0 -70
  117. package/src/__tests__/fixtures/nerv/config/prod.js +0 -18
  118. package/src/__tests__/fixtures/nerv/package.json +0 -59
  119. package/src/__tests__/fixtures/nerv/src/app.config.ts +0 -11
  120. package/src/__tests__/fixtures/nerv/src/app.tsx +0 -10
  121. package/src/__tests__/fixtures/nerv/src/index.html +0 -19
  122. package/src/__tests__/fixtures/nerv/src/pages/index/index.config.ts +0 -3
  123. package/src/__tests__/fixtures/nerv/src/pages/index/index.tsx +0 -25
  124. package/src/__tests__/fixtures/vue/babel.config.js +0 -10
  125. package/src/__tests__/fixtures/vue/config/dev.js +0 -9
  126. package/src/__tests__/fixtures/vue/config/index.js +0 -70
  127. package/src/__tests__/fixtures/vue/config/prod.js +0 -18
  128. package/src/__tests__/fixtures/vue/package.json +0 -54
  129. package/src/__tests__/fixtures/vue/src/app.config.js +0 -11
  130. package/src/__tests__/fixtures/vue/src/app.js +0 -12
  131. package/src/__tests__/fixtures/vue/src/index.html +0 -19
  132. package/src/__tests__/fixtures/vue/src/pages/index/index.config.js +0 -3
  133. package/src/__tests__/fixtures/vue/src/pages/index/index.vue +0 -15
  134. package/src/config/babylon.ts +0 -16
  135. package/templates/default/__tests__/index.test.js.tmpl +0 -12
  136. package/templates/default/_env.prod +0 -1
  137. package/templates/default/jest.config.js +0 -6
  138. package/templates/default/project.tt.json +0 -9
@@ -1,4 +1,4 @@
1
- {{#if (includes "Vue" "Vue3" s=framework)}}
1
+ {{#if (includes "Vue3" s=framework)}}
2
2
  // ESLint 检查 .vue 文件需要单独配置编辑器:
3
3
  // https://eslint.vuejs.org/user-guide/#editor-integrations
4
4
  {{/if}}
@@ -18,7 +18,7 @@
18
18
  "build:rn": "taro build --type rn",
19
19
  "build:qq": "taro build --type qq",
20
20
  "build:jd": "taro build --type jd",
21
- "build:quickapp": "taro build --type quickapp",
21
+ "build:harmony-hybrid": "taro build --type harmony-hybrid",
22
22
  "dev:weapp": "npm run build:weapp -- --watch",
23
23
  "dev:swan": "npm run build:swan -- --watch",
24
24
  "dev:alipay": "npm run build:alipay -- --watch",
@@ -27,17 +27,24 @@
27
27
  "dev:rn": "npm run build:rn -- --watch",
28
28
  "dev:qq": "npm run build:qq -- --watch",
29
29
  "dev:jd": "npm run build:jd -- --watch",
30
- "dev:quickapp": "npm run build:quickapp -- --watch",
31
- "test": "jest"
30
+ "dev:harmony-hybrid": "npm run build:harmony-hybrid -- --watch"
32
31
  },
32
+ {{#if (includes "Webpack5" s=compiler)}}
33
+ "browserslist": [
34
+ "defaults and fully supports es6-module",
35
+ "maintained node versions"
36
+ ],
37
+ {{/if}}
38
+ {{#if (includes "Vite" s=compiler)}}
33
39
  "browserslist": [
34
40
  "last 3 versions",
35
41
  "Android >= 4.1",
36
42
  "ios >= 8"
37
43
  ],
44
+ {{/if}}
38
45
  "author": "",
39
46
  "dependencies": {
40
- "@babel/runtime": "^7.21.5",
47
+ "@babel/runtime": "^7.24.4",
41
48
  "@tarojs/components": "{{ version }}",
42
49
  "@tarojs/helper": "{{ version }}",
43
50
  "@tarojs/plugin-platform-weapp": "{{ version }}",
@@ -47,6 +54,7 @@
47
54
  "@tarojs/plugin-platform-jd": "{{ version }}",
48
55
  "@tarojs/plugin-platform-qq": "{{ version }}",
49
56
  "@tarojs/plugin-platform-h5": "{{ version }}",
57
+ "@tarojs/plugin-platform-harmony-hybrid": "{{ version }}",
50
58
  "@tarojs/runtime": "{{ version }}",
51
59
  "@tarojs/shared": "{{ version }}",
52
60
  "@tarojs/taro": "{{ version }}",{{#if (includes "React" "Preact" s=framework)}}
@@ -54,92 +62,77 @@
54
62
  "@tarojs/react": "{{ version }}",
55
63
  "react-dom": "^18.0.0",
56
64
  "react": "^18.0.0"{{/if}}{{#if (eq framework "Preact") }}
57
- "preact": "^10.5.15"{{/if}}{{#if (eq framework "Vue") }}
58
- "@tarojs/plugin-framework-vue2": "{{ version }}",
59
- "vue-template-compiler": "^2.5.0",
60
- "vue": "^2.5.0"{{/if}}{{#if (eq framework "Vue3") }}
65
+ "preact": "^10.5.15"{{/if}}{{#if (eq framework "Vue3") }}
61
66
  "@tarojs/plugin-framework-vue3": "{{ version }}",
62
- "vue": "^3.0.0"{{/if}}
63
- },{{#if (includes "Webpack4" "Webpack5" s=compiler)}}
67
+ "vue": "^3.0.0"{{/if}}{{#if (eq framework "Solid") }}
68
+ "@tarojs/plugin-framework-solid": "{{ version }}",
69
+ "solid-js": "^1.8.16"{{/if}}
70
+ },{{#if (includes "Webpack5" s=compiler)}}
64
71
  "devDependencies": {
65
- "@babel/core": "^7.8.0",
72
+ "@babel/core": "^7.24.4",
66
73
  "@tarojs/cli": "{{ version }}",
74
+ "@babel/plugin-proposal-class-properties": "7.14.5",
67
75
  "@types/webpack-env": "^1.13.6",{{#if (includes "React" "Preact" s=framework)}}
68
- "@tarojs/test-utils-react": "^0.1.1",
69
- "@types/react": "^18.0.0",{{/if}}{{#if (eq compiler "Webpack4") }}
70
- "@tarojs/mini-runner": "{{ version }}",
71
- "@tarojs/webpack-runner": "{{ version }}",
72
- "webpack": "4.46.0",{{/if}}{{#if (eq compiler "Webpack5") }}
73
- "webpack": "5.78.0",
76
+ "@types/react": "^18.0.0",{{/if}}{{#if (eq compiler "Webpack5") }}
77
+ "webpack": "5.91.0",
74
78
  "@tarojs/taro-loader": "{{ version }}",
75
- "@tarojs/webpack5-runner": "{{ version }}",{{/if}}
76
- "babel-preset-taro": "{{ version }}",{{#if (includes "Vue" "Vue3" s=framework)}}
77
- "css-loader": "3.4.2",
78
- "style-loader": "1.3.0",{{/if}}{{#if (eq framework "Vue") }}
79
- "@tarojs/test-utils-vue": "^0.1.1",
80
- "@vue/babel-preset-jsx": "^1.2.4",
81
- "vue-loader": "^15.9.2",
82
- "eslint-plugin-vue": "^8.x",{{/if}}{{#if (eq framework "Vue3") }}
79
+ "@tarojs/webpack5-runner": "{{ version }}",{{/if}}{{#if (eq css "Sass") }}
80
+ "sass": "^1.75.0",{{/if}}{{#if (eq css "Less") }}
81
+ "less": "^4.2.0",{{/if}}{{#if (eq css "Stylus") }}
82
+ "stylus": "^0.63.0",{{/if}}
83
+ "babel-preset-taro": "{{ version }}",{{#if (eq framework "Vue3") }}
84
+ "css-loader": "^7.1.1",
85
+ "style-loader": "^3.3.4",
83
86
  "@tarojs/test-utils-vue3": "^0.1.1",
84
- "@vue/babel-plugin-jsx": "^1.0.6",
87
+ "@vue/babel-plugin-jsx": "^1.2.2",
85
88
  "@vue/compiler-sfc": "^3.0.0",
86
- "vue-loader": "^17.0.0",
87
- "eslint-plugin-vue": "^8.0.0",{{/if}}
89
+ "vue-loader": "^17.4.2",
90
+ "eslint-plugin-vue": "^9.17.0",{{/if}}
88
91
  "eslint-config-taro": "{{ version }}",
89
- "eslint": "^8.12.0",{{#if (eq framework "React") }}
92
+ "eslint": "^8.57.0",{{#if (eq framework "React") }}
90
93
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
91
- "react-refresh": "^0.11.0",{{/if}}{{#if (eq framework "Preact") }}
92
- "@prefresh/webpack": "^3.2.3",
93
- "@prefresh/core": "^1.3.4",
94
- "@prefresh/babel-plugin": "^0.4.1",{{/if}}{{#if (includes "React" "Preact" s=framework)}}
95
- "eslint-plugin-react": "^7.8.2",
96
- "eslint-plugin-import": "^2.12.0",
97
- "eslint-plugin-react-hooks": "^4.2.0",{{/if}}
98
- "stylelint": "^14.4.0"{{#if typescript }},
99
- "@typescript-eslint/parser": "^6.2.0",
100
- "@typescript-eslint/eslint-plugin": "^6.2.0",
101
- "typescript": "^5.1.0",
102
- "tsconfig-paths-webpack-plugin": "^4.0.1"{{/if}},
103
- "postcss": "^8.4.18",
104
- "ts-node": "^10.9.1",
105
- "@types/node": "^18.15.11",
106
- "@types/jest": "^29.3.1",
107
- "jest": "^29.3.1",
108
- "jest-environment-jsdom": "^29.5.0"
94
+ "react-refresh": "^0.14.0",{{/if}}{{#if (eq framework "Preact") }}
95
+ "@prefresh/webpack": "^4",
96
+ "@prefresh/core": "^1.5.2",
97
+ "@prefresh/babel-plugin": "^0.5.1",{{/if}}{{#if (includes "React" "Preact" s=framework)}}
98
+ "@babel/preset-react": "^7.24.1",
99
+ "eslint-plugin-react": "^7.34.1",
100
+ "eslint-plugin-react-hooks": "^4.4.0",{{/if}}
101
+ "stylelint": "^16.4.0"{{#if typescript }},
102
+ "typescript": "^5.4.5",
103
+ "tsconfig-paths-webpack-plugin": "^4.1.0"{{/if}},
104
+ "postcss": "^8.4.38",
105
+ "@types/node": "^18"
109
106
  }{{/if}}{{#if (eq compiler "Vite") }}
110
107
  "devDependencies": {
111
- "@babel/core": "^7.8.0",
108
+ "@babel/core": "^7.24.4",
109
+ "@babel/plugin-proposal-class-properties": "7.14.5",
112
110
  "@tarojs/cli": "{{ version }}",
113
111
  "@tarojs/vite-runner": "{{ version }}",
114
112
  "babel-preset-taro": "{{ version }}",
115
113
  "eslint-config-taro": "{{ version }}",
116
- "eslint": "^8.12.0",
117
- "stylelint": "^14.4.0",
118
- "terser": "^5.16.8",
114
+ "eslint": "^8.57.0",
115
+ "stylelint": "^16.4.0",
116
+ "terser": "^5.30.4",
119
117
  "vite": "^4.2.0",{{#if (includes "React" "Preact" s=framework)}}
120
- "@tarojs/test-utils-react": "^0.1.1",
118
+ "@babel/preset-react": "^7.24.1",
121
119
  "@types/react": "^18.0.0",
122
- "@vitejs/plugin-react": "^4.1.0",
123
- "eslint-plugin-react": "^7.8.2",
124
- "eslint-plugin-import": "^2.12.0",
125
- "eslint-plugin-react-hooks": "^4.2.0",{{/if}}{{#if (eq framework "Preact") }}
126
- "@preact/preset-vite": "^2.5.0",
127
- "@prefresh/core": "^1.3.4",
128
- "@prefresh/babel-plugin": "^0.4.1",{{/if}}{{#if (eq framework "React") }}
129
- "react-refresh": "^0.11.0",{{/if}}{{#if (eq framework "Vue") }}
130
- "@vitejs/plugin-vue2": "^2.2.0",
131
- "eslint-plugin-vue": "^8.x",{{/if}}{{#if (eq framework "Vue3") }}
132
- "@vitejs/plugin-vue": "^4.0.0",
133
- "@vitejs/plugin-vue-jsx": "^3.0.0",
134
- "eslint-plugin-vue": "^8.0.0",{{/if}}{{#if (eq css "Sass") }}
135
- "sass": "^1.60.0",{{/if}}{{#if (eq css "Less") }}
136
- "less": "^4.1.3",{{/if}}{{#if (eq css "Stylus") }}
137
- "stylus": "^0.59.0",{{/if}}{{#if typescript }}
138
- "@typescript-eslint/parser": "^5.20.0",
139
- "@typescript-eslint/eslint-plugin": "^5.20.0",
140
- "typescript": "^4.1.0",{{/if}}
141
- "postcss": "^8.4.18",
142
- "jest-environment-jsdom": "^29.5.0"
120
+ "@vitejs/plugin-react": "^4.3.0",
121
+ "eslint-plugin-react": "^7.34.1",
122
+ "eslint-plugin-react-hooks": "^4.4.0",{{/if}}{{#if (eq framework "Preact") }}
123
+ "@preact/preset-vite": "^2.8.2",
124
+ "@prefresh/core": "^1.5.2",
125
+ "@prefresh/babel-plugin": "^0.5.1",{{/if}}{{#if (eq framework "React") }}
126
+ "react-refresh": "^0.14.0",{{/if}}{{#if (eq framework "Vue3") }}
127
+ "@vitejs/plugin-vue": "^5.0.4",
128
+ "@vitejs/plugin-vue-jsx": "^3.1.0",
129
+ "eslint-plugin-vue": "^9.17.0",{{/if}}{{#if (eq framework "Solid") }}
130
+ "vite-plugin-solid": "2.10.0",{{/if}}{{#if (eq css "Sass") }}
131
+ "sass": "^1.75.0",{{/if}}{{#if (eq css "Less") }}
132
+ "less": "^4.2.0",{{/if}}{{#if (eq css "Stylus") }}
133
+ "stylus": "^0.63.0",{{/if}}{{#if typescript }}
134
+ "typescript": "^5.4.5",{{/if}}
135
+ "postcss": "^8.4.38"
143
136
  }{{/if}}
144
137
  }
145
138
 
@@ -1,16 +1,17 @@
1
1
  {{#if (includes "React" "Preact" s=framework)}}
2
2
  {{#if typescript }}import { PropsWithChildren } from 'react'{{/if}}
3
3
  import { useLaunch } from '@tarojs/taro'
4
- {{/if}}{{#if (eq framework 'Vue') }}
5
- import Vue from 'vue'
6
4
  {{/if}}{{#if (eq framework 'Vue3') }}
7
5
  import { createApp } from 'vue'
6
+ {{/if}}{{#if (eq framework 'Solid') }}
7
+ {{#if typescript }}import { ParentProps } from 'solid-js'{{/if}}
8
+ import { useLaunch } from '@tarojs/taro'
8
9
  {{/if}}
10
+
9
11
  import './app.{{ cssExt }}'
10
12
 
11
13
  {{#if (includes "React" "Preact" s=framework)}}
12
14
  function App({ children }{{#if typescript }}: PropsWithChildren<any>{{/if}}) {
13
-
14
15
  useLaunch(() => {
15
16
  console.log('App launched.')
16
17
  })
@@ -19,17 +20,18 @@ function App({ children }{{#if typescript }}: PropsWithChildren<any>{{/if}}) {
19
20
  return children
20
21
  }
21
22
  {{/if}}
22
- {{#if (eq framework 'Vue') }}
23
- const App = {
24
- onShow (options) {
25
- console.log('App onShow.')
26
- },
27
- render(h) {
28
- // this.$slots.default 是将要会渲染的页面
29
- return h('block', this.$slots.default)
30
- }
23
+
24
+ {{#if (eq framework 'Solid') }}
25
+ function App({ children }{{#if typescript }}: ParentProps{{/if}}) {
26
+ useLaunch(() => {
27
+ console.log('App launched.')
28
+ })
29
+
30
+ // children 是将要会渲染的页面
31
+ return children
31
32
  }
32
33
  {{/if}}
34
+
33
35
  {{#if (eq framework 'Vue3') }}
34
36
  const App = createApp({
35
37
  onShow (options) {
@@ -2,8 +2,7 @@ import { View, Text } from '@tarojs/components'
2
2
  import { useLoad } from '@tarojs/taro'
3
3
  import './index.{{ cssExt }}'
4
4
 
5
- export default function {{ to_pascal_case pageName }}() {
6
-
5
+ export default function {{ to_pascal_case pageName }} () {
7
6
  useLoad(() => {
8
7
  console.log('Page loaded.')
9
8
  })
@@ -11,13 +11,6 @@ import { ref } from 'vue'
11
11
  import './index.{{ cssExt }}'
12
12
 
13
13
  export default {
14
- {{#if (eq framework 'Vue') }}
15
- data () {
16
- return {
17
- msg: 'Hello world!'
18
- }
19
- }
20
- {{/if}}
21
14
  {{#if (eq framework 'Vue3') }}
22
15
  setup () {
23
16
  const msg = ref('Hello world')
@@ -3,6 +3,11 @@ const path = require('path')
3
3
  function createWhenTs (err, params) {
4
4
  return !!params.typescript
5
5
  }
6
+
7
+ function normalizePath (path) {
8
+ return path.replace(/\\/g, '/').replace(/\/{2,}/g, '/')
9
+ }
10
+
6
11
  const SOURCE_ENTRY = '/src'
7
12
  const PAGES_ENTRY = '/src/pages'
8
13
 
@@ -10,40 +15,40 @@ const handler = {
10
15
  '/tsconfig.json': createWhenTs,
11
16
  '/types/global.d.ts': createWhenTs,
12
17
  '/types/vue.d.ts' (err, { framework, typescript }) {
13
- return ['Vue', 'Vue3'].includes(framework) && !!typescript
18
+ return ['Vue3'].includes(framework) && !!typescript
14
19
  },
15
20
  '/src/pages/index/index.jsx' (err, { pageDir = '', pageName = '', subPkg = '' }) {
16
- return {
17
- setPageName: path.join(PAGES_ENTRY, pageDir, pageName, 'index.jsx'),
18
- setSubPkgName: path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.jsx')
21
+ return {
22
+ setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.jsx')),
23
+ setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.jsx'))
19
24
  }
20
25
  },
21
26
  '/src/pages/index/index.css' (err, { pageDir = '', pageName = '', subPkg = '' }) {
22
- return {
23
- setPageName: path.join(PAGES_ENTRY, pageDir, pageName, 'index.css'),
24
- setSubPkgName: path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.css')
27
+ return {
28
+ setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.css')),
29
+ setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.css'))
25
30
  }
26
31
  },
27
32
  '/src/pages/index/index.vue' (err, { pageDir = '', pageName = '', subPkg = '' }) {
28
- return {
29
- setPageName: path.join(PAGES_ENTRY, pageDir, pageName, 'index.vue'),
30
- setSubPkgName: path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.vue')
33
+ return {
34
+ setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.vue')),
35
+ setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.vue'))
31
36
  }
32
37
  },
33
38
  '/src/pages/index/index.config.js' (err, { pageDir = '', pageName = '', subPkg = '' }) {
34
- return {
35
- setPageName: path.join(PAGES_ENTRY, pageDir, pageName, 'index.config.js'),
36
- setSubPkgName: path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.config.js')
39
+ return {
40
+ setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.config.js')),
41
+ setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.config.js'))
37
42
  }
38
43
  },
39
44
  '/_editorconfig' () {
40
45
  return { setPageName: `/.editorconfig` }
41
46
  },
42
- '/_env.dev' () {
43
- return { setPageName: `/.env.dev` }
47
+ '/_env.development' () {
48
+ return { setPageName: `/.env.development` }
44
49
  },
45
- '/_env.prod' () {
46
- return { setPageName: `/.env.prod` }
50
+ '/_env.production' () {
51
+ return { setPageName: `/.env.production` }
47
52
  },
48
53
  '/_env.test' () {
49
54
  return { setPageName: `/.env.test` }
@@ -13,9 +13,8 @@
13
13
  "noUnusedParameters": true,
14
14
  "strictNullChecks": true,
15
15
  "sourceMap": true,
16
- "baseUrl": ".",
17
16
  "rootDir": ".",
18
- "jsx": "{{#if (includes "Vue" "Vue3" s=framework)}}preserve{{else}}react-jsx{{/if}}",{{#if (eq framework "Preact") }}
17
+ "jsx": "{{#if (includes "Vue3" s=framework)}}preserve{{else}}react-jsx{{/if}}",{{#if (eq framework "Preact") }}
19
18
  "skipLibCheck": true,{{/if}}
20
19
  "allowJs": true,
21
20
  "resolveJsonModule": true,
@@ -23,7 +22,8 @@
23
22
  "node_modules/@types"
24
23
  ],
25
24
  "paths": {
26
- "@/*": ["src/*"]
25
+ // TS5090 leading './'
26
+ "@/*": ["./src/*"]
27
27
  }
28
28
  },
29
29
  "include": ["./src", "./types", "./config"],
@@ -16,7 +16,7 @@ declare namespace NodeJS {
16
16
  /** NODE 内置环境变量, 会影响到最终构建生成产物 */
17
17
  NODE_ENV: 'development' | 'production',
18
18
  /** 当前构建的平台 */
19
- TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
19
+ TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn'
20
20
  /**
21
21
  * 当前构建的小程序 appid
22
22
  * @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
@@ -26,7 +26,7 @@ declare namespace NodeJS {
26
26
  }
27
27
  }
28
28
 
29
- {{#if (includes "Vue" "Vue3" s=framework)}}
29
+ {{#if (includes "Vue3" s=framework)}}
30
30
  declare module '@tarojs/components' {
31
31
  export * from '@tarojs/components/types/index.vue3'
32
32
  }{{/if}}
@@ -18,7 +18,7 @@ npm i {{ projectName }} -D
18
18
  * installPath: string 安装的路径
19
19
  * css?: 'none' | 'sass' | 'stylus' | 'less'
20
20
  * typescript?: boolean
21
- * compiler?: 'webpack4' | 'webpack5' | 'vite'
21
+ * compiler?: 'webpack5' | 'vite'
22
22
  * }
23
23
  * 这些参数后续会被模版文件解析所用
24
24
  * 如果不传,会从 package.json 的 templateInfo
@@ -31,14 +31,13 @@
31
31
  "@tarojs/service": "^{{ version }}"{{#if (eq pluginType "plugin-build") }},
32
32
  "webpack-chain": "^6.5.1"{{/if}}{{#if (eq pluginType "plugin-template") }},
33
33
  "download": "^8.0.0",
34
- "fs-extra": "^11.1.1",
35
- "path": "^0.12.7",
34
+ "fs-extra": "^11.2.0",
36
35
  "unzip": "^0.1.11"{{/if}}
37
36
  },
38
37
  "devDependencies": {
39
- "@types/node": "^18.13.0"
38
+ "@types/node": "^18.15.11"
40
39
  }{{#if (eq pluginType "plugin-template") }},
41
40
  "resolutions": {
42
- "graceful-fs": "^4.2.10"
41
+ "graceful-fs": "^4.2.11"
43
42
  }{{/if}}
44
43
  }
@@ -81,7 +81,7 @@ const unzip = require("unzip")
81
81
  interface ITemplateInfo {
82
82
  css: 'none' | 'sass' | 'stylus' | 'less'
83
83
  typescript?: boolean
84
- compiler?: 'webpack4' | 'webpack5' | 'vite'
84
+ compiler?: 'webpack5' | 'vite'
85
85
  template?: string
86
86
  }
87
87
 
@@ -17,7 +17,6 @@
17
17
  "outDir": "./dist",
18
18
  "traceResolution": false,
19
19
  "sourceMap": true,
20
- "baseUrl": ".",
21
20
  "rootDir": "./src",
22
21
  "declaration": true,
23
22
  "declarationDir": "types"
@@ -1,3 +0,0 @@
1
- import type { ParserOptions } from '@babel/parser';
2
- declare const config: ParserOptions;
3
- export default config;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config = {
4
- sourceType: 'module',
5
- plugins: [
6
- 'typescript',
7
- 'classProperties',
8
- 'jsx',
9
- 'asyncGenerators',
10
- 'objectRestSpread',
11
- 'decorators',
12
- 'dynamicImport'
13
- ]
14
- };
15
- exports.default = config;
16
- //# sourceMappingURL=babylon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"babylon.js","sourceRoot":"","sources":["../../src/config/babylon.ts"],"names":[],"mappings":";;AAEA,MAAM,MAAM,GAAkB;IAC5B,UAAU,EAAE,QAAQ;IACpB,OAAO,EAAE;QACP,YAAY;QACZ,iBAAiB;QACjB,KAAK;QACL,iBAAiB;QACjB,kBAAkB;QAClB,YAAY;QACZ,eAAe;KAChB;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -1,10 +0,0 @@
1
- // babel-preset-taro 更多选项和默认值:
2
- // https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3
- module.exports = {
4
- presets: [
5
- ['taro', {
6
- framework: 'react',
7
- ts: true
8
- }]
9
- ]
10
- }
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- env: {
3
- NODE_ENV: '"development"'
4
- },
5
- defineConstants: {
6
- },
7
- mini: {},
8
- h5: {}
9
- }
@@ -1,70 +0,0 @@
1
- const config = {
2
- projectName: 't3',
3
- date: '2020-5-28',
4
- designWidth: 750,
5
- deviceRatio: {
6
- 640: 2.34 / 2,
7
- 750: 1,
8
- 828: 1.81 / 2
9
- },
10
- sourceRoot: 'src',
11
- outputRoot: 'dist',
12
- plugins: [],
13
- defineConstants: {
14
- },
15
- copy: {
16
- patterns: [
17
- ],
18
- options: {
19
- }
20
- },
21
- framework: 'nerv',
22
- mini: {
23
- postcss: {
24
- pxtransform: {
25
- enable: true,
26
- config: {
27
-
28
- }
29
- },
30
- url: {
31
- enable: true,
32
- config: {
33
- limit: 1024 // 设定转换尺寸上限
34
- }
35
- },
36
- cssModules: {
37
- enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
38
- config: {
39
- namingPattern: 'module', // 转换模式,取值为 global/module
40
- generateScopedName: '[name]__[local]___[hash:base64:5]'
41
- }
42
- }
43
- }
44
- },
45
- h5: {
46
- publicPath: '/',
47
- staticDirectory: 'static',
48
- postcss: {
49
- autoprefixer: {
50
- enable: true,
51
- config: {
52
- }
53
- },
54
- cssModules: {
55
- enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
56
- config: {
57
- namingPattern: 'module', // 转换模式,取值为 global/module
58
- generateScopedName: '[name]__[local]___[hash:base64:5]'
59
- }
60
- }
61
- }
62
- }
63
- }
64
-
65
- module.exports = function (merge) {
66
- if (process.env.NODE_ENV === 'development') {
67
- return merge({}, config, require('./dev'))
68
- }
69
- return merge({}, config, require('./prod'))
70
- }
@@ -1,18 +0,0 @@
1
- module.exports = {
2
- env: {
3
- NODE_ENV: '"production"'
4
- },
5
- defineConstants: {
6
- },
7
- mini: {},
8
- h5: {
9
- /**
10
- * 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
11
- * 参考代码如下:
12
- * webpackChain (chain) {
13
- * chain.plugin('analyzer')
14
- * .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
15
- * }
16
- */
17
- }
18
- }
@@ -1,59 +0,0 @@
1
- {
2
- "name": "t3",
3
- "version": "1.0.0",
4
- "private": true,
5
- "description": "",
6
- "templateInfo": {
7
- "name": "default",
8
- "typescript": true,
9
- "css": "none"
10
- },
11
- "scripts": {
12
- "build:weapp": "taro build --type weapp",
13
- "build:swan": "taro build --type swan",
14
- "build:alipay": "taro build --type alipay",
15
- "build:tt": "taro build --type tt",
16
- "build:h5": "taro build --type h5",
17
- "build:rn": "taro build --type rn",
18
- "build:qq": "taro build --type qq",
19
- "build:quickapp": "taro build --type quickapp",
20
- "dev:weapp": "npm run build:weapp -- --watch",
21
- "dev:swan": "npm run build:swan -- --watch",
22
- "dev:alipay": "npm run build:alipay -- --watch",
23
- "dev:tt": "npm run build:tt -- --watch",
24
- "dev:h5": "npm run build:h5 -- --watch",
25
- "dev:rn": "npm run build:rn -- --watch",
26
- "dev:qq": "npm run build:qq -- --watch",
27
- "dev:quickapp": "npm run build:quickapp -- --watch"
28
- },
29
- "browserslist": [
30
- "last 3 versions",
31
- "Android >= 4.1",
32
- "ios >= 8"
33
- ],
34
- "author": "",
35
- "dependencies": {
36
- "@babel/runtime": "^7.7.7",
37
- "@tarojs/components": "3.0.0-rc.0",
38
- "@tarojs/runtime": "3.0.0-rc.0",
39
- "@tarojs/taro": "3.0.0-rc.0",
40
- "nervjs": "^1.5.0"
41
- },
42
- "devDependencies": {
43
- "@types/webpack-env": "^1.13.6",
44
- "@types/react": "^16.0.0",
45
- "@tarojs/mini-runner": "3.0.0-rc.0",
46
- "@babel/core": "^7.8.0",
47
- "@tarojs/webpack-runner": "3.0.0-rc.0",
48
- "babel-preset-taro": "3.0.0-rc.0",
49
- "eslint-config-taro": "3.0.0-rc.0",
50
- "eslint": "^8.12.0",
51
- "eslint-plugin-react": "^7.33.2",
52
- "eslint-plugin-import": "^2.12.0",
53
- "eslint-plugin-react-hooks": "^1.6.1",
54
- "stylelint": "9.3.0",
55
- "@typescript-eslint/parser": "^2.x",
56
- "@typescript-eslint/eslint-plugin": "^2.x",
57
- "typescript": "^3.7.0"
58
- }
59
- }
@@ -1,11 +0,0 @@
1
- export default {
2
- pages: [
3
- 'pages/index/index'
4
- ],
5
- window: {
6
- backgroundTextStyle: 'light',
7
- navigationBarBackgroundColor: '#fff',
8
- navigationBarTitleText: 'WeChat',
9
- navigationBarTextStyle: 'black'
10
- }
11
- }