-
Notifications
You must be signed in to change notification settings - Fork 46
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
Conversation
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 ModuleSpecifier
s. Let's change specifier: &str
to an owned specifier: ModuleSpecifier
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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
This allows you to emit any program. Previously
deno_ast
could only emit programs it also transformed to JS.