swc-project / swc-loader

Moved to https://github.com/swc-project/pkgs
MIT License
394 stars 29 forks source link

not working with existing vue js project #32

Open eregnier opened 2 years ago

eregnier commented 2 years ago

Hey,

swc looks promising. however, I tried to setup one legacy project with webpack using swc-loader and I have the follwing error when I try to run the project

Failed to compile.

./src/main.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: .inputSourceMap must be a boolean, object, or undefined
    at assertInputSourceMap (/code/sample/node_modules/@babel/core/lib/config/validation/option-assertions.js:124:11)
    at /code/sample/node_modules/@babel/core/lib/config/validation/options.js:118:5
    at Array.forEach (<anonymous>)
    at validateNested (/code/sample/node_modules/@babel/core/lib/config/validation/options.js:94:21)
    at validate (/code/sample/node_modules/@babel/core/lib/config/validation/options.js:85:10)
    at loadPrivatePartialConfig (/code/sample/node_modules/@babel/core/lib/config/partial.js:80:50)
    at loadPrivatePartialConfig.next (<anonymous>)
    at /code/sample/node_modules/@babel/core/lib/config/partial.js:149:25
    at Generator.next (<anonymous>)
    at step (/code/sample/node_modules/gensync/index.js:261:32)
    at evaluateAsync (/code/sample/node_modules/gensync/index.js:291:5)
    at /code/sample/node_modules/gensync/index.js:93:9
    at new Promise (<anonymous>)
    at async (/code/sample/node_modules/gensync/index.js:92:14)
    at Object.<anonymous> (/code/sample/node_modules/babel-loader/lib/index.js:155:26)
    at Generator.next (<anonymous>)

I only updated my vue.config.js file like and it starts to load quickly but fail at the end with the error above:

configureWebpack: {
    module: {
        rules: [
            {
                test: /\.m?js$/,
                exclude: /node_modules/,
                use: {
                    loader: "swc-loader",
                },
            ]
        },
    },
},

I found on the internet that this option in webpack seems to allow load the entire project, but it is slow to load, so I guess It falls back on babel to perform this operation instead of swc

devtool: "eval-cheap-source-map"

I tried this on two projects and tried to update babel dependencies as well. I got this error in both. Any idea about what is missing, what is going on ?