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: add Emitter and emit feature #230

Merged
merged 4 commits into from
Apr 11, 2024
Merged

feat: add Emitter and emit feature #230

merged 4 commits into from
Apr 11, 2024

Conversation

lucacasonato
Copy link
Member

This allows you to emit any program. Previously deno_ast could only emit programs it also transformed to JS.

This allows you to emit any program. Previously `deno_ast` could only emit programs it also transformed to JS.

/// Source emitted based on the emit options.
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Debug)]
pub struct EmittedSource {
Copy link
Member

Choose a reason for hiding this comment

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

Move above Emitter so that the impl of Emitter is not separated by this?

src/emit.rs Outdated
}

impl Emitter {
pub fn new(specifier: &str, source: String, options: EmitOptions) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

We changed deno_ast to work completely off ModuleSpecifiers. Let's change specifier: &str to an owned specifier: ModuleSpecifier

Copy link
Member Author

Choose a reason for hiding this comment

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

It's only used to construct the source map, and for NPM transpile I need the ability to specify a relative path as the source map path. Hence why this is a string instead of a module specifier

src/emit.rs Outdated Show resolved Hide resolved
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM!

@dsherret dsherret merged commit 8752164 into main Apr 11, 2024
2 checks passed
@dsherret dsherret deleted the emit_and_emitter branch April 11, 2024 18:45
github-merge-queue bot pushed a commit to jsr-io/jsr that referenced this pull request Apr 17, 2024
This fixes various bugs, and introduces some features. Specifically:

- Source code is now included in the bundle to enable better "Go to
source definition"
- More usecases using `/// <reference types="..." />` work correctly
now, especially when d.ts file is not a sibling of the JS file.
- We strip `/// <reference types="..." />` out of JS files correctly
now.
- We transpile `npm:` and `jsr:` specifiers in user provided `.d.ts`
files now.

Fixes #367
Fixes #372
Fixes #364
Fixes #313
Fixes #180
Fixes #216
Fixes #326

~~Blocked on landing denoland/deno_ast#230 and
denoland/deno_graph#429 Landed
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