-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Preserve directive prologues, fixes #5 The most important goal is correctness. Directives were destroyed by placing imports above it. Directive prologues are defined by the spec as > A Directive Prologue is the longest sequence of ExpressionStatements occurring as > the initial StatementListItems or ModuleItems of a FunctionBody, a ScriptBody, or > a ModuleBody and where each ExpressionStatement in the sequence consists entirely > of a StringLiteral token followed by a semicolon. The semicolon may appear explicitly > or may be inserted by automatic semicolon insertion (12.9). A Directive Prologue may > be an empty sequence. * Remove nodes from code via proper algorithm, fixes #7 Previously, a regex string replacement was used, and regex is an inadequate tool for transforming entire JavaScript code files. Instead, this commit changes that to a proper algorithm that removes the code at the source position ranges of the nodes to be removed. This will not work properly if the Babel parser ever did not return the correct source positions, but that is not a regression since the former algortihm already relied on the positions being correct. * Remove comments from directives we add back at the top, #5 The comments are added back as part of the new directives placed at the top, so we should remove them from the original code we add after the directives and the imports.
- Loading branch information
1 parent
9f5a0ba
commit b5c23c7
Showing
19 changed files
with
453 additions
and
37 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
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
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
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
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
Oops, something went wrong.