@jcoreio/toolchain-esnext 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 +3 -3
- package/plugins/compile.cjs +23 -1
- package/plugins/getConfigFiles.cjs +16 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jcoreio/toolchain-esnext",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
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": "3.2.
|
|
35
|
+
"@jcoreio/toolchain": "3.2.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@jcoreio/toolchain": "3.2.
|
|
38
|
+
"@jcoreio/toolchain": "3.2.2"
|
|
39
39
|
},
|
|
40
40
|
"toolchainManaged": {
|
|
41
41
|
"dependencies": {
|
package/plugins/compile.cjs
CHANGED
|
@@ -3,7 +3,10 @@ const fs = require('@jcoreio/toolchain/util/projectFs.cjs')
|
|
|
3
3
|
const glob = require('@jcoreio/toolchain/util/glob.cjs')
|
|
4
4
|
const path = require('path')
|
|
5
5
|
const dedent = require('dedent-js')
|
|
6
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
toolchainConfig,
|
|
8
|
+
projectDir,
|
|
9
|
+
} = require('@jcoreio/toolchain/util/findUps.cjs')
|
|
7
10
|
const getPluginsArraySync = require('@jcoreio/toolchain/util/getPluginsArraySync.cjs')
|
|
8
11
|
const resolveImportsCodemod = require('../util/resolveImportsCodemod.cjs')
|
|
9
12
|
|
|
@@ -15,11 +18,30 @@ module.exports = [
|
|
|
15
18
|
await execa('babel', [
|
|
16
19
|
'src',
|
|
17
20
|
...(extensions.length ? ['--extensions', extensions.join(',')] : []),
|
|
21
|
+
...(extensions.includes('.ts') ? ['--ignore', '**/*.d.ts'] : []),
|
|
18
22
|
'--out-dir',
|
|
19
23
|
'dist',
|
|
20
24
|
'--out-file-extension',
|
|
21
25
|
'.js',
|
|
22
26
|
])
|
|
27
|
+
if (extensions.length) {
|
|
28
|
+
for (const ext of ['.js', '.mjs']) {
|
|
29
|
+
if (!extensions.includes(ext)) {
|
|
30
|
+
const srcFiles = await glob(path.join('**', '*' + ext), {
|
|
31
|
+
cwd: path.join(projectDir, 'src'),
|
|
32
|
+
})
|
|
33
|
+
for (const file of srcFiles) {
|
|
34
|
+
// eslint-disable-next-line no-console
|
|
35
|
+
console.error(
|
|
36
|
+
path.join('src', file),
|
|
37
|
+
'->',
|
|
38
|
+
path.join('dist', file)
|
|
39
|
+
)
|
|
40
|
+
await fs.copy(path.join('src', file), path.join('dist', file))
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
23
45
|
const jsFiles = await glob(path.join('dist', '**', '*.js'))
|
|
24
46
|
await resolveImportsCodemod(jsFiles)
|
|
25
47
|
if (toolchainConfig.outputEsm !== false) {
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
const { name } = require('../package.json')
|
|
2
|
+
const confirmOutputEsm = require('@jcoreio/toolchain/scripts/migrate/confirmOutputEsm.cjs')
|
|
2
3
|
const dedent = require('dedent-js')
|
|
3
4
|
|
|
4
5
|
module.exports = [
|
|
5
6
|
async function getConfigFiles() {
|
|
6
7
|
return {
|
|
7
|
-
'toolchain.config.cjs':
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
'toolchain.config.cjs': async (existing) => {
|
|
9
|
+
if (existing) return existing
|
|
10
|
+
const outputEsm = await confirmOutputEsm()
|
|
11
|
+
return dedent`
|
|
12
|
+
/* eslint-env node, es2018 */
|
|
13
|
+
module.exports = {
|
|
14
|
+
cjsBabelEnv: { forceAllTransforms: true },
|
|
15
|
+
${
|
|
16
|
+
outputEsm
|
|
17
|
+
? `esmBabelEnv: { targets: { node: 16 } }`
|
|
18
|
+
: `outputEsm: false`
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
},
|
|
14
23
|
'.babelrc.cjs': dedent`
|
|
15
24
|
/* eslint-env node, es2018 */
|
|
16
25
|
module.exports = function (api) {
|