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

Rust rewrite #52

Merged
merged 122 commits into from
May 12, 2021
Merged

Rust rewrite #52

merged 122 commits into from
May 12, 2021

Conversation

DeMoorJasper
Copy link
Member

@DeMoorJasper DeMoorJasper commented Apr 4, 2021

This PR is a ground-up rewrite of this library in Rust instead of C++.
This should result in a more stable and easier to read codebase, with the advantage of having access to the vast amount of libraries that are already available for Rust.

Fixes #54

TODO:

  • Setup benchmark action and compare to current version
  • Fix failing tests
  • Update azure pipeline
  • Move filepath normalization to Rust
  • Fix performance issues with filepath normalization in Rust
  • Experiment with bincode instead of flatbuffers
  • Implement extends
  • Setup test workflow
  • Setup release workflow

@devongovett
Copy link
Member

Should we use the same rustfmt settings as in the monorepo?

@DeMoorJasper
Copy link
Member Author

@devongovett Sure, feel free to update it

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Looks good! A few comments but nothing blocking. Should we also update the readme to say it's written in Rust instead of C++ now?

return ctx.env.create_string(source_content);
}
None => {
return ctx.env.create_string("");
Copy link
Member

Choose a reason for hiding this comment

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

Should this throw an error or return null maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is intentional to mimic the c++ logic. Might make some breaking changes in a follow-up

return ctx.env.create_string(name);
}
Err(_err) => {
return ctx.env.create_string("");
Copy link
Member

Choose a reason for hiding this comment

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

Same with this one. I guess this is ignoring the error atm

Copy link
Member Author

Choose a reason for hiding this comment

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

Same consistency w/ cpp implementation

let this: JsObject = ctx.this_unchecked();
let source_map_instance: &mut SourceMap = ctx.env.unwrap(&this)?;

// TODO: Figure out a more optimal way of handling typed arrays...
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah been discussing how to properly tackle this with the napi-rs maintainer, gonna update that... it's really hitting performance atm

src/SourceMap.js Outdated
@@ -13,15 +14,18 @@ export default class SourceMap {
/**
* @private
*/
projectRoot: string;
projectRoot: any;
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member Author

Choose a reason for hiding this comment

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

probably from some experimenting and flow complaining, reverted that...

source: './helloworld.coffee',
generated: { line: 2, column: 2 },
original: { line: 1, column: 0 },
source: 'helloworld.coffee',
Copy link
Member

Choose a reason for hiding this comment

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

This change was intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, wanted to make it follow the same logic as source-map library, esbuild, ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I can revert it very easily

@DeMoorJasper
Copy link
Member Author

@devongovett Thanks, will update readme and resolve your comments

@DeMoorJasper DeMoorJasper merged commit e1be119 into master May 12, 2021
@DeMoorJasper DeMoorJasper deleted the rust-rewrite branch May 12, 2021 20:20
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.

Node crash when bundling (SourceMapBinding::addRawMappings)
2 participants