GoogleChromeLabs / worker-plugin

👩‍🏭 Adds native Web Worker bundling support to Webpack.
https://npm.im/worker-plugin
Apache License 2.0
1.91k stars 79 forks source link

Prettier Error #86

Open vicente-dl opened 4 years ago

vicente-dl commented 4 years ago

Hello! I have been trying to add a worker through this plugin, but I cannot stop getting errors from prettier related to core-js. All the functions that I used I appear to be imported as double quotes when compiled.

error in ./src/workers/myworker.js

Module build failed (from ./node_modules/worker-plugin/loader.js): ModuleError: Module Error (from ./node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js):

/Users/vicentediaz/pt/src/workers/myworker.js 1:9 error Replace "core-js/modules/es.array.for-each"); with 'core-js/modules/es.array.for-each') prettier/prettier 3:9 error Replace "core-js/modules/es.array.join"); with 'core-js/modules/es.array.join') prettier/prettier 5:9 error Replace "core-js/modules/es.array.map"); with 'core-js/modules/es.array.map') prettier/prettier 7:9 error Replace "core-js/modules/es.function.name"); with 'core-js/modules/es.function.name') prettier/prettier 9:9 error Replace "core-js/modules/es.object.keys"); with 'core-js/modules/es.object.keys') prettier/prettier 11:9 error Replace "core-js/modules/es.object.to-string"); with 'core-js/modules/es.object.to-string') prettier/prettier 13:9 error Replace "core-js/modules/es.regexp.exec"); with 'core-js/modules/es.regexp.exec') prettier/prettier 15:9 error Replace "core-js/modules/es.string.split"); with 'core-js/modules/es.string.split') prettier/prettier 17:9 error Replace "core-js/modules/web.dom-collections.for-each"); with 'core-js/modules/web.dom-collections.for-each') prettier/prettier 19:42 error Replace "/Users/vicentediaz/pt/node_modules/@babel/runtime/helpers/createForOfIteratorHelper"); with '/Users/vicentediaz/pt/node_modules/@babel/runtime/helpers/createForOfIteratorHelper') prettier/prettier

Has anyone had any similar problem??

developit commented 4 years ago

You shouldn't be running prettier or eslint on generated output files. I'm not sure how the vue-cli prettier plugin you're using works, but you'll want to find a way to tell prettier to ignore whatever directory you're outputting files to (dist, build, etc).

vicente-dl commented 4 years ago

Is not running on generated files, the error appears on the worker inside the src folder. I was able to fix it ignoring the worker specifically. Is not the best solution but works for now.

developit commented 4 years ago

What does your worker code look like? I can't think of a reason why Prettier would complain about core-js require() statements other than them simply being present in the worker file. Is it code you've copied from somewhere?

developit commented 4 years ago

FWIW this appears to be a specific issue with @vue/cli.

vicente-dl commented 3 years ago

What does your worker code look like? I can't think of a reason why Prettier would complain about core-js require() statements other than them simply being present in the worker file. Is it code you've copied from somewhere?

I created the code, there is nothing complex about, but it throws the error when I use ES6 functions such as map. I was able to fix the error by disabling prettier on it, but still i havent been able to find any other solution.

dohun-toss commented 3 years ago

Could you provide CSB?

jpoles1 commented 3 years ago

Still having issues with this plugin and @vue/cli. Unable to switch over to eslint-webpack-plugin as described in #95, unfortunately. Any fixes that anyone's come across to get it working with vue?