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

fix(unstable): various resolution bugs for npm: specifiers #15546

Merged
merged 39 commits into from
Aug 24, 2022

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Aug 22, 2022

  1. cargo run -- run -A --unstable npm:vite build --debug
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.24.3
Args: ["../deno/target/debug/deno", "run", "-A", "--unstable", "npm:vite", "build", "--debug"]

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: could not find npm package 'source-map-support' referenced by '[email protected]'', ext/node/resolution.rs:595:6
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

  1. cargo run -- run -A --unstable npm:vite@2 build --debug
error getting response  https://registry.npmjs.org/ Err(
    Error("missing field `name`", line: 1, column: 470),
)
error preparing Error {
    context: "Error getting response at https://registry.npmjs.org/",
    source: Error("missing field `name`", line: 1, column: 470),
}
failed to load config from /Users/ib/dev/my-vue-app/vite.config.js
error during build:
TypeError: Error getting response at https://registry.npmjs.org/
    at async loadConfigFromFile (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/chunks/dep-689425f3.js:61925:31)
    at async resolveConfig (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/chunks/dep-689425f3.js:61456:28)
    at async doBuild (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/chunks/dep-689425f3.js:41564:20)
    at async build (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/chunks/dep-689425f3.js:41552:16)
    at async CAC.<anonymous> (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/cli.js:738:9)

error preparing CustomError {
    class: "TypeError",
    message: "Relative import path \"@vitejs/plugin-vue\" not prefixed with / or ./ or ../\n    at file:https:///Users/ib/dev/my-vue-app/vite.config.js?t=1661250685827:2:17",
}
failed to load config from /Users/ib/dev/my-vue-app/vite.config.js
error during build:
TypeError: Relative import path "@vitejs/plugin-vue" not prefixed with / or ./ or ../
    at file:https:///Users/ib/dev/my-vue-app/vite.config.js?t=1661250685827:2:17
    at async loadConfigFromFile (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/chunks/dep-689425f3.js:61925:31)
    at async resolveConfig (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/chunks/dep-689425f3.js:61456:28)
    at async doBuild (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/chunks/dep-689425f3.js:41564:20)
    at async build (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/chunks/dep-689425f3.js:41552:16)
    at async CAC.<anonymous> (file:https:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/vite/2.9.15/dist/node/cli.js:738:9)

@bartlomieju
Copy link
Member Author

There should be assertions verifying that name is not an empty string.

@bartlomieju
Copy link
Member Author

cargo run -- run -A --unstable npm:prisma --help doesn't print anything. Adding console log into binary entry point is never printed which suggests that the code is never executed.

@bartlomieju
Copy link
Member Author

No 1. is now addressed, but running it again yields another error:

error: Uncaught (in promise) TypeError: Loading unprepared module: https://deno.land/[email protected]/node/module.ts

@bartlomieju
Copy link
Member Author

cargo run -- run -A --unstable npm:prisma --help doesn't print anything. Adding console log into binary entry point is never printed which suggests that the code is never executed.

This is now fixed as well

cli/module_loader.rs Outdated Show resolved Hide resolved
// Trying to import a devDependency should result in an error
await import("xo");
} catch (e) {
console.error("devDependency import failed:", e);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use better error message instead of Relative import path "xo" is not prefix with /, ./ or ../

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will open a PR with this change later.

@bartlomieju bartlomieju changed the title [WIP] fix: various resolution bugs for npm: specifiers fix: various resolution bugs for npm: specifiers Aug 23, 2022
cli/npm/resolution.rs Outdated Show resolved Hide resolved
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I think we should move referrer_package.dependencies.get to be first instead of last in that one method.

cli/module_loader.rs Show resolved Hide resolved
// Trying to import a devDependency should result in an error
await import("xo");
} catch (e) {
console.error("devDependency import failed:", e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will open a PR with this change later.

@bartlomieju bartlomieju changed the title fix: various resolution bugs for npm: specifiers fix(unstable): various resolution bugs for npm: specifiers Aug 24, 2022
@bartlomieju bartlomieju merged commit 5268fa0 into denoland:main Aug 24, 2022
@bartlomieju bartlomieju deleted the fix_vite_problems branch August 24, 2022 12:54
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 this pull request may close these issues.

None yet

2 participants