@xylabs/sdk-js 2.3.24 → 2.3.25
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 +2 -1
- package/rollup.config.js +2 -113
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"@types/mocha": "^9",
|
|
22
22
|
"@types/node": "^17",
|
|
23
23
|
"@xylabs/eslint-config": "2.2.10",
|
|
24
|
+
"@xylabs/rollup-config": "^1.0.5",
|
|
24
25
|
"@xylabs/ts-scripts": "^1.0.24",
|
|
25
26
|
"@xylabs/tsconfig": "^1.0.8",
|
|
26
27
|
"axios": "^0.24.0",
|
|
@@ -88,5 +89,5 @@
|
|
|
88
89
|
"sideEffects": false,
|
|
89
90
|
"type": "module",
|
|
90
91
|
"types": "dist/index.d.ts",
|
|
91
|
-
"version": "2.3.
|
|
92
|
+
"version": "2.3.25"
|
|
92
93
|
}
|
package/rollup.config.js
CHANGED
|
@@ -1,116 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import replace from '@rollup/plugin-replace'
|
|
3
|
-
import strip from '@rollup/plugin-strip'
|
|
4
|
-
import typescriptPlugin from '@rollup/plugin-typescript'
|
|
5
|
-
import typescript from 'typescript'
|
|
1
|
+
import { getRollupConfig } from '@xylabs/rollup-config'
|
|
6
2
|
|
|
7
3
|
import pkg from './package.json'
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const BUILD_TARGET_MAGIC_STRING = '__BUILD_TARGET__'
|
|
12
|
-
|
|
13
|
-
function generateBuildTargetReplaceConfig(moduleFormat, languageTarget) {
|
|
14
|
-
let buildTarget = ''
|
|
15
|
-
|
|
16
|
-
switch (moduleFormat.toLowerCase()) {
|
|
17
|
-
case 'esm':
|
|
18
|
-
buildTarget += 'esm'
|
|
19
|
-
break
|
|
20
|
-
case 'cjs':
|
|
21
|
-
buildTarget += 'cjs'
|
|
22
|
-
break
|
|
23
|
-
default:
|
|
24
|
-
throw Error(`unsupported module format ${moduleFormat}. Valid values are esm and cjs.`)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (typeof languageTarget !== 'number') {
|
|
28
|
-
throw Error('languageTarget accepts only number')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// simplified input validation
|
|
32
|
-
if (languageTarget != 5 && languageTarget < 2015) {
|
|
33
|
-
throw Error(`invalid languageTarget ${languageTarget}. Valid values are 5, 2015, 2016, etc.`)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
buildTarget += languageTarget
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
[BUILD_TARGET_MAGIC_STRING]: buildTarget,
|
|
40
|
-
preventAssignment: true,
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function emitModulePackageFile() {
|
|
45
|
-
return {
|
|
46
|
-
generateBundle() {
|
|
47
|
-
this.emitFile({
|
|
48
|
-
fileName: 'package.json',
|
|
49
|
-
source: '{"type":"module"}',
|
|
50
|
-
type: 'asset',
|
|
51
|
-
})
|
|
52
|
-
},
|
|
53
|
-
name: 'emit-module-package-file',
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const getPlugIns = (outDir) => {
|
|
58
|
-
return [
|
|
59
|
-
json(),
|
|
60
|
-
strip({
|
|
61
|
-
functions: ['debugAssert.*'],
|
|
62
|
-
}),
|
|
63
|
-
typescriptPlugin({
|
|
64
|
-
outDir,
|
|
65
|
-
typescript,
|
|
66
|
-
}),
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const browserBuilds = [
|
|
71
|
-
{
|
|
72
|
-
external: (id) => deps.some((dep) => id === dep || id.startsWith(`${dep}/`)),
|
|
73
|
-
input: {
|
|
74
|
-
index: './src/index.ts',
|
|
75
|
-
},
|
|
76
|
-
output: [{ dir: './dist/esm5', format: 'es', sourcemap: true }],
|
|
77
|
-
plugins: [...getPlugIns('./dist/esm5'), replace(generateBuildTargetReplaceConfig('esm', 5))],
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
external: (id) => deps.some((dep) => id === dep || id.startsWith(`${dep}/`)),
|
|
81
|
-
input: {
|
|
82
|
-
index: './src/index.ts',
|
|
83
|
-
},
|
|
84
|
-
output: {
|
|
85
|
-
dir: './dist/esm2017',
|
|
86
|
-
format: 'es',
|
|
87
|
-
sourcemap: true,
|
|
88
|
-
},
|
|
89
|
-
plugins: [...getPlugIns('./dist/esm2017'), replace(generateBuildTargetReplaceConfig('esm', 2017))],
|
|
90
|
-
},
|
|
91
|
-
]
|
|
92
|
-
|
|
93
|
-
const nodeBuilds = [
|
|
94
|
-
{
|
|
95
|
-
external: (id) => deps.some((dep) => id === dep || id.startsWith(`${dep}/`)),
|
|
96
|
-
input: {
|
|
97
|
-
index: './src/index.ts',
|
|
98
|
-
},
|
|
99
|
-
output: [{ dir: './dist/node', format: 'cjs', sourcemap: true }],
|
|
100
|
-
plugins: [...getPlugIns('./dist/node'), replace(generateBuildTargetReplaceConfig('cjs', 5))],
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
external: (id) => deps.some((dep) => id === dep || id.startsWith(`${dep}/`)),
|
|
104
|
-
input: {
|
|
105
|
-
index: './src/index.ts',
|
|
106
|
-
},
|
|
107
|
-
output: [{ dir: './dist/node-esm', format: 'es', sourcemap: true }],
|
|
108
|
-
plugins: [
|
|
109
|
-
...getPlugIns('./dist/node-esm'),
|
|
110
|
-
replace(generateBuildTargetReplaceConfig('esm', 2017)),
|
|
111
|
-
emitModulePackageFile(),
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
]
|
|
115
|
-
|
|
116
|
-
export default [...browserBuilds, ...nodeBuilds]
|
|
5
|
+
export default getRollupConfig(pkg)
|