forked from christina-de-martinez/babel-plugin-glowup-vibes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add preparser for emoji to semicolon (christina-de-martinez#49)
- Loading branch information
1 parent
95916ee
commit 2c74391
Showing
8 changed files
with
99 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const parse = require("./preParser.js") | ||
|
||
module.exports = { | ||
ignore: ["./identifierMappings.js"], | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: { | ||
edge: "17", | ||
firefox: "60", | ||
chrome: "67", | ||
safari: "11.1" | ||
}, | ||
useBuiltIns: "usage", | ||
corejs: "3.6.5" | ||
} | ||
] | ||
], | ||
plugins: [ | ||
{ | ||
parserOverride(code, opts) { | ||
return parse(code, opts); | ||
} | ||
}, | ||
"./index.js" | ||
] | ||
} |
This file was deleted.
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
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,20 @@ | ||
const parser = require("@babel/parser"); | ||
|
||
module.exports = function (code, opts) { | ||
const literalIndictors = ['"', '\'', '`']; | ||
let currentIndicator; | ||
let insideLiteral = false | ||
let parsed = ""; | ||
for (let i=0, ch; ch = code[i]; i++) { | ||
if (insideLiteral) { | ||
insideLiteral = !(ch == currentIndicator && code[i-1] != '\\') | ||
} else { | ||
if (literalIndictors.includes(ch)) { | ||
currentIndicator = ch; | ||
insideLiteral = true | ||
} | ||
} | ||
parsed += (!insideLiteral && ch == "\uD83D" && code[++i] == "\uDE2D") ? ";" : ch; | ||
} | ||
return parser.parse(parsed, opts) | ||
} |
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