rolldown 1.3.0 → 1.3.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3009cd0582b4be54137b4f9773637b187d2b685b3361205f437d2a40901916b6
4
- data.tar.gz: e333babfcf9260b97704d4cbd256a6df85d71c7c8ac672e74b3ef2ef8ac03086
3
+ metadata.gz: 43287c36f20c0eea05d2581ab41eb7347df8f497310090adf6b5aa4633d915a0
4
+ data.tar.gz: 5ffc16fe573d48d188fbaee042dfe854655ffb7e11b73d60ce135c6cf2661510
5
5
  SHA512:
6
- metadata.gz: 7c68f331191d9b2f17c71b1f067789b95bdff472e7070c1b41fc441c3fd5b4d2db2d6f151d27e9769025aa85f256101a4040ba939715b30aaa2df291442e2e37
7
- data.tar.gz: 95c178319f535896c242409d47a17a075fec68837e52d0617dc2deb4a4875131ab69d7b3c5f80bd42b126e43370ae597f8fd4d8a189853c52118ff09063aebc7
6
+ metadata.gz: 2e3454bf63f2c1af58f6ca106d7e603d6e4156d84785aaf924e57b4fde2c0444f64e188455f2b311e5ed3f264f89671c62c0c711ecf949f71923c4d9ed291b2b
7
+ data.tar.gz: 7bc4aabbcfe6935a6f13734902cd11ff3b93f5f4ccab13a5eab6b0fdcf28d5bfd559180da65f4156895b12e81f0aa7a2be29234c990cf366c00007235ea30ecb
data/README.md CHANGED
@@ -95,7 +95,7 @@ Rolldown.build(
95
95
  )
96
96
  ```
97
97
 
98
- They mix freely with what is on disk. A module in memory can import an npm package or a relative file, and a file on disk can import a module in memory. A relative import out of a module in memory resolves against that module's own name, so give it a path-shaped one when it needs to reach real files next to it.
98
+ They mix freely with what is on disk. A module in memory can import an npm package or a relative file, and a file on disk can import a module in memory. A relative import out of a module in memory resolves against that module's own name, so give it a path-shaped one when it needs to reach real files next to it. From there it resolves the way an import from disk does, against `cwd`, so an import with no extension and a directory with an `index` file are both found.
99
99
 
100
100
  This exists so a generator can transform sources in Ruby first and bundle the result without writing anything out. There are no plugins, and no Ruby runs while the bundle does.
101
101
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rolldown
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.0.1"
5
5
  end
data/rust/src/modules.rs CHANGED
@@ -5,7 +5,7 @@ use std::path::{Component, Path, PathBuf};
5
5
  use arcstr::ArcStr;
6
6
  use rolldown_plugin::{
7
7
  HookLoadArgs, HookLoadOutput, HookLoadReturn, HookResolveIdArgs, HookResolveIdOutput, HookResolveIdReturn, HookUsage,
8
- Plugin, PluginContext, SharedLoadPluginContext,
8
+ Plugin, PluginContext, PluginContextResolveOptions, SharedLoadPluginContext,
9
9
  };
10
10
 
11
11
  #[derive(Debug)]
@@ -30,7 +30,7 @@ impl Plugin for VirtualModules {
30
30
  HookUsage::ResolveId | HookUsage::Load
31
31
  }
32
32
 
33
- async fn resolve_id(&self, _ctx: &PluginContext, args: &HookResolveIdArgs<'_>) -> HookResolveIdReturn {
33
+ async fn resolve_id(&self, ctx: &PluginContext, args: &HookResolveIdArgs<'_>) -> HookResolveIdReturn {
34
34
  if self.sources.contains_key(args.specifier) {
35
35
  return Ok(Some(HookResolveIdOutput {
36
36
  id: ArcStr::from(args.specifier),
@@ -50,12 +50,39 @@ impl Plugin for VirtualModules {
50
50
  return Ok(None);
51
51
  };
52
52
 
53
- let Some(resolved) = normalize(&directory.join(args.specifier)) else {
53
+ let joined = directory.join(args.specifier);
54
+
55
+ let Some(resolved) = normalize(&joined) else {
56
+ return Ok(None);
57
+ };
58
+
59
+ if self.sources.contains_key(&resolved) {
60
+ return Ok(Some(HookResolveIdOutput::from_id(resolved)));
61
+ }
62
+
63
+ let Some(absolute) = normalize(&ctx.cwd().join(joined)) else {
64
+ return Ok(None);
65
+ };
66
+
67
+ let options = PluginContextResolveOptions {
68
+ import_kind: args.kind,
69
+ skip_self: true,
70
+ custom: args.custom.clone(),
71
+ ..Default::default()
72
+ };
73
+
74
+ let Ok(on_disk) = ctx.resolve(&absolute, None, Some(options)).await? else {
54
75
  return Ok(None);
55
76
  };
56
77
 
57
78
  Ok(Some(HookResolveIdOutput {
58
- id: ArcStr::from(resolved),
79
+ id: on_disk.id.as_arc_str().clone(),
80
+ external: Some(on_disk.external),
81
+ normalize_external_id: on_disk.normalize_external_id,
82
+ side_effects: on_disk.side_effects,
83
+ package_json_path: on_disk
84
+ .package_json
85
+ .map(|package| package.realpath().to_string_lossy().into_owned()),
59
86
  ..Default::default()
60
87
  }))
61
88
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rolldown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Roth