|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | const {
|
|---|
| 2 | getImportSource,
|
|---|
| 3 | getRequireSource
|
|---|
| 4 | } = require("./utils.cjs");
|
|---|
| 5 | function isRegeneratorSource(source) {
|
|---|
| 6 | return source === "regenerator-runtime/runtime" || source === "regenerator-runtime/runtime.js";
|
|---|
| 7 | }
|
|---|
| 8 | module.exports = function () {
|
|---|
| 9 | const visitor = {
|
|---|
| 10 | ImportDeclaration(path) {
|
|---|
| 11 | if (isRegeneratorSource(getImportSource(path))) {
|
|---|
| 12 | this.regeneratorImportExcluded = true;
|
|---|
| 13 | path.remove();
|
|---|
| 14 | }
|
|---|
| 15 | },
|
|---|
| 16 | Program(path) {
|
|---|
| 17 | path.get("body").forEach(bodyPath => {
|
|---|
| 18 | if (isRegeneratorSource(getRequireSource(bodyPath))) {
|
|---|
| 19 | this.regeneratorImportExcluded = true;
|
|---|
| 20 | bodyPath.remove();
|
|---|
| 21 | }
|
|---|
| 22 | });
|
|---|
| 23 | }
|
|---|
| 24 | };
|
|---|
| 25 | return {
|
|---|
| 26 | name: "preset-env/remove-regenerator",
|
|---|
| 27 | visitor,
|
|---|
| 28 | pre() {
|
|---|
| 29 | this.regeneratorImportExcluded = false;
|
|---|
| 30 | },
|
|---|
| 31 | post() {
|
|---|
| 32 | if (this.opts.debug && this.regeneratorImportExcluded) {
|
|---|
| 33 | let filename = this.file.opts.filename;
|
|---|
| 34 | if (process.env.BABEL_ENV === "test") {
|
|---|
| 35 | filename = filename.replace(/\\/g, "/");
|
|---|
| 36 | }
|
|---|
| 37 | console.log(`\n[${filename}] Based on your targets, regenerator-runtime import excluded.`);
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
| 40 | };
|
|---|
| 41 | };
|
|---|
| 42 |
|
|---|
| 43 | //# sourceMappingURL=regenerator.cjs.map
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.