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

feat: basic commonjs support #38

Merged
merged 9 commits into from
Oct 11, 2023
Merged

feat: basic commonjs support #38

merged 9 commits into from
Oct 11, 2023

Conversation

underfin
Copy link
Contributor

@underfin underfin commented Oct 9, 2023

Description

related #36

Test Plan

Add basic.


@underfin underfin changed the title wip: basic commonjs support rename: basic commonjs support Oct 11, 2023
@underfin underfin changed the title rename: basic commonjs support feat: basic commonjs support Oct 11, 2023
crates/rolldown/src/bundler/visitors/mod.rs Outdated Show resolved Hide resolved
crates/rolldown/src/bundler/runtime/mod.rs Outdated Show resolved Hide resolved
@underfin underfin merged commit d40c919 into main Oct 11, 2023
3 checks passed
@underfin underfin deleted the commonjs branch October 11, 2023 08:41
@underfin
Copy link
Contributor Author

!bench

@github-actions
Copy link

Benchmark Results

group                            baseline                               pr
-----                            --------                               --
rolldown benchmark/threejs       1.00     61.6±3.41ms        ? ?/sec    1.03     63.7±7.44ms        ? ?/sec
rolldown benchmark/threejs10x    1.03   621.7±38.18ms        ? ?/sec    1.00   604.4±16.94ms        ? ?/sec

@@ -25,7 +25,8 @@ pub struct ScanResult {
pub import_records: IndexVec<ImportRecordId, ImportRecord>,
pub star_exports: Vec<ImportRecordId>,
pub export_default_symbol_id: Option<SymbolId>,
pub dynamic_imports: FxHashMap<Span, ImportRecordId>,
pub imports: FxHashMap<Span, ImportRecordId>,
pub module_resolution: Option<ModuleResolution>,
Copy link
Member

Choose a reason for hiding this comment

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

What's ModuleResolution?

Looking into the code, I thought it was marking a module whether is cjs or esm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Member

Choose a reason for hiding this comment

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

I think it could be replaced with module_type that you gonna to add in #56.

fn set_module_resolution(&mut self, module_resolution: ModuleResolution) {
if let Some(resolution) = &self.result.module_resolution {
if resolution != &module_resolution {
// TODO shouldn't mix esm syntax and cjs syntax
Copy link
Member

Choose a reason for hiding this comment

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

Is mix esm syntax and cjs syntax not allowed or not implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remember it shouldn't support rolldown at previous rolldown meetings

Copy link
Member

@hyf0 hyf0 Oct 15, 2023

Choose a reason for hiding this comment

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

As I remember correctly, the meeting said it should be supported, but it could be enable or disable in module level. https://github.com/rolldown-rs/meeting-notes/blob/3fe04946dd858b4f5844763e0f476318b17d7854/09-18-2023.md?plain=1#L30

.get_symbol_final_name(symbol)
.cloned()
.unwrap_or_else(|| name.into())
// .expect(&format!("runtime symbol {name} not found"))
Copy link
Member

@hyf0 hyf0 Oct 15, 2023

Choose a reason for hiding this comment

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

Why this was comment out? panic should be expected here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because runtime symbol deconfict is not implemented.

Copy link
Member

Choose a reason for hiding this comment

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

It's better to add a TODO comment here or raise a issue, otherwise, this is easily to be forgotten.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I already added to runtime task.

Copy link
Member

Choose a reason for hiding this comment

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

Have you also add that person who implementing the runtime symbol deconflicting should un-comment out this line of code?

If you haven't, I think it's just like I said above that this is easily to be forgotten.

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