You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm importing a terser node_module and since it doesn't have default export I need to import the terser function specifically. This then results in an error in Codacy PR review saying "Unnecessary block".
Here is the code where the error happens:
import vue from 'rollup-plugin-vue'
import { terser } from 'rollup-plugin-terser'
import replace from '@rollup/plugin-replace'
import filesize from 'rollup-plugin-filesize'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import babel from 'rollup-plugin-babel'
import json from '@rollup/plugin-json'
import builtins from 'rollup-plugin-node-builtins'
import globals from 'rollup-plugin-node-globals'
const production = !process.env.ROLLUP_WATCH
// We can't really do much about circular dependencies in node_modules
function onwarn (warning) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
console.error(`(!) ${warning.message}`)
}
}
export default {
input: 'ui/app.js',
output: {
file: 'assets/hello.js',
format: 'amd',
sourcemap: !production
},
onwarn,
plugins: [
vue(),
replace({
'process.env.NODE_ENV': JSON.stringify('production')
}),
resolve({
mainFields: ['browser', 'jsnext', 'module', 'main'],
include: 'node_modules/**',
preferBuiltins: true
}),
babel({
exclude: 'node_modules/**',
runtimeHelpers: true
}),
commonjs({
include: 'node_modules/**'
}),
json(),
globals(),
builtins(),
production && terser(),
production && filesize()
]
}
I don't think this error should happen because what if this would be some really big library and we'd want to use only some small pieces of it but would have to import it whole in order to not get this error?
The text was updated successfully, but these errors were encountered:
You're absolutely right, that should not be flagged as a potential problem. And PMD's maintainers are already aware of this problem as you can see in this issue on their repository.
Until this issue is fixed, as a workaround, you can either
a) ignore the issue's occurrence: expand the issue > click the configuration gear > Ignore issue
Or
b) ignore the pattern: go to Code patterns (on the side bar) > PMD > Untick the box next to the "Unnecessary block." pattern.
Feel free to reach out if you have any question or concern.
I'm importing a terser node_module and since it doesn't have default export I need to import the terser function specifically. This then results in an error in Codacy PR review saying "Unnecessary block".
Here is the code where the error happens:
I don't think this error should happen because what if this would be some really big library and we'd want to use only some small pieces of it but would have to import it whole in order to not get this error?
The text was updated successfully, but these errors were encountered: