@jcoreio/toolchain 5.9.0-beta.2 → 5.9.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcoreio/toolchain",
3
- "version": "5.9.0-beta.2",
3
+ "version": "5.9.0",
4
4
  "description": "base JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,19 +14,27 @@ module.exports = [
14
14
  return path
15
15
  }
16
16
 
17
- const dtsExtension = packageJson.type === 'module' ? '.d.cts' : '.d.ts'
18
- const cjsExtension = packageJson.type === 'module' ? '.cjs' : '.js'
19
- const esmExtension = packageJson.type === 'module' ? '.js' : '.mjs'
17
+ const isDual =
18
+ toolchainConfig.outputCjs !== false && toolchainConfig.outputEsm !== false
19
+ const dtsExtension =
20
+ isDual && packageJson.type === 'module' ? '.d.cts' : '.d.ts'
21
+ const cjsExtension =
22
+ isDual && packageJson.type === 'module' ? '.cjs' : '.js'
23
+ const esmExtension =
24
+ isDual && packageJson.type !== 'module' ? '.mjs' : '.js'
20
25
 
21
26
  for (const key of ['main', 'module', 'browser', 'types', 'bin', 'types']) {
22
27
  if (typeof packageJson[key] === 'string') {
23
28
  packageJson[key] = replaceDist(
24
29
  packageJson[key],
25
- key === 'module' ? esmExtension
26
- : key === 'main' ? cjsExtension
27
- : key === 'types' ? dtsExtension
28
- : outputEsm ? esmExtension
29
- : cjsExtension
30
+ isDual ?
31
+ key === 'module' ? esmExtension
32
+ : key === 'main' ? cjsExtension
33
+ : key === 'types' ? dtsExtension
34
+ : outputEsm ? esmExtension
35
+ : cjsExtension
36
+ : key === 'types' ? '.d.ts'
37
+ : '.js'
30
38
  )
31
39
  }
32
40
  }