Skip to content

feat: prepare supporting runtime#37

Merged
hyfdev merged 3 commits into
mainfrom
runtime-file
Oct 10, 2023
Merged

feat: prepare supporting runtime#37
hyfdev merged 3 commits into
mainfrom
runtime-file

Conversation

@underfin

@underfin underfin commented Oct 8, 2023

Copy link
Copy Markdown
Contributor

Description

related #35

Test Plan

no need.


pub entries: Vec<(Option<String>, ModuleId)>,
pub sorted_modules: Vec<ModuleId>,
pub symbols: Symbols,
pub runtime: ModuleId,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The runtime module put into modules of graph and use runtime to refrence it, but maybe is good to put it to runtime.

@underfin

underfin commented Oct 8, 2023

Copy link
Copy Markdown
Contributor Author

!bench

@github-actions

github-actions Bot commented Oct 8, 2023

Copy link
Copy Markdown
Contributor

Benchmark Results

group                            baseline                               pr
-----                            --------                               --
rolldown benchmark/threejs       1.00     65.9±4.87ms        ? ?/sec    1.02     67.0±8.51ms        ? ?/sec
rolldown benchmark/threejs10x    1.01   704.1±36.37ms        ? ?/sec    1.00   695.8±36.31ms        ? ?/sec

@hyfdev

hyfdev commented Oct 8, 2023

Copy link
Copy Markdown
Member

Would you mind holding this PR before #27 being merged? I need to apply some changes to this PR after #27.

@underfin

underfin commented Oct 8, 2023

Copy link
Copy Markdown
Contributor Author

ok

@hyfdev hyfdev changed the title feat: add runtime file to module graph feat: prepare supporting runtime Oct 10, 2023
tracing::trace!("process {:?}", self.path);
// load
let source = tokio::fs::read_to_string(self.path.as_ref()).await?;
let source = if RUNTIME_PATH == self.path.as_ref() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm intending to not include runtime module as the part of making module graph. In this way, we don't need to write such code.

Another way is to have a special ModuleTaskForRuntime to deal with the special logic of runtime module.

I haven't think through which way is better. Let's change it later.

@hyfdev
hyfdev merged commit cd4899f into main Oct 10, 2023
leegeunhyeok referenced this pull request in rollipop-dev/rolldown Jun 17, 2026
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
graphite-app Bot pushed a commit that referenced this pull request Jul 15, 2026
### Description

`crates/rolldown/src/runtime/index.js` is not part of the build, and hasn''t been for a long time. This PR deletes it.

The runtime module is assembled in [`runtime_module_task.rs`](https://github.com/rolldown/rolldown/blob/main/crates/rolldown/src/module_loader/runtime_module_task.rs#L33-L36) from exactly four `include_str!`ed files:

```rust
const RUNTIME_BASE_JS: &str = include_str!("../runtime/runtime-base.js");
const RUNTIME_TAIL_JS: &str = include_str!("../runtime/runtime-tail.js");
const RUNTIME_HEAD_NODE_JS: &str = include_str!("../runtime/runtime-head-node.js");
const RUNTIME_TAIL_NODE_JS: &str = include_str!("../runtime/runtime-tail-node.js");
```

`index.js` is not among them. Nothing else in the repo references it either — there''s no `build.rs` in the crate, and no path reference to it in Rust, JS, or `knip.jsonc`. Its only remaining coverage is incidental: the sibling `tsconfig.json` globs `./**/*`, so it gets type-checked and formatted alongside the files that actually ship.

### How it got here

It''s the original esbuild runtime port from #37. #375 added `runtime-without-comments.js` as the copy actually fed to the bundler; that file was renamed to `runtime-base.js` in #2919 and later split with `runtime-tail.js`. `index.js` was never wired back up — it survived as a copy that edits were hand-mirrored into.

### Why delete rather than leave it

The mirroring has fallen behind, so the file now actively misinforms:

| | `runtime-base.js` (ships) | `index.js` (dead) |
|---|---|---|
| `cb = null` release in `__commonJS` (#9067) | present | **missing** |
| `__exportAll` + `Symbol.toStringTag` | present | still the old `__export` |
| `__require` error text | rewritten to link the rolldown docs (in `runtime-tail.js`) | still esbuild''s "Dynamic require of …" |

Someone grepping for a runtime helper can land here and draw the wrong conclusion about what ships — the missing #9067 fix reads as a live memory leak. It isn''t, because the file is inert. Deleting it removes the trap and the ongoing cost of keeping a second copy in sync.

### Test Plan

Deletion only; no shipped output changes, so no snapshots move. `include_str!` resolves at compile time, so a stale reference would break the build:

- `cargo check -p rolldown --all-targets` — passes
- `tsc --noEmit -p crates/rolldown/src/runtime/tsconfig.json` — passes
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.

2 participants