Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/taro-h5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"rollup": "^3.29.4",
"rollup-plugin-node-externals": "^5.0.0",
"@rollup/plugin-typescript": "^12.1.2",
"@rollup/plugin-node-resolve": "^15.2.3"
"@rollup/plugin-node-resolve": "^15.2.3",
"rollup-plugin-dts": "^6.2.1"
},
"peerDependencies": {
"@tarojs/components": "workspace:~"
Expand Down
30 changes: 15 additions & 15 deletions packages/taro-h5/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'
import ts from '@rollup/plugin-typescript'
import { mergeWith } from 'lodash'
import { defineConfig } from 'rollup'
import { dts } from 'rollup-plugin-dts'
import externals from 'rollup-plugin-node-externals'
import postcss from 'rollup-plugin-postcss'

Expand Down Expand Up @@ -46,6 +47,20 @@ const variesConfig: RollupOptions[] = [
},
]

variesConfig.push({
input: 'src/index.ts',
output: {
file: 'dist/index.esm.js',
inlineDynamicImports: true
}
},
{
// 需要该配置才能生成打包的 .d.ts 文件供 taro-platform-h5\build\definition-json\parser.ts 生成 apis 配置
input: 'src/index.ts',
output: { file: 'dist/index.esm.d.ts' },
plugins: [dts()]
})

if (process.env.NODE_ENV === 'production') {
variesConfig.push(
{
Expand All @@ -55,25 +70,10 @@ if (process.env.NODE_ENV === 'production') {
file: 'dist/index.cjs.js',
inlineDynamicImports: true,
},
},
{
input: 'src/index.ts',
output: {
file: 'dist/index.esm.js',
inlineDynamicImports: true,
},
}
)
}

variesConfig.push({
input: 'src/index.ts',
output: {
file: 'dist/index.esm.js',
inlineDynamicImports: true
}
})

export default defineConfig(
variesConfig.map((v) => {
const customizer = function (objValue, srcValue) {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-platform-h5/build/definition-json/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function parseAnyOrVoid (str = '', obj: unknown = str) {
}

export function parseDefinitionJSON ({
apisPath = require.resolve('@tarojs/taro-h5/dist/index.d.ts'),
apisPath = require.resolve('@tarojs/taro-h5/dist/index.esm.d.ts'),
componentsPath = require.resolve('@tarojs/components/dist/types/components.d.ts'),
} = {},
config: ts.CompilerOptions = tsconfig,
Expand Down
Loading