-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use babel when transpiling to es5 instead of swc until it reach…
…es maturity
- Loading branch information
Showing
11 changed files
with
134 additions
and
267 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
28 changes: 28 additions & 0 deletions
28
src/build/plugin/babel/plugin-transform-inline-regenerator.ts
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 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import type {PluginItem, types, NodePath} from "@babel/core"; | ||
import template from "@babel/template"; | ||
import { REGENERATOR_SOURCE } from "../../../constant/regenerator-source"; | ||
|
||
const REGENERATOR_TEMPLATE = template(REGENERATOR_SOURCE)(); | ||
|
||
export default function (): PluginItem { | ||
let hasInlinedRegeneratorRuntime = false; | ||
let root: NodePath<types.Program>; | ||
|
||
return { | ||
name: "transform-inline-regenerator", | ||
visitor: { | ||
Program(path) { | ||
root = path; | ||
}, | ||
MemberExpression(path) { | ||
if (hasInlinedRegeneratorRuntime || path.node.object.type !== "Identifier" || path.node.object.name !== "regeneratorRuntime") { | ||
return; | ||
} | ||
|
||
hasInlinedRegeneratorRuntime = true; | ||
root.unshiftContainer("body", REGENERATOR_TEMPLATE); | ||
} | ||
} | ||
}; | ||
} |
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