@jcoreio/toolchain 5.8.9 → 5.9.0-beta.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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const once = require('../../util/once.cjs')
|
|
2
|
+
const confirm = require('../../util/confirm.cjs')
|
|
3
|
+
const {
|
|
4
|
+
toolchainConfig,
|
|
5
|
+
toolchainConfigDeclared,
|
|
6
|
+
} = require('../../util/findUps.cjs')
|
|
7
|
+
|
|
8
|
+
module.exports = once(async () => {
|
|
9
|
+
if (toolchainConfig && toolchainConfigDeclared) {
|
|
10
|
+
if (typeof toolchainConfig.outputCjs === 'boolean') {
|
|
11
|
+
return toolchainConfig.outputCjs
|
|
12
|
+
}
|
|
13
|
+
return toolchainConfig.cjsBabelEnv != null
|
|
14
|
+
}
|
|
15
|
+
return await confirm({
|
|
16
|
+
type: 'confirm',
|
|
17
|
+
initial: true,
|
|
18
|
+
ifNotInteractive: true,
|
|
19
|
+
message: 'Output CJS in build?',
|
|
20
|
+
})
|
|
21
|
+
})
|
|
@@ -2,11 +2,13 @@ const semver = require('semver')
|
|
|
2
2
|
|
|
3
3
|
function migrateExportMap(
|
|
4
4
|
exportMap,
|
|
5
|
-
{ fromVersion = '0.0.0', outputEsm = true } = {}
|
|
5
|
+
{ fromVersion = '0.0.0', outputCjs = true, outputEsm = true } = {}
|
|
6
6
|
) {
|
|
7
7
|
if (
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
semver.lt(fromVersion || '0.0.0', '5.5.0') &&
|
|
9
|
+
exportMap &&
|
|
10
|
+
outputCjs !== false &&
|
|
11
|
+
outputEsm !== false
|
|
10
12
|
) {
|
|
11
13
|
function process(obj) {
|
|
12
14
|
if (typeof obj.types === 'string') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const {
|
|
2
|
-
toolchainConfig: { outputEsm },
|
|
2
|
+
toolchainConfig: { outputCjs, outputEsm },
|
|
3
3
|
toolchainManaged,
|
|
4
4
|
} = require('../../util/findUps.cjs')
|
|
5
5
|
const { name } = require('../../package.json')
|
|
@@ -10,6 +10,7 @@ const semver = require('semver')
|
|
|
10
10
|
const isEmpty = require('../../util/isEmpty.cjs')
|
|
11
11
|
const pick = require('../../util/pick.cjs')
|
|
12
12
|
const Path = require('path')
|
|
13
|
+
const confirmOutputCjs = require('./confirmOutputCjs.cjs')
|
|
13
14
|
const confirmOutputEsm = require('./confirmOutputEsm.cjs')
|
|
14
15
|
const confirm = require('../../util/confirm.cjs')
|
|
15
16
|
const unset = require('../../util/unset.cjs')
|
|
@@ -138,6 +139,7 @@ async function migrateProjectPackageJson({ fromVersion }) {
|
|
|
138
139
|
ifNotInteractive: false,
|
|
139
140
|
message: 'Add ./* exports map to package.json?',
|
|
140
141
|
})
|
|
142
|
+
const outputCjs = await confirmOutputCjs()
|
|
141
143
|
const outputEsm = await confirmOutputEsm()
|
|
142
144
|
packageJson.exports = {
|
|
143
145
|
'./package.json': './package.json',
|
|
@@ -145,19 +147,25 @@ async function migrateProjectPackageJson({ fromVersion }) {
|
|
|
145
147
|
...(packageJson.types ?
|
|
146
148
|
{ types: relativize(packageJson.types) }
|
|
147
149
|
: {}),
|
|
148
|
-
...(outputEsm !== false && packageJson.module ?
|
|
150
|
+
...(outputEsm !== false && outputCjs !== false && packageJson.module ?
|
|
149
151
|
{ import: relativize(packageJson.module) }
|
|
150
152
|
: {}),
|
|
151
|
-
default: relativize(
|
|
153
|
+
default: relativize(
|
|
154
|
+
outputCjs === false ? packageJson.module : packageJson.main
|
|
155
|
+
),
|
|
152
156
|
},
|
|
153
157
|
...(dotStar ?
|
|
154
158
|
{
|
|
155
159
|
'./*': {
|
|
156
160
|
types: {
|
|
157
|
-
...(outputEsm !== false
|
|
161
|
+
...(outputEsm !== false && outputCjs !== false ?
|
|
162
|
+
{ import: './*.d.mts' }
|
|
163
|
+
: {}),
|
|
158
164
|
default: './*.d.ts',
|
|
159
165
|
},
|
|
160
|
-
...(outputEsm !== false
|
|
166
|
+
...(outputEsm !== false && outputCjs !== false ?
|
|
167
|
+
{ import: './*.mjs' }
|
|
168
|
+
: {}),
|
|
161
169
|
default: './*.js',
|
|
162
170
|
},
|
|
163
171
|
}
|
|
@@ -166,7 +174,7 @@ async function migrateProjectPackageJson({ fromVersion }) {
|
|
|
166
174
|
}
|
|
167
175
|
}
|
|
168
176
|
|
|
169
|
-
migrateExportMap(packageJson.exports, { outputEsm, fromVersion })
|
|
177
|
+
migrateExportMap(packageJson.exports, { outputCjs, outputEsm, fromVersion })
|
|
170
178
|
|
|
171
179
|
merge(
|
|
172
180
|
packageJson,
|
package/util/configSchema.cjs
CHANGED
|
@@ -4,6 +4,7 @@ module.exports = z.object({
|
|
|
4
4
|
cjsBabelEnv: z.record(z.unknown()).optional(),
|
|
5
5
|
esmBabelEnv: z.record(z.unknown()).optional(),
|
|
6
6
|
esWrapper: z.boolean().optional(),
|
|
7
|
+
outputCjs: z.boolean().optional(),
|
|
7
8
|
outputEsm: z.boolean().optional(),
|
|
8
9
|
hasTypeScriptSources: z.boolean().optional(),
|
|
9
10
|
buildIgnore: z.array(z.string()).optional(),
|