@jcoreio/toolchain 5.5.9 → 5.6.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.
package/package.json
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const mapValues = require('../util/mapValues.cjs')
|
|
2
|
+
const { toolchainConfig } = require('@jcoreio/toolchain/util/findUps.cjs')
|
|
3
|
+
const outputEsm = toolchainConfig.outputEsm !== false
|
|
2
4
|
|
|
3
5
|
module.exports = [
|
|
4
6
|
async function buildDistPackageJson(packageJson) {
|
|
@@ -6,16 +8,33 @@ module.exports = [
|
|
|
6
8
|
delete packageJson.scripts
|
|
7
9
|
delete packageJson.config
|
|
8
10
|
|
|
9
|
-
function replaceDist(path) {
|
|
10
|
-
|
|
11
|
+
function replaceDist(path, ext) {
|
|
12
|
+
path = path.replace(/^(\.\/)?(src|dist)\//, '$1')
|
|
13
|
+
if (ext) path = path.replace(/(\.d)?\.tsx?$/, ext)
|
|
14
|
+
return path
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
for (const key of ['main', 'module', 'browser', 'types', 'bin']) {
|
|
17
|
+
for (const key of ['main', 'module', 'browser', 'types', 'bin', 'types']) {
|
|
14
18
|
if (typeof packageJson[key] === 'string') {
|
|
15
|
-
packageJson[key] = replaceDist(
|
|
19
|
+
packageJson[key] = replaceDist(
|
|
20
|
+
packageJson[key],
|
|
21
|
+
key === 'module' ? '.mjs'
|
|
22
|
+
: key === 'main' ? '.js'
|
|
23
|
+
: key === 'types' ? '.d.ts'
|
|
24
|
+
: outputEsm ? '.mjs'
|
|
25
|
+
: '.js'
|
|
26
|
+
)
|
|
16
27
|
}
|
|
17
28
|
}
|
|
18
|
-
for (const key of ['bin'
|
|
29
|
+
for (const key of ['bin']) {
|
|
30
|
+
if (typeof packageJson[key] === 'object' && packageJson[key] != null) {
|
|
31
|
+
packageJson[key] = mapValues(packageJson[key], (path) =>
|
|
32
|
+
replaceDist(path, outputEsm ? '.mjs' : '.js')
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const key of ['directories']) {
|
|
19
38
|
if (typeof packageJson[key] === 'object' && packageJson[key] != null) {
|
|
20
39
|
packageJson[key] = mapValues(packageJson[key], replaceDist)
|
|
21
40
|
}
|