@jcoreio/toolchain 3.2.0 → 3.2.2
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.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "base JS build toolchain",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=16"
|
|
38
38
|
},
|
|
39
|
-
"packageManager": "pnpm@8.
|
|
39
|
+
"packageManager": "pnpm@8.11.0",
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"eslint": "*"
|
|
42
42
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const once = require('../../util/once.cjs')
|
|
2
|
+
const confirm = require('../../util/confirm.cjs')
|
|
3
|
+
const { toolchainConfig } = require('../../util/findUps.cjs')
|
|
4
|
+
|
|
5
|
+
module.exports = once(async () => {
|
|
6
|
+
if (toolchainConfig) {
|
|
7
|
+
if (typeof toolchainConfig.outputEsm === 'boolean') {
|
|
8
|
+
return toolchainConfig.outputEsm
|
|
9
|
+
}
|
|
10
|
+
if (Object.keys(toolchainConfig).length) {
|
|
11
|
+
return toolchainConfig.esmBabelEnv != null
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return await confirm({
|
|
15
|
+
type: 'confirm',
|
|
16
|
+
initial: true,
|
|
17
|
+
ifNotInteractive: true,
|
|
18
|
+
message: 'Output ESM in build?',
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -7,6 +7,7 @@ const isEmpty = require('lodash/isEmpty')
|
|
|
7
7
|
const pick = require('lodash/pick')
|
|
8
8
|
const Path = require('path')
|
|
9
9
|
const { toolchainConfig } = require('../../util/findUps.cjs')
|
|
10
|
+
const confirmOutputEsm = require('./confirmOutputEsm.cjs')
|
|
10
11
|
const confirm = require('../../util/confirm.cjs')
|
|
11
12
|
|
|
12
13
|
async function migrateProjectPackageJson() {
|
|
@@ -72,44 +73,47 @@ async function migrateProjectPackageJson() {
|
|
|
72
73
|
const hasIndex =
|
|
73
74
|
hasIndexTypes || (await fs.pathExists(Path.join('src', 'index.js')))
|
|
74
75
|
if (hasIndex) {
|
|
75
|
-
packageJson.main = 'index.js'
|
|
76
|
-
packageJson.module = 'index.mjs'
|
|
76
|
+
packageJson.main = 'dist/index.js'
|
|
77
|
+
packageJson.module = 'dist/index.mjs'
|
|
77
78
|
}
|
|
78
79
|
if (hasIndexTypes) {
|
|
79
|
-
packageJson.types = 'index.d.ts'
|
|
80
|
+
packageJson.types = 'dist/index.d.ts'
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
for (const dep of require('./migrateRemoveDevDeps.cjs')) {
|
|
83
84
|
delete devDependencies[dep]
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
if (!packageJson.exports && packageJson.main) {
|
|
88
|
+
const relativize = (p) => (p.startsWith('.') ? p : `./${p}`)
|
|
89
|
+
|
|
90
|
+
const dotStar = await confirm({
|
|
89
91
|
type: 'confirm',
|
|
90
92
|
initial: true,
|
|
91
93
|
ifNotInteractive: false,
|
|
92
94
|
message: 'Add ./* exports map to package.json?',
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
+
})
|
|
96
|
+
const outputEsm = await confirmOutputEsm()
|
|
95
97
|
packageJson.exports = {
|
|
96
98
|
'./package.json': './package.json',
|
|
97
|
-
|
|
99
|
+
'.': {
|
|
100
|
+
...(packageJson.types ? { types: relativize(packageJson.types) } : {}),
|
|
101
|
+
...(outputEsm !== false && packageJson.module
|
|
102
|
+
? { import: relativize(packageJson.module) }
|
|
103
|
+
: {}),
|
|
104
|
+
default: relativize(packageJson.main),
|
|
105
|
+
},
|
|
106
|
+
...(dotStar
|
|
98
107
|
? {
|
|
99
|
-
'
|
|
100
|
-
|
|
101
|
-
...(toolchainConfig.outputEsm !== false
|
|
102
|
-
? { import:
|
|
108
|
+
'./*': {
|
|
109
|
+
types: './*.d.ts',
|
|
110
|
+
...(toolchainConfig.outputEsm !== false
|
|
111
|
+
? { import: './*.mjs' }
|
|
103
112
|
: {}),
|
|
104
|
-
default:
|
|
113
|
+
default: './*.js',
|
|
105
114
|
},
|
|
106
115
|
}
|
|
107
116
|
: {}),
|
|
108
|
-
'./*': {
|
|
109
|
-
types: './*.d.ts',
|
|
110
|
-
...(toolchainConfig.outputEsm !== false ? { import: './*.mjs' } : {}),
|
|
111
|
-
default: './*.js',
|
|
112
|
-
},
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
|