Dynamic import and Vue cannot be used with webpack loader
See original GitHub issueCode:
// index.js
async function main() {
const mod = await import("./module");
console.log(mod);
}
main();
// module.js
export const text = "Hello World";
Error:
ERROR in ./src/index.js
Module build failed (from (webpack)-obfuscator/dist/loader/index.js):
Error: SyntaxError: Unexpected token (2:20)
at Function.parseCode (/Users/kevin/projects/webpack-obfuscator-demo/node_modules/webpack-obfuscator/dist/loader/index.js:63:23)
at Function.getCommentedSource (/Users/kevin/projects/webpack-obfuscator-demo/node_modules/webpack-obfuscator/dist/loader/index.js:31:55)
at Object.Loader (/Users/kevin/projects/webpack-obfuscator-demo/node_modules/webpack-obfuscator/dist/loader/index.js:84:63)
Webpack config:
// webpack.config.js
const path = require("path");
const WebpackObfuscator = require("webpack-obfuscator");
module.exports = {
mode: "production",
module: {
rules: [
{
test: /\.js$/,
include: [path.resolve(".", "src")],
enforce: "post",
use: {
loader: WebpackObfuscator.loader,
options: {
rotateStringArray: true,
},
},
},
],
},
};
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
webpack - vue.js - dynamic imports results in error: Support for ...
I want to use lazy/dynamic imports because I am rebuilding my content management system which has many, many pages that may or may...
Read more >Webpack and Dynamic Imports: Doing it Right - Medium
The problem is if you want to dynamically load a file, in this case, an image, Webpack by default generate a chunk for...
Read more >Lazy Loading Routes | Vue Router
Vue Router supports dynamic imports out of the box, meaning you can ... In general, it's a good idea to always use dynamic...
Read more >Features | Vite
You can NOT use variables or expressions in them. Dynamic Import #. Similar to glob import, Vite also supports dynamic import with variables....
Read more >file-loader - webpack - JS.ORG
The file-loader resolves import / require() on a file into a url and emits ... This can be used to prepend or append...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PR for export literals https://github.com/javascript-obfuscator/javascript-obfuscator/pull/712
So. I’ll fix that literal value moved to the string array. But i cannot fix that
as foo
part was removed from this export because this isescodegen
problem. I’ll try to create the PR to that package, but it may be merged in few weeks or even months