Open withoutmeat opened 3 years ago
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
.
if i change devtool: "eval-cheap-module-source-map"
to devtool: "eval-cheap-source-map"
in the webpack.config.js, it will be ok.
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.
Having this problem too in a react app. use eval-cheap-source-map
solves the problem.
The latest @swc/core
works.
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",
},
},
},
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", }, }, },
It's "sourceMaps" not "sourceMap"
@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',