Skip to content

chore: add tsdown #17746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@
"stylelint-order": "^6.0.4",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.1",
"typescript": "~5.4.5",
"tsdown": "^0.12.2",
"tslib": "^2.6.2",
"typescript": "~5.4.5",
"vitest": "^1.6.0"
},
"pnpm": {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-rn/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// 由 getLibList.js 脚本生成, 不要进行手动修改, 请不要手动修改
export * from './ENV_TYPE'
export * from './arrayBufferToBase64'
export * from './authorize'
export * from './base64ToArrayBuffer'
Expand All @@ -16,6 +15,7 @@ export * from './createInnerAudioContext'
export * from './createSelectorQuery'
export * from './createVideoContext'
export * from './downloadFile'
export * from './ENV_TYPE'
export * from './getAppBaseInfo'
export * from './getClipboardData'
export * from './getEnv'
Expand Down
7 changes: 5 additions & 2 deletions packages/taro-runtime/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const path = require('path')
import path from 'node:path'
import { fileURLToPath } from 'node:url'

module.exports = {
const __dirname = path.dirname(fileURLToPath(import.meta.url))
Copy link
Contributor

@yoyo837 yoyo837 May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tarojs/runtime 并没有声明 "type": "module", 这样有问题吧,建议变动尽量小。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在 package.json 里加了 "type": "module",而且本来之前导出的文件也都是esm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我个人倾向于先保持 commonjs 的效果,避免一些意外。


export default {
globals: {
ENABLE_INNER_HTML: true,
ENABLE_ADJACENT_HTML: true,
Expand Down
15 changes: 5 additions & 10 deletions packages/taro-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@tarojs/runtime",
"type": "module",
"version": "4.1.1",
"description": "taro runtime for mini apps.",
"author": "O2Team",
Expand All @@ -16,12 +17,9 @@
"./dist/dom-external/index.js"
],
"scripts": {
"prod": "pnpm run build",
"prebuild": "pnpm run clean",
"build": "pnpm run rollup --environment NODE_ENV:production",
"clean": "rimraf ./dist",
"dev": "pnpm run rollup --environment NODE_ENV:development -w",
"rollup": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
"prod": "tsdown",
"build": "tsdown",
"dev": "tsdown -w",
"test": "jest",
"test:ci": "jest --ci -i --coverage --silent"
},
Expand All @@ -37,12 +35,9 @@
"tslib": "^2.6.2"
},
"devDependencies": {
"@rollup/plugin-typescript": "^12.1.2",
"@types/react": "^18.2.79",
"@vue/runtime-core": "^3.4.23",
"lodash": "^4.17.21",
"react": "^18.2.0",
"rollup": "^4.37.0",
"rollup-plugin-ts": "^3.4.5"
"react": "^18.2.0"
}
}
48 changes: 0 additions & 48 deletions packages/taro-runtime/rollup.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/taro-runtime/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"outDir": "./dist",
"target": "ES2017"
},
"include": ["./src", "./rollup.config.ts"],
"include": ["./src"],
"exclude": ["./src/__tests__"]
}
19 changes: 19 additions & 0 deletions packages/taro-runtime/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'tsdown'

export default [
defineConfig({
entry: 'src/index.ts',
noExternal: ['@tarojs/shared'],
treeshake: false,
sourcemap: true,
unbundle: true,
}),
defineConfig({
entry: {
'runtime.esm': 'src/index.ts',
},
noExternal: ['@tarojs/shared'],
treeshake: false,
sourcemap: true,
})
]
Loading