@tarojs/taro 3.6.9-alpha.2 → 3.6.9-alpha.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/taro",
3
- "version": "3.6.9-alpha.2",
3
+ "version": "3.6.9-alpha.3",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -21,15 +21,11 @@
21
21
  "author": "O2Team",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@tarojs/api": "3.6.9-alpha.2",
25
- "@tarojs/runtime": "3.6.9-alpha.2"
24
+ "@tarojs/api": "3.6.9-alpha.3",
25
+ "@tarojs/runtime": "3.6.9-alpha.3"
26
26
  },
27
27
  "devDependencies": {
28
- "postcss": "^8.4.18",
29
- "@tarojs/helper": "3.6.9-alpha.2"
30
- },
31
- "peerDependencies": {
32
- "postcss": "^8.4.18"
28
+ "@tarojs/helper": "3.6.9-alpha.3"
33
29
  },
34
30
  "peerDependenciesMeta": {
35
31
  "@types/react": {
@@ -41,6 +37,9 @@
41
37
  "@types/webpack-dev-server": {
42
38
  "optional": true
43
39
  },
40
+ "postcss": {
41
+ "optional": true
42
+ },
44
43
  "vue": {
45
44
  "optional": true
46
45
  }
@@ -5,8 +5,11 @@ import type HtmlWebpackPlugin from 'html-webpack-plugin'
5
5
  import type { IOption, IPostcssOption } from './util'
6
6
 
7
7
  export interface IH5RouterConfig {
8
+ /** 配置路由模式 */
8
9
  mode?: 'hash' | 'browser' | 'multi'
10
+ /** 配置自定义路由 */
9
11
  customRoutes?: IOption
12
+ /** 配置路由基准路径 */
10
13
  basename?: string
11
14
  lazyload?: boolean | ((pagename: string) => boolean)
12
15
  renamePagename?: (pagename: string) => string
@@ -14,37 +17,95 @@ export interface IH5RouterConfig {
14
17
  }
15
18
 
16
19
  export interface IH5Config {
20
+ /** 设置输出解析文件的目录(默认值:'/')*/
17
21
  publicPath?: string
22
+
23
+ /** h5 编译后的静态文件目录(默认值:'static') */
18
24
  staticDirectory?: string
25
+
26
+ /** 编译后非 entry 的 js 文件的存放目录,主要影响动态引入的 pages 的存放路径(默认值:'chunk') */
19
27
  chunkDirectory?: string
20
28
 
21
29
  webpack?: ((webpackConfig: Webpack.Configuration, webpack) => Webpack.Configuration) | Webpack.Configuration
22
30
 
31
+ /**
32
+ * 自定义 Webpack 配置
33
+ * @param chain [webpackChain](https://github.com/neutrinojs/webpack-chain) 对象
34
+ * @param webpack webpack 实例
35
+ */
23
36
  webpackChain?: (chain: Chain, webpack: typeof Webpack) => void
24
37
 
38
+ /** 可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/) */
25
39
  output?: Webpack.Configuration['output']
40
+
41
+ /** 路由相关的配置 */
26
42
  router?: IH5RouterConfig
43
+
44
+ /** 预览服务的配置,可以更改端口等参数。具体配置参考 [webpack-dev-server](https://webpack.js.org/configuration/dev-server) */
27
45
  devServer?: webpackDevServer.Configuration
28
- sourceMapType?: 'none' | 'eval' | 'cheap-eval-source-map' | 'cheap-module-eval-source-map' | 'eval-source-map' | 'cheap-source-map' | 'cheap-module-source-map' | 'inline-cheap-source-map' | 'inline-cheap-module-source-map' | 'source-map' | 'inline-source-map' | 'hidden-source-map' | 'nosources-source-map'
46
+
47
+ /** 具体配置请参考 [Webpack devtool](https://webpack.js.org/configuration/devtool/#devtool) 配置 (默认值:'cheap-module-eval-source-map')*/
48
+ sourceMapType?:
49
+ | 'none'
50
+ | 'eval'
51
+ | 'cheap-eval-source-map'
52
+ | 'cheap-module-eval-source-map'
53
+ | 'eval-source-map'
54
+ | 'cheap-source-map'
55
+ | 'cheap-module-source-map'
56
+ | 'inline-cheap-source-map'
57
+ | 'inline-cheap-module-source-map'
58
+ | 'source-map'
59
+ | 'inline-source-map'
60
+ | 'hidden-source-map'
61
+ | 'nosources-source-map'
62
+
63
+ /** extract 功能开关,开启后将使用 mini-css-extract-plugin 分离 css 文件,可通过 h5.miniCssExtractPluginOption 对插件进行配置 (默认值:watch 模式下为 false,否则为 true) */
29
64
  enableExtract?: boolean
30
- transformOnly?: boolean
31
65
 
66
+ /** [css-loader](https://github.com/webpack-contrib/css-loader) 的附加配置 */
32
67
  cssLoaderOption?: IOption
68
+
69
+ /** [style-loader](https://github.com/webpack-contrib/style-loader) 的附加配置 */
33
70
  styleLoaderOption?: IOption
71
+
72
+ /** [sass-loader](https://github.com/webpack-contrib/sass-loader) 的附加配置 */
34
73
  sassLoaderOption?: IOption
74
+
75
+ /** [less-loader](https://github.com/webpack-contrib/less-loader) 的附加配置 */
35
76
  lessLoaderOption?: IOption
77
+
78
+ /** [stylus-loader](https://github.com/shama/stylus-loader) 的附加配置 */
36
79
  stylusLoaderOption?: IOption
80
+
81
+ /** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
37
82
  mediaUrlLoaderOption?: IOption
83
+
84
+ /** 针对 woff | woff2 | eot | ttf | otf 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
38
85
  fontUrlLoaderOption?: IOption
86
+
87
+ /** 针对 png | jpg | jpeg | gif | bpm | svg 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
39
88
  imageUrlLoaderOption?: IOption
89
+
90
+ /** [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的附加配置 */
40
91
  miniCssExtractPluginOption?: IOption
92
+
93
+ /** 配置需要额外的经由 Taro 预设的 postcss 编译的模块 */
41
94
  esnextModules?: string[]
95
+
96
+ /** 用于控制在 H5 端是否使用兼容性组件库,详情请看 [React 兼容性组件库](https://taro-docs.jd.com/docs/next/h5#react-兼容性组件库)。(默认值:false) */
42
97
  useHtmlComponents?: boolean
98
+
99
+ /** 用于控制在 H5 端是否使用旧版本适配器,旧版本采用全局注册组件,懒加载组件相关依赖;新版本适配器会自动注册相关组件,不再需要引入 @tarojs/components/loader 中的全局 defineCustomElements 方法。(默认值:false) */
43
100
  useDeprecatedAdapterComponent?: boolean
44
101
 
102
+ /** 配置 postcss 相关插件 */
45
103
  postcss?: IPostcssOption
104
+
105
+ /** html-webpack-plugin 的具体配置 */
46
106
  htmlPluginOption?: HtmlWebpackPlugin.Options
47
107
 
108
+ /** Web 编译过程的相关配置 */
48
109
  compile?: {
49
110
  exclude?: any[]
50
111
  include?: any[]
@@ -1,6 +1,6 @@
1
1
  import type Webpack from 'webpack'
2
2
  import type Chain from 'webpack-chain'
3
- import type { IMINI_APP_FILE_TYPE, IOption, IPostcssOption } from './util'
3
+ import type { IOption, IPostcssOption } from './util'
4
4
 
5
5
  interface Runtime {
6
6
  enableInnerHTML: boolean
@@ -13,36 +13,75 @@ interface Runtime {
13
13
  }
14
14
 
15
15
  export interface IMiniAppConfig {
16
- appOutput?: boolean
16
+ /** 默认值:'cheap-module-source-map', 具体参考[Webpack devtool 配置](https://webpack.js.org/configuration/devtool/#devtool) */
17
17
  sourceMapType?: string
18
+
19
+ /** 指定 React 框架相关的代码是否使用开发环境(未压缩)代码,默认使用生产环境(压缩后)代码 */
18
20
  debugReact?: boolean
21
+
22
+ /** 压缩小程序 xml 文件的相关配置 */
19
23
  minifyXML?: {
24
+ /** 是否合并 xml 文件中的空格 (默认false) */
20
25
  collapseWhitespace?: boolean
21
26
  }
22
27
 
28
+ /**
29
+ * 自定义 Webpack 配置
30
+ * @param chain [webpackChain](https://github.com/neutrinojs/webpack-chain) 对象
31
+ * @param webpack webpack 实例
32
+ * @param PARSE_AST_TYPE 小程序编译时的文件类型集合
33
+ * @returns
34
+ */
23
35
  webpackChain?: (chain: Chain, webpack: typeof Webpack, PARSE_AST_TYPE: any) => void
36
+
37
+ /** 可用于修改、拓展 Webpack 的 [output](https://webpack.js.org/configuration/output/) 选项 */
24
38
  output?: Webpack.Configuration['output']
39
+
40
+ /** 配置 postcss 相关插件 */
25
41
  postcss?: IPostcssOption
42
+
43
+ /** [css-loader](https://github.com/webpack-contrib/css-loader) 的附加配置 */
26
44
  cssLoaderOption?: IOption
45
+
46
+ /** [sass-loader](https://github.com/webpack-contrib/sass-loader) 的附加配置 */
27
47
  sassLoaderOption?: IOption
48
+
49
+ /** [less-loader](https://github.com/webpack-contrib/less-loader) 的附加配置 */
28
50
  lessLoaderOption?: IOption
51
+
52
+ /** [stylus-loader](https://github.com/shama/stylus-loader) 的附加配置 */
29
53
  stylusLoaderOption?: IOption
54
+
55
+ /** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
30
56
  mediaUrlLoaderOption?: IOption
57
+
58
+ /** 针对 woff | woff2 | eot | ttf | otf 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
31
59
  fontUrlLoaderOption?: IOption
60
+
61
+ /** 针对 png | jpg | jpeg | gif | bpm | svg 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
32
62
  imageUrlLoaderOption?: IOption
63
+
64
+ /** [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的附加配置 */
33
65
  miniCssExtractPluginOption?: IOption
34
66
 
35
- customFilesTypes?: IMINI_APP_FILE_TYPE
67
+ /** 用于告诉 Taro 编译器需要抽取的公共文件 */
36
68
  commonChunks?: string[] | ((commonChunks: string[]) => string[])
37
- addChunkPages?: ((pages: Map<string, string[]>, pagesNames?: string[]) => void)
69
+
70
+ /** 为某些页面单独指定需要引用的公共文件 */
71
+ addChunkPages?: (pages: Map<string, string[]>, pagesNames?: string[]) => void
72
+
73
+ /** 优化主包的体积大小 */
38
74
  optimizeMainPackage?: {
39
75
  enable?: boolean
40
76
  exclude?: any[]
41
77
  }
42
78
 
79
+ /** 小程序编译过程的相关配置 */
43
80
  compile?: {
44
81
  exclude?: any[]
45
82
  include?: any[]
46
83
  }
84
+
85
+ /** 插件内部使用 */
47
86
  runtime?: Runtime
48
87
  }
@@ -6,8 +6,9 @@ import type { IModifyWebpackChain } from '../hooks'
6
6
  import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from './util'
7
7
  import type { IH5Config } from './h5'
8
8
  import type { IMiniAppConfig } from './mini'
9
+ import { IRNConfig } from './rn'
9
10
 
10
- export type PluginItem = string | [string, object]
11
+ export type PluginItem = string | [string, object] | [string, () => object | Promise<object>]
11
12
 
12
13
  interface ICache {
13
14
  enable?: boolean
@@ -137,7 +138,73 @@ export interface IProjectBaseConfig {
137
138
  modifyBuildAssets?: (assets: any, miniPlugin?: any) => Promise<any>
138
139
  }
139
140
 
140
- export interface IProjectConfig extends IProjectBaseConfig {
141
+ /** 暴露出来给 config/index 使用的配置类型,参考 https://github.com/NervJS/taro-doctor/blob/main/assets/config_schema.json */
142
+ export interface IProjectConfig {
143
+ /** 项目名称 */
144
+ projectName?: string
145
+
146
+ /** 项目创建日期 */
147
+ date?: string
148
+
149
+ /** 设计稿尺寸 */
150
+ designWidth?: number | ((size?: string | number | Input) => number)
151
+
152
+ /** 设计稿尺寸换算规则 */
153
+ deviceRatio?: TaroGeneral.TDeviceRatio
154
+
155
+ /** 源码存放目录 (默认值:'src') */
156
+ sourceRoot?: string
157
+
158
+ /** 代码编译后的生产目录 (默认值:'dist') */
159
+ outputRoot?: string
160
+
161
+ /** 用于设置环境变量 (除了NODE_ENV以外,其他环境变量建议在根目录下的.env文件中) */
162
+ env?: IOption
163
+
164
+ /** 用于配置目录别名,从而方便书写代码引用路径 */
165
+ alias?: IOption
166
+
167
+ /** 用于配置一些全局变量供代码中进行使用(建议放在根目录下的.env文件中) */
168
+ defineConstants?: IOption
169
+
170
+ /** 用于把文件从源码目录直接拷贝到编译后的生产目录 */
171
+ copy?: ICopyOptions
172
+
173
+ /** 配置 JS 压缩工具 (默认 terser) */
174
+ jsMinimizer?: 'terser' | 'esbuild'
175
+
176
+ /** 配置 CSS 压缩工具 (默认 csso) */
177
+ cssMinimizer?: 'csso' | 'esbuild' | 'parcelCss'
178
+
179
+ /** 配置 csso 工具以压缩 CSS 代码 */
180
+ csso?: TogglableOptions
181
+
182
+ /** 配置 terser 工具以压缩 JS 代码 */
183
+ terser?: TogglableOptions
184
+
185
+ esbuild?: Record<'minify', TogglableOptions>
186
+
187
+ /** 用于控制对 scss 代码的编译行为,默认使用 dart-sass,具体配置可以参考 https://www.npmjs.com/package/sass */
188
+ sass?: ISassOptions
189
+
190
+ /** 配置 Taro 插件 */
191
+ plugins?: PluginItem[]
192
+
193
+ /** 一个 preset 是一系列 Taro 插件的集合,配置语法同 plugins */
194
+ presets?: PluginItem[]
195
+
196
+ /** 使用的开发框架。可选值:react、preact、nerv、vue、vue3 */
197
+ framework?: 'react' | 'preact' | 'nerv' | 'vue' | 'vue3'
198
+
199
+ /** 使用的编译工具。可选值:webpack4、webpack5 */
200
+ compiler?: Compiler
201
+
202
+ /** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
203
+ cache?: ICache
204
+
205
+ /** 控制 Taro 编译日志的输出方式 */
206
+ logger?: ILogger
207
+
141
208
  /** 专属于小程序的配置 */
142
209
  mini?: IMiniAppConfig
143
210
 
@@ -145,7 +212,7 @@ export interface IProjectConfig extends IProjectBaseConfig {
145
212
  h5?: IH5Config
146
213
 
147
214
  /** 专属于 RN 的配置 */
148
- rn?: IH5Config
215
+ rn?: IRNConfig
149
216
 
150
217
  [key: string]: any
151
218
  }
@@ -0,0 +1,52 @@
1
+ import type Webpack from 'webpack'
2
+ import type Chain from 'webpack-chain'
3
+ import type webpackDevServer from 'webpack-dev-server'
4
+ import type HtmlWebpackPlugin from 'html-webpack-plugin'
5
+ import type { IOption, IPostcssOption } from './util'
6
+
7
+ export interface IRNConfig {
8
+ /** 设置 RN bundle 中注册应用的名称 */
9
+ appName: string
10
+
11
+ /** entry 利用模块查找规则{name}.{platform}.{ext}自动区分平台 */
12
+ entry?: string
13
+
14
+ /** 设置 Metro 打包生成 bundle 的输出路径,默认 dist 目录下 */
15
+ output?: any
16
+
17
+ /** [sass](https://github.com/sass/node-sass#options) 相关配置 */
18
+ sass?: IOption
19
+
20
+ /** [less](https://lesscss.org/usage/#less-options) 相关配置 */
21
+ less?: IOption
22
+
23
+ /** [stylus](https://github.com/NervJS/taro/blob/next/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */
24
+ stylus?: IOption
25
+
26
+ /** 配置 postcss 相关插件 */
27
+ postcss?: {
28
+ /** postcss 配置,参考 https://github.com/postcss/postcss#options */
29
+ options?: any
30
+ /** 默认true,控制是否对 css value 进行 scalePx2dp 转换,pxtransform配置 enable 才生效 */
31
+ scalable?: boolean
32
+ pxtransform?: {
33
+ enable?: boolean
34
+ /** 插件 pxtransform 配置项 */
35
+ config: ?{
36
+ additionalProperties?: boolean
37
+ [key: string]: any
38
+ }
39
+ }
40
+ }
41
+
42
+ resolve?: any
43
+
44
+ /** 支持多 className 转换,以 classname 或 style 结尾的, 提取前缀, 然后根据前缀,再生成对应的 xxxStyle。如:barClassName -> barStyle。默认值 false,不开启 */
45
+ enableMultipleClassName?: boolean
46
+
47
+ /** 当标签 style 属性值是数组时转换成对象。默认值 false,不开启 */
48
+ enableMergeStyle?: boolean
49
+
50
+ /** 将 svg 文件转换为组件引入。默认值 false,不开启 */
51
+ enableSvgTransform?: boolean
52
+ }