@vitus-labs/tools-rollup 0.41.0 → 0.42.0

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.
Files changed (45) hide show
  1. package/bin/run-build.js +1 -1
  2. package/{typings → global}/index.d.ts +0 -0
  3. package/lib/config/baseConfig.js +2 -0
  4. package/lib/config/baseConfig.js.map +1 -1
  5. package/lib/config/index.js +9 -5
  6. package/lib/config/index.js.map +1 -1
  7. package/lib/declarations/index.js +3 -0
  8. package/lib/declarations/index.js.map +1 -0
  9. package/lib/index.js +1 -1
  10. package/lib/index.js.map +1 -1
  11. package/lib/rollup/config.js +130 -0
  12. package/lib/rollup/config.js.map +1 -0
  13. package/lib/rollup/createBuildPipeline.js +138 -0
  14. package/lib/rollup/createBuildPipeline.js.map +1 -0
  15. package/lib/rollup/index.js +11 -0
  16. package/lib/rollup/index.js.map +1 -0
  17. package/lib/scripts/build.js +119 -59
  18. package/lib/scripts/build.js.map +1 -1
  19. package/lib/types/config/baseConfig.d.ts +1 -0
  20. package/lib/types/config/index.d.ts +4 -3
  21. package/lib/types/declarations/index.d.ts +17 -0
  22. package/lib/types/{config/rollup.d.ts → rollup/config.d.ts} +9 -7
  23. package/lib/types/rollup/createBuildPipeline.d.ts +2 -0
  24. package/lib/types/rollup/index.d.ts +3 -0
  25. package/package.json +9 -5
  26. package/src/config/{baseConfig.js → baseConfig.ts} +2 -1
  27. package/src/config/index.ts +10 -0
  28. package/src/index.ts +3 -0
  29. package/src/{config/rollup.js → rollup/config.ts} +43 -48
  30. package/src/{scripts/utils.js → rollup/createBuildPipeline.ts} +21 -18
  31. package/src/rollup/index.ts +4 -0
  32. package/src/scripts/{build.js → build.ts} +21 -33
  33. package/tsconfig.json +25 -0
  34. package/tsconfig.tsbuildinfo +1 -0
  35. package/lib/config/rollup.js +0 -129
  36. package/lib/config/rollup.js.map +0 -1
  37. package/lib/scripts/utils.js +0 -138
  38. package/lib/scripts/utils.js.map +0 -1
  39. package/lib/types/scripts/utils.d.ts +0 -2
  40. package/lib/types/utils.d.ts +0 -5
  41. package/lib/utils.js +0 -106
  42. package/lib/utils.js.map +0 -1
  43. package/src/config/index.js +0 -4
  44. package/src/index.js +0 -3
  45. package/src/utils.js +0 -129
package/src/utils.js DELETED
@@ -1,129 +0,0 @@
1
- const fs = require('fs')
2
- const findUp = require('find-up')
3
- const merge = require('lodash.merge')
4
-
5
- // --------------------------------------------------------
6
- // FIND & READ file helpers
7
- // --------------------------------------------------------
8
- const findFile = (filename) => findUp.sync(filename, { type: 'file' })
9
- // const findFilePath = (filename) => findFile(filename).replace(filename, '')
10
-
11
- const fileToJson = (name) => {
12
- const file = fs.readFileSync(findFile(name)).toString('utf8')
13
-
14
- try {
15
- const json = JSON.parse(file)
16
-
17
- return json
18
- } catch (e) {
19
- console.log(e)
20
- }
21
-
22
- return {}
23
- }
24
-
25
- // --------------------------------------------------------
26
- // GET PACKAGE.JSON info
27
- // --------------------------------------------------------
28
- const getPackageJSON = () => {
29
- const data = fileToJson('package.json')
30
-
31
- return data
32
- }
33
-
34
- // --------------------------------------------------------
35
- // PACKAGE.json parsing functions
36
- // --------------------------------------------------------
37
-
38
- // GET LIST OF DEPENDENCIES from package.json
39
- const getDependenciesList = (types) => {
40
- const pkg = getPackageJSON()
41
- let result = []
42
-
43
- types.forEach((item) => {
44
- const data = pkg[item]
45
- result = [...result, ...Object.keys(data || {})]
46
- })
47
-
48
- return result
49
- }
50
-
51
- // parse namespace name
52
- // const parseNamespace = (name) =>
53
- // name.startsWith('@') ? name.split('/')[0] : ''
54
-
55
- // converts package name to umd or iife valid format
56
- // example: napespace-package-name => namespacePackageName
57
- const camelspaceBundleName = (name) => {
58
- const parsedName = name.replace('@', '').replace('/', '-')
59
- const arrayStringsCamel = (arr) =>
60
- arr.map((item, i) =>
61
- i === 0
62
- ? item
63
- : item.charAt(0).toUpperCase() + item.substr(1).toLowerCase()
64
- )
65
- const arr = parsedName.split('-')
66
- const result = arrayStringsCamel(arr).join('')
67
-
68
- return result
69
- }
70
-
71
- // --------------------------------------------------------
72
- // PACKAGE JSON DATA
73
- // --------------------------------------------------------
74
- const getPkgData = () => {
75
- const pkg = getPackageJSON()
76
- const { name } = pkg
77
- // const namespace = parseNamespace(name)
78
-
79
- return {
80
- ...pkg,
81
- // nameWithoutPrefix: name.replace(namespace, '').replace('/', ''),
82
- // namespace,
83
- // namespaceName: namespace.replace('@', ''),
84
- // rootPath: findFilePath('package.json'),
85
- bundleName: camelspaceBundleName(name),
86
- externalDependencies: getDependenciesList([
87
- 'dependencies',
88
- 'peerDependencies',
89
- ]),
90
- }
91
- }
92
-
93
- // --------------------------------------------------------
94
- // LOAD EXTERNAL CONFIGURATION
95
- // --------------------------------------------------------
96
- const getExternalConfig = () => {
97
- const file = findFile('vl-tools.config.js')
98
- if (file) {
99
- const data = require(file)
100
-
101
- return data.build
102
- }
103
-
104
- return {}
105
- }
106
-
107
- const loadConfig = (config) => {
108
- const externalConfig = getExternalConfig()
109
-
110
- return merge(config, externalConfig)
111
- }
112
-
113
- const swapGlobals = (globals) => {
114
- const result = {}
115
-
116
- Object.entries(globals).forEach(([key, value]) => {
117
- result[value] = key
118
- })
119
-
120
- return result
121
- }
122
-
123
- module.exports = {
124
- findFile,
125
- loadConfig,
126
- swapGlobals,
127
- PKG: getPkgData(),
128
- CONFIG: getExternalConfig(),
129
- }