@jcoreio/toolchain-esnext 2.1.1 → 3.0.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-esnext",
3
- "version": "2.1.1",
3
+ "version": "3.0.0",
4
4
  "description": "ESNext JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,10 +32,10 @@
32
32
  "glob": "^7.2.0",
33
33
  "resolve": "^1.22.2",
34
34
  "resolve-bin": "^1.0.0",
35
- "@jcoreio/toolchain": "2.1.1"
35
+ "@jcoreio/toolchain": "3.0.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@jcoreio/toolchain": "2.1.1"
38
+ "@jcoreio/toolchain": "3.0.0"
39
39
  },
40
40
  "toolchainManaged": {
41
41
  "dependencies": {
@@ -1,43 +1,18 @@
1
1
  const glob = require('@jcoreio/toolchain/util/glob.cjs')
2
2
  const Path = require('path')
3
3
  const fs = require('@jcoreio/toolchain/util/projectFs.cjs')
4
- const { toolchainConfig } = require('@jcoreio/toolchain/util/findUps.cjs')
5
4
 
6
5
  module.exports = [
7
6
  [
8
7
  async function buildDistPackageJson(packageJson) {
9
8
  const files = await glob(Path.join('dist', '**', '*.{js,cjs,mjs,d.ts}'))
10
- const exportMap = { './package.json': './package.json' }
11
9
  let usesBabelRuntime = false
12
10
  for (const file of files) {
13
- const fileInDist = `./${Path.relative('dist', file)}`
14
- const key = fileInDist
15
- .replace(/(\.[^/.]*)*$/, '')
16
- .replace(/\/index$/, '')
17
- const forFile = exportMap[key] || (exportMap[key] = {})
18
- const condition = /\.d\.ts$/.test(file)
19
- ? 'types'
20
- : /\.c?js$/.test(file)
21
- ? 'require'
22
- : 'import'
23
- forFile[condition] = fileInDist
24
- usesBabelRuntime =
25
- usesBabelRuntime ||
26
- // this could return false positives in rare cases, but keeps the test simple
27
- (await fs.readFile(file)).includes('@babel/runtime')
28
- }
29
- if (toolchainConfig.outputEsm !== false) {
30
- if (!packageJson.exports) {
31
- packageJson.exports = exportMap
11
+ if ((await fs.readFile(file, 'utf8')).includes('@babel/runtime')) {
12
+ usesBabelRuntime = true
13
+ break
32
14
  }
33
15
  }
34
- const indexExport = exportMap['.']
35
- if (indexExport) {
36
- if (indexExport.require) packageJson.main = indexExport.require
37
- if (indexExport.import) packageJson.module = indexExport.import
38
- if (indexExport.types) packageJson.types = indexExport.types
39
- }
40
- packageJson.main = indexExport.require
41
16
  if (!usesBabelRuntime) {
42
17
  const { dependencies } = packageJson
43
18
  if (dependencies) delete dependencies['@babel/runtime']