@jcoreio/toolchain-esnext 5.8.1 → 5.8.3

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.8.1",
3
+ "version": "5.8.3",
4
4
  "description": "ESNext JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "resolve": "^1.22.2",
34
34
  "resolve-bin": "^1.0.0",
35
35
  "semver": "^7.5.3",
36
- "@jcoreio/toolchain": "5.8.1"
36
+ "@jcoreio/toolchain": "5.8.3"
37
37
  },
38
38
  "toolchainManaged": {
39
39
  "dependencies": {
@@ -8,15 +8,23 @@ const projectDirPrefix = pathToFileURL(projectDir) + '/'
8
8
 
9
9
  export async function resolve(specifier, context, nextResolve) {
10
10
  if (
11
- specifier.startsWith('.') &&
12
- context.parentURL.startsWith('file:') &&
13
- !context.parentURL.includes('/node_modules/')
11
+ specifier.startsWith(projectDirPrefix) ||
12
+ (specifier.startsWith('.') &&
13
+ context.parentURL.startsWith('file:') &&
14
+ !context.parentURL.includes('/node_modules/'))
14
15
  ) {
15
- const basedir = path.dirname(fileURLToPath(context.parentURL))
16
+ const basedir =
17
+ context.parentURL ?
18
+ path.dirname(fileURLToPath(context.parentURL))
19
+ : process.cwd()
20
+ if (!specifier.startsWith('.')) {
21
+ specifier = path.relative(basedir, fileURLToPath(specifier))
22
+ if (!specifier.startsWith('.')) specifier = `./${specifier}`
23
+ }
16
24
  const altTypeResolved = resolveAltType(specifier, basedir)
17
25
  if (altTypeResolved) {
18
26
  return {
19
- url: new URL(altTypeResolved, context.parentURL).toString(),
27
+ url: pathToFileURL(path.resolve(basedir, altTypeResolved)),
20
28
  shortCircuit: true,
21
29
  format:
22
30
  process.env.JCOREIO_TOOLCHAIN_CJS ? 'commonjs'
@@ -34,14 +42,14 @@ export async function load(url, context, nextLoad) {
34
42
  }
35
43
  const extension = path.extname(url)
36
44
  if (
37
- process.env.JCOREIO_TOOLCHAIN_ESM &&
45
+ (process.env.JCOREIO_TOOLCHAIN_ESM || extension.startsWith('.m')) &&
38
46
  url.startsWith(projectDirPrefix) &&
39
47
  (!extension || /\.m?[jt]sx?$/i.test(extension))
40
48
  ) {
41
49
  context = { ...context, format: 'module' }
42
50
  }
43
51
  if (
44
- process.env.JCOREIO_TOOLCHAIN_CJS &&
52
+ (process.env.JCOREIO_TOOLCHAIN_CJS || extension.startsWith('.c')) &&
45
53
  url.startsWith(projectDirPrefix) &&
46
54
  (!extension || /\.c?[jt]sx?$/i.test(extension))
47
55
  ) {