-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: a new unassertCode function that returns the modified code and …
…sourcemap
- Loading branch information
1 parent
8733dc3
commit 410ccf5
Showing
6 changed files
with
522 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type MagicString from "magic-string"; | ||
import type { SourceMap, SourceMapOptions } from "magic-string"; | ||
import type { Node } from "acorn"; | ||
import type { Visitor } from "estraverse"; | ||
|
||
export type UnassertAstOptions = Partial<{ | ||
modules: string[]; | ||
variables: string[]; | ||
}>; | ||
|
||
export type UnassertCodeOptions = UnassertAstOptions & | ||
Partial<{ | ||
sourceMap: boolean | SourceMapOptions; | ||
}>; | ||
|
||
export type CreateVisitorOptions = UnassertAstOptions & | ||
Partial<{ | ||
code: MagicString; | ||
}>; | ||
|
||
export type UnassertCodeResult = { | ||
code: string; | ||
map: SourceMap | null; | ||
}; | ||
|
||
export function unassertAst(ast: Node, options?: UnassertAstOptions): Node; | ||
|
||
export function unassertCode( | ||
code: string, | ||
ast: Node, | ||
options?: UnassertCodeOptions | ||
): UnassertCodeResult; | ||
export function unassertCode( | ||
code: MagicString, | ||
ast: Node, | ||
options?: UnassertCodeOptions | ||
): MagicString; | ||
export function unassertCode( | ||
code: string | MagicString, | ||
ast: Node, | ||
options?: UnassertCodeOptions | ||
): UnassertCodeResult | MagicString; | ||
|
||
export function defaultOptions(): UnassertAstOptions; | ||
|
||
export function createVisitor(options?: CreateVisitorOptions): Visitor; |
Oops, something went wrong.