Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

There will be an error when enable sourcemap in vue3 app #19

Open
withoutmeat opened this issue Apr 30, 2021 · 8 comments
Open

There will be an error when enable sourcemap in vue3 app #19

withoutmeat opened this issue Apr 30, 2021 · 8 comments

Comments

@withoutmeat
Copy link

withoutmeat commented Apr 30, 2021

thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/sourcemap-6.0.1/src/builder.rs:84:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
[1]    57707 abort      npx webpack
@withoutmeat
Copy link
Author

withoutmeat commented Apr 30, 2021

webpack.config.js:

const VueLoaderPlugin = require("vue-loader").VueLoaderPlugin;

module.exports = {
  mode: "development",
  entry: "./index.ts",
  devtool: "eval-cheap-module-source-map",
  module: {
    rules: [
      {
        test: /\.vue$/,
        use: { loader: "vue-loader" },
      },
      {
        test: /\.(ts|js)$/,
        use: {
          loader: "swc-loader",
          options: {
            jsc: {
              parser: {
                syntax: "typescript",
                dynamicImport: true,
              },
              target: "es2015",
            },
          },
        },
      },
    ],
  },
  plugins: [new VueLoaderPlugin()],
};

index.ts:

import { createApp } from "vue";
import App from "./app.vue";

createApp(App).mount("#app");

app.vue:

<template>
  <div>app</div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
  setup() {
    return {}
  }
});
</script>

package.json:

{
  "name": "swc-test",
  "version": "1.0.0",
  "license": "MIT",
  "devDependencies": {
    "@swc/core": "^1.2.54",
    "@vue/compiler-sfc": "^3.0.11",
    "swc-loader": "^0.1.14",
    "vue-loader": "^16.2.0",
    "webpack": "^5.36.1",
    "webpack-cli": "^4.6.0"
  },
  "dependencies": {
    "vue": "^3.0.11"
  }
}

then run npx webpack.

@withoutmeat withoutmeat changed the title sourceMaps: true will cause an error There will be an error when enable sourcemap in vue app Apr 30, 2021
@withoutmeat withoutmeat reopened this Apr 30, 2021
@withoutmeat
Copy link
Author

withoutmeat commented Apr 30, 2021

if i change devtool: "eval-cheap-module-source-map" to devtool: "eval-cheap-source-map" in the webpack.config.js, it will be ok.

@withoutmeat withoutmeat changed the title There will be an error when enable sourcemap in vue app There will be an error when enable sourcemap in vue3 app Apr 30, 2021
@lephuongbg
Copy link

We use vue 2 with eval-source-map setting and also meet the same error. Changing devtool setting to eval-cheap-source-map works but not desirable.

@Jack-Works
Copy link

Having this problem too in a react app. use eval-cheap-source-map solves the problem.

@FuJuntao
Copy link

FuJuntao commented Oct 15, 2021

The latest @swc/core works.

@Edge00
Copy link

Edge00 commented Oct 28, 2021

My vue3 app get no sourcemap with following config while babel is fine:

use: {
  loader: "swc-loader",
  options: {
    sourceMap: true,
    jsc: {
      parser: {
        syntax: "typescript",
        dynamicImport: true,
      },
      target: "es2015",
    },
  },
},

image

@FuJuntao
Copy link

My vue3 app get no sourcemap with following config while babel is fine:

use: {
  loader: "swc-loader",
  options: {
    sourceMap: true,
    jsc: {
      parser: {
        syntax: "typescript",
        dynamicImport: true,
      },
      target: "es2015",
    },
  },
},

image

It's "sourceMaps" not "sourceMap"

@Edge00
Copy link

Edge00 commented Oct 28, 2021

@FuJuntao I've tried sourceMaps and got same result.
more info here:

"@swc/core": "1.2.103",
"@swc/helpers": "0.2.13",
"swc-loader": "0.1.15",
devtool: 'cheap-module-source-map',

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants