Skip to content

refactor: update for deno_graph handling redirects #548

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

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:
cargo clippy --all-targets --locked -- -D clippy::all
deno lint --ignore=src/html,benches/fixtures,target/

- name: Tailwind Check
run: |
deno task tailwind
git diff --exit-code
# - name: Tailwind Check
# run: |
# deno task tailwind
# git diff --exit-code
Copy link
Member Author

Choose a reason for hiding this comment

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


- name: Build
run: deno task build && cargo build --locked --all-targets
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/target
/js/deno_doc_wasm_bg.wasm
/js/deno_doc_wasm.generated.d.ts
/js/deno_doc_wasm.generated.js
/js/LICENSE
.vscode
Expand Down
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/denoland/deno_doc"
members = ["lib"]

[workspace.dependencies]
deno_graph = { version = "0.72.0", default-features = false, features = ["symbols"] }
deno_graph = { version = "0.73.1", default-features = false, features = ["symbols"] }
import_map = "0.19.0"
serde = { version = "1.0.140", features = ["derive"] }

Expand Down
4 changes: 2 additions & 2 deletions benches/doc_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ async fn parse_with_reexports() -> Vec<DocNode> {
content: source.as_str(),
},
)];
let mut memory_loader = MemoryLoader::new(sources, vec![]);
let memory_loader = MemoryLoader::new(sources, vec![]);
let root = ModuleSpecifier::parse("file:///test/fixtures/deno.d.ts").unwrap();

