@jcoreio/toolchain-typescript 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-typescript",
3
- "version": "5.9.0-beta.2",
3
+ "version": "5.9.0",
4
4
  "description": "TypeScript JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  "eslint": "^9.18.0",
22
22
  "json5": "^2.2.1",
23
23
  "typescript-eslint": "^8.29.0",
24
- "@jcoreio/toolchain": "5.9.0-beta.2",
25
- "@jcoreio/toolchain-esnext": "5.9.0-beta.2"
24
+ "@jcoreio/toolchain": "5.9.0",
25
+ "@jcoreio/toolchain-esnext": "5.9.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "typescript": "^5.1.0"
@@ -19,6 +19,7 @@ module.exports = [
19
19
  ...(toolchainConfig.sourceMaps ? ['--declarationMap'] : []),
20
20
  ])
21
21
  }
22
+
22
23
  const dtsFiles = await glob(Path.join('dist', '**', '*.d.ts'))
23
24
  await Promise.all(
24
25
  dtsFiles.map(async (src) => {
@@ -26,9 +27,14 @@ module.exports = [
26
27
  /\.d\.ts$/,
27
28
  packageJson.type === 'module' ? '.d.cts' : '.d.mts'
28
29
  )
29
- if (await fs.pathExists(dest)) return
30
- // eslint-disable-next-line no-console
31
- console.error(src, '->', dest)
30
+ if (
31
+ toolchainConfig.outputCjs !== false &&
32
+ toolchainConfig.outputEsm !== false
33
+ ) {
34
+ if (await fs.pathExists(dest)) return
35
+ // eslint-disable-next-line no-console
36
+ console.error(src, '->', dest)
37
+ }
32
38
  const content = await fs.readFile(src, 'utf8')
33
39
  const parserOpts = {
34
40
  sourceType: 'unambiguous',
@@ -59,76 +65,80 @@ module.exports = [
59
65
  ],
60
66
  }
61
67
  const [cts, mts] = await Promise.all([
62
- babel.transformAsync(content, {
63
- filename: src,
64
- babelrc: false,
65
- sourceMaps: true,
66
- parserOpts,
67
- plugins: [
68
- [
69
- '@jcoreio/toolchain-esnext/util/babelPluginResolveImports.cjs',
70
- {
71
- outputExtension:
72
- packageJson.type === 'module' ? '.cjs' : '.js',
68
+ toolchainConfig.outputCjs !== false &&
69
+ babel.transformAsync(content, {
70
+ filename: src,
71
+ babelrc: false,
72
+ sourceMaps: true,
73
+ parserOpts,
74
+ plugins: [
75
+ [
76
+ '@jcoreio/toolchain-esnext/util/babelPluginResolveImports.cjs',
77
+ {
78
+ outputExtension:
79
+ packageJson.type === 'module' ? '.cjs' : '.js',
80
+ },
81
+ ],
82
+ function ({ types: t }) {
83
+ return {
84
+ visitor: {
85
+ ExportDefaultDeclaration(path) {
86
+ const { declaration } = path.node
87
+ if (declaration.type === 'Identifier') {
88
+ path.replaceWith(t.tsExportAssignment(declaration))
89
+ } else if (
90
+ declaration.id &&
91
+ declaration.id.type === 'Identifier'
92
+ ) {
93
+ path.replaceWithMultiple([
94
+ Object.assign(declaration, { declare: true }),
95
+ t.tsExportAssignment(
96
+ t.identifier(declaration.id.name)
97
+ ),
98
+ ])
99
+ }
100
+ },
101
+ },
102
+ }
73
103
  },
74
104
  ],
75
- function ({ types: t }) {
76
- return {
77
- visitor: {
78
- ExportDefaultDeclaration(path) {
79
- const { declaration } = path.node
80
- if (declaration.type === 'Identifier') {
81
- path.replaceWith(t.tsExportAssignment(declaration))
82
- } else if (
83
- declaration.id &&
84
- declaration.id.type === 'Identifier'
85
- ) {
86
- path.replaceWithMultiple([
87
- Object.assign(declaration, { declare: true }),
88
- t.tsExportAssignment(
89
- t.identifier(declaration.id.name)
90
- ),
91
- ])
92
- }
93
- },
105
+ }),
106
+ toolchainConfig.outputEsm !== false &&
107
+ (await babel.transformAsync(content, {
108
+ filename: src,
109
+ babelrc: false,
110
+ sourceMaps: true,
111
+ parserOpts,
112
+ plugins: [
113
+ [
114
+ '@jcoreio/toolchain-esnext/util/babelPluginResolveImports.cjs',
115
+ {
116
+ outputExtension:
117
+ packageJson.type === 'module' ? '.js' : '.mjs',
94
118
  },
95
- }
96
- },
97
- ],
98
- }),
99
- await babel.transformAsync(content, {
100
- filename: src,
101
- babelrc: false,
102
- sourceMaps: true,
103
- parserOpts,
104
- plugins: [
105
- [
106
- '@jcoreio/toolchain-esnext/util/babelPluginResolveImports.cjs',
107
- {
108
- outputExtension:
109
- packageJson.type === 'module' ? '.js' : '.mjs',
110
- },
119
+ ],
111
120
  ],
112
- ],
113
- }),
121
+ })),
114
122
  ])
115
123
  const ctsFile = packageJson.type === 'module' ? dest : src
116
124
  const mtsFile = packageJson.type === 'module' ? src : dest
117
- cts.map.file = Path.basename(ctsFile)
118
- mts.map.file = Path.basename(mtsFile)
125
+ if (cts) cts.map.file = Path.basename(ctsFile)
126
+ if (mts) mts.map.file = Path.basename(mtsFile)
119
127
  await Promise.all([
120
- fs.writeFile(
121
- ctsFile,
122
- `${cts.code}\n//# sourceMappingURL=${Path.basename(ctsFile)}.map`,
123
- 'utf8'
124
- ),
125
- fs.writeJson(`${ctsFile}.map`, cts.map),
126
- fs.writeFile(
127
- mtsFile,
128
- `${mts.code}\n//# sourceMappingURL=${Path.basename(mtsFile)}.map`,
129
- 'utf8'
130
- ),
131
- fs.writeJson(`${mtsFile}.map`, mts.map),
128
+ cts &&
129
+ fs.writeFile(
130
+ ctsFile,
131
+ `${cts.code}\n//# sourceMappingURL=${Path.basename(ctsFile)}.map`,
132
+ 'utf8'
133
+ ),
134
+ cts && fs.writeJson(`${ctsFile}.map`, cts.map),
135
+ mts &&
136
+ fs.writeFile(
137
+ mtsFile,
138
+ `${mts.code}\n//# sourceMappingURL=${Path.basename(mtsFile)}.map`,
139
+ 'utf8'
140
+ ),
141
+ mts && fs.writeJson(`${mtsFile}.map`, mts.map),
132
142
  ])
133
143
  })
134
144
  )
@@ -1,10 +1,20 @@
1
1
  const execa = require('@jcoreio/toolchain/util/execa.cjs')
2
+ const { toolchainConfig } = require('@jcoreio/toolchain/util/findUps.cjs')
2
3
 
3
4
  module.exports = [
4
5
  async function smokeTestBuild() {
5
6
  await execa(
6
7
  'pnpm',
7
- ['--package=@arethetypeswrong/cli', 'dlx', 'attw', '--pack', '.'],
8
+ [
9
+ '--package=@arethetypeswrong/cli',
10
+ 'dlx',
11
+ 'attw',
12
+ '--pack',
13
+ '.',
14
+ ...(toolchainConfig.outputCjs === false ?
15
+ ['--profile', 'esm-only']
16
+ : []),
17
+ ],
8
18
  { cwd: 'dist' }
9
19
  )
10
20
  },