Repository navigation
Expand file tree
/
Copy pathrollup.config.js
More file actions
85 lines (78 loc) · 2.11 KB
/
Copy pathrollup.config.js
File metadata and controls
85 lines (78 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import typescript from 'rollup-plugin-typescript2'
import { dts } from "rollup-plugin-dts"
// Cordova Library Configuration
const libCordovaDir = 'packages/lib-cordova'
const libCordovaInput = `${libCordovaDir}/src/index.ts`
const libCordovaOutput = `${libCordovaDir}/lib/index.js`
const libCordovaOutputDts = `${libCordovaDir}/lib/index.d.ts`
const expectedCordovaModules = ["cordova-powerauth-mobile-sdk", "cordova"]
// React Native Library Configuration
const libRNDir = 'packages/lib-rn'
const libRNInput = `${libRNDir}/src/index.ts`
const libRNOutput = `${libRNDir}/lib`
// Generate both the JavaScript bundle and the TypeScript declaration file
export default [
/**************
* CORDOVA
**************/
// Cordova Library
{
input: libCordovaInput,
output: {
file: libCordovaOutput,
format: 'cjs',
sourcemap: true
},
plugins: [
typescript({
tsconfig: `${libCordovaDir}/tsconfig.json`
}),
// We dont want to import modules that will be supplied by Cordova environment
// Cordova plugins are injected at runtime, so we need to strip these imports from the final bundle to not cause errors.
{
name: "remove-cordova-modules",
transform(code, id) {
return {
code: code.replace(new RegExp(`^import.*(?:${expectedCordovaModules.map(m => `"${m}"`).join("|")}).*$`, "gm"), ""),
map: null,
};
},
}
]
},
// Cordova Library .d.ts
{
input: libCordovaInput,
output: {
file: libCordovaOutputDts,
format: 'es'
},
plugins: [dts()],
},
/**************
* REACT NATIVE
**************/
// React Native Library
{
input: libRNInput,
output: {
dir: libRNOutput,
format: 'es',
},
external: ['react-native-powerauth-mobile-sdk', 'react-native'],
plugins: [
typescript({
tsconfig: `${libRNDir}/tsconfig.json`
})
]
},
// React Native .d.ts
{
input: libRNInput,
output: {
dir: libRNOutput,
format: 'es'
},
plugins: [dts({ tsconfig: `${libRNDir}/tsconfig.json` })],
}
]