Skip to content

Comments

feat: support PluginContext.load#2687

Merged
underfin merged 10 commits intomainfrom
plugin-load
Nov 12, 2024
Merged

feat: support PluginContext.load#2687
underfin merged 10 commits intomainfrom
plugin-load

Conversation

@underfin
Copy link
Contributor

@underfin underfin commented Nov 11, 2024

Description

Support PluginContext.load, ref https://rollupjs.org/plugin-development/#this-load. close #2355.

The pr using msg channel to hand extra modules need to load. Here need to use one channel to avoid #2687 (comment).

Here has a another way to do it. Using load_via_plugins, like resolve_id_via_plugins, but it need to a lot of change the relation crate dependencies and meet a cycle dependencies problem at moving create_ecma_view, it is difficult to resolve. try here at #2690.

The pr implements it as much as possible, but it also has a problem, consider some cases at here.

  • ModuleTables has not the module A, here only fetch it.
  • ModuleTables has module A and already fetched, here return already fetched result, using PluginContext#modules.
  • ModuleTables has module A but it is not fetched finished, here may lost result because here can't ensure the fetch time before the module task is finished. The case maybe happend because it is run at parallel. We could re-fetch it at the case, but it call the module-related hook again, It could be put as low priority to resolve.

@underfin underfin marked this pull request as draft November 11, 2024 07:09
@netlify
Copy link

netlify bot commented Nov 11, 2024

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit a02257b
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/6732cd661e4c3a0008cf486f

@github-actions
Copy link
Contributor

github-actions bot commented Nov 11, 2024

Benchmarks Rust

group                                                               pr                                     target
-----                                                               --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol                     1.00     64.3±1.60ms        ? ?/sec    1.01     64.9±1.24ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify              1.02     91.7±1.68ms        ? ?/sec    1.00     89.9±1.07ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify-sourcemap    1.01    106.5±1.16ms        ? ?/sec    1.00    105.7±0.98ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap           1.03     74.8±2.15ms        ? ?/sec    1.00     72.9±1.33ms        ? ?/sec
bundle/bundle@rome-ts                                               1.00    112.0±1.23ms        ? ?/sec    1.00    111.9±0.99ms        ? ?/sec
bundle/bundle@rome-ts-minify                                        1.00   233.6±17.89ms        ? ?/sec    1.04   242.1±11.56ms        ? ?/sec
bundle/bundle@rome-ts-minify-sourcemap                              1.02   287.4±25.48ms        ? ?/sec    1.00    282.4±8.61ms        ? ?/sec
bundle/bundle@rome-ts-sourcemap                                     1.00    128.1±1.84ms        ? ?/sec    1.00    127.5±1.93ms        ? ?/sec
bundle/bundle@threejs                                               1.03     39.4±1.11ms        ? ?/sec    1.00     38.2±0.75ms        ? ?/sec
bundle/bundle@threejs-minify                                        1.00    101.1±1.83ms        ? ?/sec    1.02    103.0±1.57ms        ? ?/sec
bundle/bundle@threejs-minify-sourcemap                              1.01    120.3±1.86ms        ? ?/sec    1.00    118.6±1.77ms        ? ?/sec
bundle/bundle@threejs-sourcemap                                     1.01     47.1±0.57ms        ? ?/sec    1.00     46.7±0.62ms        ? ?/sec
bundle/bundle@threejs10x                                            1.00    399.9±3.81ms        ? ?/sec    1.00    399.8±4.65ms        ? ?/sec
bundle/bundle@threejs10x-minify                                     1.00  1258.9±13.92ms        ? ?/sec    1.00   1264.0±9.20ms        ? ?/sec
bundle/bundle@threejs10x-minify-sourcemap                           1.00  1461.8±10.84ms        ? ?/sec    1.02  1492.7±12.67ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                                  1.01    467.1±5.53ms        ? ?/sec    1.00    462.8±8.26ms        ? ?/sec
remapping/remapping                                                 1.00     29.2±0.25ms        ? ?/sec    1.00     29.0±0.28ms        ? ?/sec
remapping/render-chunk-remapping                                    1.01     70.7±0.71ms        ? ?/sec    1.00     70.0±0.25ms        ? ?/sec
scan/scan@rome-ts                                                   1.01     91.0±0.89ms        ? ?/sec    1.00     90.2±0.72ms        ? ?/sec
scan/scan@threejs                                                   1.01     28.4±0.87ms        ? ?/sec    1.00     28.1±0.19ms        ? ?/sec
scan/scan@threejs10x                                                1.01    290.5±3.86ms        ? ?/sec    1.00    288.4±3.35ms        ? ?/sec

@underfin underfin marked this pull request as ready for review November 11, 2024 09:11
@hyf0
Copy link
Member

hyf0 commented Nov 12, 2024

Except above comments, others looks fine. Good job!

@underfin underfin added this pull request to the merge queue Nov 12, 2024
Merged via the queue into main with commit 6bf4a3f Nov 12, 2024
@underfin underfin deleted the plugin-load branch November 12, 2024 12:10
graphite-app bot pushed a commit that referenced this pull request Sep 16, 2025
The code for `this.load` waited for the `markModuleLoaded` callback to be called. But this should be able to simplify by using a future.
This PR refactors the code for `this.load` to wait for a future instead. This should also improve the perf a bit because we no longer have to call `markModuleLoaded` for each module.
I wonder if I'm missing something.

refs #4156, #2777, #2772, #2687
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PluginContext#load

2 participants