1
- import { join } from 'node:path'
2
-
3
1
import commonjs from '@rollup/plugin-commonjs'
4
2
import { nodeResolve } from '@rollup/plugin-node-resolve'
3
+ import ts from '@rollup/plugin-typescript'
5
4
import { type InputPluginOption , type RollupOptions , defineConfig } from 'rollup'
6
5
import copy from 'rollup-plugin-copy'
7
6
import externals from 'rollup-plugin-node-externals'
8
- import ts from 'rollup-plugin-ts'
9
-
10
- const cwd = __dirname
11
7
12
8
const base : RollupOptions & { plugins : InputPluginOption [ ] } = {
13
9
external : d => {
@@ -21,11 +17,7 @@ const base: RollupOptions & { plugins: InputPluginOption[] } = {
21
17
preferBuiltins : false
22
18
} ) as InputPluginOption ,
23
19
ts ( {
24
- tsconfig : e => ( {
25
- ...e ,
26
- declaration : true ,
27
- sourceMap : true ,
28
- } )
20
+ exclude : [ 'rollup.config.ts' ]
29
21
} ) ,
30
22
commonjs ( ) as InputPluginOption
31
23
]
@@ -34,9 +26,9 @@ const base: RollupOptions & { plugins: InputPluginOption[] } = {
34
26
// 供 CLI 编译时使用的 Taro 插件入口
35
27
const compileConfig : RollupOptions = {
36
28
...base ,
37
- input : join ( cwd , 'src/index.ts' ) ,
29
+ input : 'src/index.ts' ,
38
30
output : {
39
- file : join ( cwd , 'dist/index.js' ) ,
31
+ file : 'dist/index.js' ,
40
32
format : 'cjs' ,
41
33
sourcemap : true ,
42
34
exports : 'named'
@@ -59,9 +51,9 @@ const compileConfig: RollupOptions = {
59
51
// 供 Loader 使用的运行时入口
60
52
const runtimeConfig : RollupOptions = {
61
53
...base ,
62
- input : join ( cwd , 'src/runtime.ts' ) ,
54
+ input : 'src/runtime.ts' ,
63
55
output : {
64
- file : join ( cwd , 'dist/runtime.js' ) ,
56
+ file : 'dist/runtime.js' ,
65
57
format : 'es' ,
66
58
sourcemap : true
67
59
}
@@ -70,9 +62,9 @@ const runtimeConfig: RollupOptions = {
70
62
// 供继承的包使用,为了能 tree-shaking
71
63
const runtimeUtilsConfig : RollupOptions = {
72
64
...base ,
73
- input : join ( cwd , 'src/runtime-utils.ts' ) ,
65
+ input : 'src/runtime-utils.ts' ,
74
66
output : {
75
- file : join ( cwd , 'dist/runtime-utils.js' ) ,
67
+ file : 'dist/runtime-utils.js' ,
76
68
format : 'es' ,
77
69
sourcemap : true
78
70
}
@@ -81,18 +73,16 @@ const runtimeUtilsConfig: RollupOptions = {
81
73
// React 下 webpack 会 alias @tarojs/components 为此文件
82
74
const otherConfig : RollupOptions = {
83
75
...base ,
84
- input : join ( cwd , 'src/components/components-react.ts' ) ,
76
+ input : 'src/components/components-react.ts' ,
85
77
output : {
86
- file : join ( cwd , 'dist/components/components-react.js' ) ,
78
+ file : 'dist/components/components-react.js' ,
87
79
format : 'es' ,
88
80
sourcemap : true
89
81
} ,
90
82
plugins : [
91
83
ts ( {
92
- tsconfig : e => ( {
93
- ...e ,
94
- declaration : false ,
95
- } )
84
+ declaration : false ,
85
+ exclude : [ 'rollup.config.ts' ]
96
86
} )
97
87
]
98
88
}
0 commit comments