vue.js - dynamic imports results in error: Support for the experimental syntax 'dynamicImport' isn't currently enabled

I fixed the problem myself after many hours of frustration. I still don't know why the method that's used in the Babel, Webpack and Vue documentation doesn't work but I did get this working:

I first removed the plugin declaration from babel.rc file and then added an option to the babel loader in webpack.config file:

{
    test: /\.js$/,
    use: {
        loader: "babel-loader",
        options: {
            plugins: [
                "@babel/plugin-syntax-dynamic-import"
            ]
        }
    }
}

I hope this helps others.


You have the wrong plugin assignment:

"plugins": ["@babel/plugin-syntax-dynamic-import"]

Would be the correct format for that plugin.