@jcoreio/toolchain 3.1.3 → 3.2.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcoreio/toolchain",
3
- "version": "3.1.3",
3
+ "version": "3.2.1",
4
4
  "description": "base JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3,5 +3,38 @@ module.exports = [
3
3
  delete packageJson.devDependencies
4
4
  delete packageJson.scripts
5
5
  delete packageJson.config
6
+ const mapValues = require('lodash/mapValues')
7
+
8
+ function replaceDist(path) {
9
+ return path.replace(/^(\.\/)?dist\//, '$1')
10
+ }
11
+
12
+ for (const key of ['main', 'module', 'browser', 'types', 'bin']) {
13
+ if (typeof packageJson[key] === 'string') {
14
+ packageJson[key] = replaceDist(packageJson[key])
15
+ }
16
+ }
17
+ for (const key of ['bin', 'directories']) {
18
+ if (typeof packageJson[key] === 'object' && packageJson[key] != null) {
19
+ packageJson[key] = mapValues(packageJson[key], replaceDist)
20
+ }
21
+ }
22
+
23
+ if (Array.isArray(packageJson.files)) {
24
+ packageJson.files = packageJson.files.map(replaceDist)
25
+ }
26
+
27
+ function convertExportMap(thing) {
28
+ if (typeof thing === 'string') return replaceDist(thing)
29
+ if (typeof thing === 'object' && thing != null)
30
+ return mapValues(thing, convertExportMap)
31
+ return thing
32
+ }
33
+ if (packageJson.exports)
34
+ packageJson.exports = convertExportMap(packageJson.exports)
35
+ if (packageJson.imports)
36
+ packageJson.imports = convertExportMap(packageJson.imports)
37
+
38
+ return packageJson
6
39
  },
7
40
  ]