let analyzer = CapturingModuleAnalyzer::default();
let mut graph = ModuleGraph::new(GraphKind::TypesOnly);
graph
.build(
vec![root.clone()],
&mut memory_loader,
&memory_loader,
BuildOptions {
module_analyzer: &analyzer,
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion build_css.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from "https://deno.land/x/dax@0.36.0/mod.ts";
import $ from "jsr:@david/dax@0.40";
import browserslist from "npm:browserslist@4.22.2";
import { browserslistToTargets, transform } from "npm:lightningcss";

Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"lock": false,
"tasks": {
"build": "cp LICENSE js/LICENSE && deno run -A https://deno.land/x/wasmbuild@0.15.4/main.ts --project deno_doc_wasm --out js",
"build": "cp LICENSE js/LICENSE && deno run -A jsr:@deno/wasmbuild@0.17.1 --project deno_doc_wasm --out js",
"test": "deno test --allow-read --allow-net",
"tailwind": "deno run -A build_css.ts",
"gen_html": "deno task tailwind && cargo run --example ddoc --features=html -- --name \"std HTTP and Assert\" --html ../deno_std/http/mod.ts ../deno_std/assert/mod.ts ../deno_std/collections/mod.ts --output generated_docs/ --main_entrypoint ../deno_std/assert/mod.ts",
Expand Down
6 changes: 3 additions & 3 deletions examples/ddoc/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct SourceFileLoader {}

impl Loader for SourceFileLoader {
fn load(
&mut self,
&self,
specifier: &ModuleSpecifier,
_options: deno_graph::source::LoadOptions,
) -> LoadFuture {
Expand Down Expand Up @@ -104,13 +104,13 @@ async fn run() -> anyhow::Result<()> {
.unwrap()
})
.collect();
let mut loader = SourceFileLoader {};
let loader = SourceFileLoader {};
let analyzer = CapturingModuleAnalyzer::default();
let mut graph = ModuleGraph::new(GraphKind::TypesOnly);
graph
.build(
source_files.clone(),
&mut loader,
&loader,
BuildOptions {
module_analyzer: &analyzer,
..Default::default()
Expand Down
13 changes: 4 additions & 9 deletions js/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@

import { instantiate } from "./deno_doc_wasm.generated.js";
import type { DocNode } from "./types.d.ts";
import { createCache } from "https://deno.land/x/deno_cache@0.7.1/mod.ts";
import type {
CacheSetting,
LoadResponse,
} from "https://deno.land/x/deno_graph@0.66.0/mod.ts";
import { createCache } from "jsr:@deno/cache-dir@0.8";
import type { CacheSetting, LoadResponse } from "jsr:@deno/graph@0.73";

export type {
CacheSetting,
LoadResponse,
} from "https://deno.land/x/deno_graph@0.66.0/mod.ts";
export type { CacheSetting, LoadResponse } from "jsr:@deno/graph@0.73";

const encoder = new TextEncoder();

Expand Down Expand Up @@ -53,6 +47,7 @@ export interface DocOptions {
specifier: string,
isDynamic?: boolean,
cacheSetting?: CacheSetting,
checksum?: string,
): Promise<LoadResponse | undefined>;
/** An optional callback that allows the default resolution logic of the
* module graph to be "overridden". This is intended to allow items like an
Expand Down
14 changes: 5 additions & 9 deletions js/test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

import {
assert,
assertEquals,
assertThrowsAsync,
} from "https://deno.land/std@0.104.0/testing/asserts.ts";
import { assert, assertEquals, assertRejects } from "jsr:@std/assert@0.223";
import { doc } from "./mod.ts";

Deno.test({
Expand Down Expand Up @@ -84,8 +80,8 @@ Deno.test({
name: "doc() - missing specifier",
// TODO(@kitsonk) - remove when new deno_graph crate published
sanitizeResources: false,
fn() {
return assertThrowsAsync(
async fn() {
await assertRejects(
async () => {
await doc("https://deno.land/x/bad.ts");
},
Expand All @@ -97,8 +93,8 @@ Deno.test({

Deno.test({
name: "doc() - bad specifier",
fn() {
return assertThrowsAsync(
async fn() {
await assertRejects(
async () => {
await doc("./bad.ts");
},
Expand Down
6 changes: 3 additions & 3 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import_map.workspace = true
serde.workspace = true

console_error_panic_hook = "0.1.7"
js-sys = "=0.3.66"
js-sys = "=0.3.69"
serde-wasm-bindgen = "=0.5.0"
wasm-bindgen = "=0.2.89"
wasm-bindgen-futures = "=0.4.39"
wasm-bindgen = "=0.2.92"
wasm-bindgen-futures = "=0.4.42"

[dev-dependencies]
pretty_assertions = "1.0.0"
4 changes: 1 addition & 3 deletions lib/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// https://github.com/rustwasm/wasm-bindgen/issues/2774
#![allow(clippy::unused_unit)]

use anyhow::anyhow;
use anyhow::Context;
Expand Down Expand Up @@ -46,7 +44,7 @@ impl JsLoader {

impl Loader for JsLoader {
fn load(
&mut self,
&self,
specifier: &ModuleSpecifier,
options: LoadOptions,
) -> LoadFuture {
Expand Down
12 changes: 6 additions & 6 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ pub(crate) async fn setup<S: AsRef<str> + Copy>(
)
})
.collect();
let mut memory_loader = MemoryLoader::new(sources, vec![]);
let memory_loader = MemoryLoader::new(sources, vec![]);
let root = ModuleSpecifier::parse(root.as_ref()).unwrap();
let analyzer = create_analyzer();
let mut graph = ModuleGraph::new(GraphKind::TypesOnly);
graph
.build(
vec![root.clone()],
&mut memory_loader,
&memory_loader,
BuildOptions {
module_analyzer: &analyzer,
..Default::default()
Expand All @@ -64,14 +64,14 @@ async fn content_type_handling() {
}"#,
},
)];
let mut memory_loader = MemoryLoader::new(sources, vec![]);
let memory_loader = MemoryLoader::new(sources, vec![]);
let root = ModuleSpecifier::parse("https://example.com/a").unwrap();
let analyzer = create_analyzer();
let mut graph = ModuleGraph::new(GraphKind::TypesOnly);
graph
.build(
vec![root.clone()],
&mut memory_loader,
&memory_loader,
BuildOptions {
module_analyzer: &analyzer,
..Default::default()
Expand Down Expand Up @@ -111,14 +111,14 @@ async fn types_header_handling() {
},
),
];
let mut memory_loader = MemoryLoader::new(sources, vec![]);
let memory_loader = MemoryLoader::new(sources, vec![]);
let root = ModuleSpecifier::parse("https://example.com/a.js").unwrap();
let analyzer = create_analyzer();
let mut graph = ModuleGraph::new(GraphKind::TypesOnly);
graph
.build(
vec![root.clone()],
&mut memory_loader,
&memory_loader,
BuildOptions {
module_analyzer: &analyzer,
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl TestBuilder {
graph
.build(
roots.clone(),
&mut self.loader,
&self.loader,
BuildOptions {
module_analyzer: &analyzer,
..Default::default()
Expand Down
6 changes: 3 additions & 3 deletions tests/html_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct SourceFileLoader {}

impl Loader for SourceFileLoader {
fn load(
&mut self,
&self,
specifier: &ModuleSpecifier,
_options: LoadOptions,
) -> LoadFuture {
Expand Down Expand Up @@ -93,13 +93,13 @@ async fn get_files(subpath: &str) -> IndexMap<ModuleSpecifier, Vec<DocNode>> {
})
.collect();

let mut loader = SourceFileLoader {};
let loader = SourceFileLoader {};
let analyzer = CapturingModuleAnalyzer::default();
let mut graph = ModuleGraph::new(GraphKind::TypesOnly);
graph
.build(
source_files.clone(),
&mut loader,
&loader,
BuildOptions {
module_analyzer: &analyzer,
..Default::default()
Expand Down
Loading