@jcoreio/toolchain-esnext 2.0.3 → 2.1.1
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/buildDistPackageJson.cjs +5 -2
- package/plugins/compile.cjs +27 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jcoreio/toolchain-esnext",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
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.
|
|
35
|
+
"@jcoreio/toolchain": "2.1.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@jcoreio/toolchain": "2.
|
|
38
|
+
"@jcoreio/toolchain": "2.1.1"
|
|
39
39
|
},
|
|
40
40
|
"toolchainManaged": {
|
|
41
41
|
"dependencies": {
|
|
@@ -1,6 +1,7 @@
|
|
|
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')
|
|
4
5
|
|
|
5
6
|
module.exports = [
|
|
6
7
|
[
|
|
@@ -25,8 +26,10 @@ module.exports = [
|
|
|
25
26
|
// this could return false positives in rare cases, but keeps the test simple
|
|
26
27
|
(await fs.readFile(file)).includes('@babel/runtime')
|
|
27
28
|
}
|
|
28
|
-
if (
|
|
29
|
-
packageJson.exports
|
|
29
|
+
if (toolchainConfig.outputEsm !== false) {
|
|
30
|
+
if (!packageJson.exports) {
|
|
31
|
+
packageJson.exports = exportMap
|
|
32
|
+
}
|
|
30
33
|
}
|
|
31
34
|
const indexExport = exportMap['.']
|
|
32
35
|
if (indexExport) {
|
package/plugins/compile.cjs
CHANGED
|
@@ -22,38 +22,40 @@ module.exports = [
|
|
|
22
22
|
])
|
|
23
23
|
const jsFiles = await glob(path.join('dist', '**', '*.js'))
|
|
24
24
|
await resolveImportsCodemod(jsFiles)
|
|
25
|
-
if (toolchainConfig.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
if (toolchainConfig.outputEsm !== false) {
|
|
26
|
+
if (toolchainConfig.esWrapper) {
|
|
27
|
+
await Promise.all(
|
|
28
|
+
jsFiles.map((file) =>
|
|
29
|
+
fs.writeFile(
|
|
30
|
+
file.replace(/\.js$/, '.mjs'),
|
|
31
|
+
dedent`
|
|
31
32
|
export * from './${path.basename(file)}'
|
|
32
33
|
import root from './${path.basename(file)}'
|
|
33
34
|
export default root
|
|
34
35
|
|
|
35
36
|
`,
|
|
36
|
-
|
|
37
|
+
'utf8'
|
|
38
|
+
)
|
|
37
39
|
)
|
|
38
40
|
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
} else {
|
|
42
|
+
await execa(
|
|
43
|
+
'babel',
|
|
44
|
+
[
|
|
45
|
+
'src',
|
|
46
|
+
...(extensions.length
|
|
47
|
+
? ['--extensions', extensions.join(',')]
|
|
48
|
+
: []),
|
|
49
|
+
'--out-dir',
|
|
50
|
+
'dist',
|
|
51
|
+
'--out-file-extension',
|
|
52
|
+
'.mjs',
|
|
53
|
+
],
|
|
54
|
+
{ env: { ...process.env, JCOREIO_TOOLCHAIN_MJS: '1' } }
|
|
55
|
+
)
|
|
56
|
+
const mjsFiles = await glob(path.join('dist', '**', '*.mjs'))
|
|
57
|
+
await resolveImportsCodemod(mjsFiles)
|
|
58
|
+
}
|
|
57
59
|
}
|
|
58
60
|
},
|
|
59
61
|
{ insteadOf: '@jcoreio/toolchain' },
|