Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom path mapping starting with # failing because exec interprets it as a comment #31

Open
skeithtan opened this issue Dec 11, 2024 · 0 comments · May be fixed by #32
Open

Custom path mapping starting with # failing because exec interprets it as a comment #31

skeithtan opened this issue Dec 11, 2024 · 0 comments · May be fixed by #32

Comments

@skeithtan
Copy link

I have a custom math mapping in deno.json.

The name of the mapping starts with a # character, e.g., #some-name.

When building in vite, this causes the build to fail:

vite v5.4.11 building for production...
✓ 62 modules transformed.
x Build failed in 591ms
error during build:
[commonjs--resolver] Cannot read properties of undefined (reading '0')
    at resolveDeno (file:///path/node_modules/.deno/@deno+vite-plugin@1.0.2/node_modules/@deno/vite-plugin/dist/resolver.js:34:32)

The stacktrace specifically references this line here:

const actualId = json.roots[0];

That's because the string passed to exec here looks like so:
deno info --json #some-name/some-path.ts

Since the name of the mapping starts with a # sign, this was interpreted as a comment, therefore only really running the command deno info --json which outputs something like so:

{
  "version": 1,
  "denoDir": "/REDACTED/Library/Caches/deno",
  "modulesCache": "/REDACTED/Library/Caches/deno/remote",
  "npmCache": "/REDACTED/Library/Caches/deno/npm",
  "typescriptCache": "/REDACTED/Library/Caches/deno/gen",
  "registryCache": "/REDACTED/Library/Caches/deno/registries",
  "originStorage": "/REDACTED/Library/Caches/deno/location_data",
  "webCacheStorage": "/REDACTED/deno_cache"
}

Which, when parsed, does not have a roots field, and therefore fails in this line.

@skeithtan skeithtan linked a pull request Dec 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant