Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When use auto imported apis, the sourcemap will be babel transpiled #465

Open
4 of 5 tasks
serialine opened this issue Jan 4, 2024 · 0 comments
Open
4 of 5 tasks

Comments

@serialine
Copy link

serialine commented Jan 4, 2024

Describe the bug

1. using Manual import

Original source

<script lang="ts">
import { ref } from "vue";
import { defineComponent } from "@nuxtjs/composition-api";

export default defineComponent({
  setup() {
    const a = ref();
    async function b() {
      return await Promise.resolve();
    }
    return { a, b };
  },
});
</script>

Generated source (chrome devtool sourcemap)

import { ref } from "vue";
import { defineComponent } from "@nuxtjs/composition-api";

export default defineComponent({
  setup() {
    const a = ref();
    async function b() {
      return await Promise.resolve();
    }
    return { a, b };
  },
});

2. using Auto import

Original source

<script lang="ts">
// import { ref } from "vue";
// import { defineComponent } from "@nuxtjs/composition-api";
export default defineComponent({
  setup() {
    const a = ref();
    async function b() {
      return await Promise.resolve();
    }
    return { a, b };
  },
});
</script>

Generated source (chrome devtool sourcemap)

import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import "regenerator-runtime/runtime.js";
import "core-js/modules/es.object.to-string.js";
// import { ref } from 'vue';
// import { defineComponent } from '@nuxtjs/composition-api';
export default defineComponent({
  setup: function setup() {
    var a = ref();
    function b() {
      return _b.apply(this, arguments);
    }
    function _b() {
      _b = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
        return regeneratorRuntime.wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              _context.next = 2;
              return Promise.resolve();
            case 2:
              return _context.abrupt("return", _context.sent);
            case 3:
            case "end":
              return _context.stop();
          }
        }, _callee);
      }));
      return _b.apply(this, arguments);
    }
    return {
      a: a,
      b: b
    };
  }
});

Reproduction

https://github.com/serialine/nuxt-ts-autoimport-transpiled

Question

Is there a way to avoid this?

Reproduction

https://github.com/serialine/nuxt-ts-autoimport-transpiled

System Info

System:
    OS: macOS 13.5.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 2.99 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.0/bin/yarn
    npm: 8.19.4 - ~/.nvm/versions/node/v16.20.0/bin/npm
    pnpm: 7.13.4 - ~/.nvm/versions/node/v16.20.0/bin/pnpm
  Browsers:
    Edge: 120.0.2210.91
    Safari: 16.6
    Safari Technology Preview: 17.4

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.

The discussion menu was not found.

@serialine serialine changed the title When use auto imported apis, the source will be babel transpiled When use auto imported apis, the sourcemap will be babel transpiled Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant