@jcoreio/toolchain-esnext 5.5.4 → 5.5.6

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": "5.5.4",
3
+ "version": "5.5.6",
4
4
  "description": "ESNext JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,7 +32,7 @@
32
32
  "globals": "^16.0.0",
33
33
  "resolve": "^1.22.2",
34
34
  "resolve-bin": "^1.0.0",
35
- "@jcoreio/toolchain": "5.5.4"
35
+ "@jcoreio/toolchain": "5.5.6"
36
36
  },
37
37
  "toolchainManaged": {
38
38
  "dependencies": {
@@ -16,6 +16,7 @@ module.exports = [
16
16
  }
17
17
  : toolchainConfig.cjsBabelEnv || { forceAllTransforms: true }),
18
18
  modules: JCOREIO_TOOLCHAIN_ESM ? false : 'auto',
19
+ exclude: ['proposal-dynamic-import'],
19
20
  },
20
21
  ],
21
22
  ]
@@ -0,0 +1,31 @@
1
+ import path from 'path'
2
+ import { fileURLToPath } from 'url'
3
+ import { resolve, load as wrappedLoad } from 'babel-register-esm'
4
+
5
+ export { resolve }
6
+
7
+ export async function load(url, context, nextLoad) {
8
+ // some versions of node support --experimental-default-type, but it was removed in Node 23.
9
+ // Since we allow the project to omit `type` in `package.json` and transpile the same source
10
+ // code to CJS and ESM, we need to set the module type based upon the mode the toolchain is
11
+ // running in here for Node >=23.
12
+ if (context.format == null) {
13
+ const extension = path.extname(fileURLToPath(url))
14
+ if (
15
+ extension === '.js' ||
16
+ extension === '.jsx' ||
17
+ extension === '.ts' ||
18
+ extension === '.tsx'
19
+ ) {
20
+ return await wrappedLoad(
21
+ url,
22
+ {
23
+ ...context,
24
+ format: process.env.JCOREIO_TOOLCHAIN_ESM ? 'module' : 'commonjs',
25
+ },
26
+ nextLoad
27
+ )
28
+ }
29
+ }
30
+ return await wrappedLoad(url, context, nextLoad)
31
+ }
@@ -1,4 +1,4 @@
1
1
  const { register } = require('node:module')
2
2
  const { pathToFileURL } = require('node:url')
3
3
 
4
- register('babel-register-esm', pathToFileURL(__filename))
4
+ register('./babelRegisterEsmWrapper.mjs', pathToFileURL(__filename))