usedexports | Find in Go exported variables that could be
kandi X-RAY | usedexports Summary
kandi X-RAY | usedexports Summary
Find exported variables (const, var, func, struct) in Go that could be unexported. The Go Challenge #5 sparked the idea of detecting unused exports. My goal with usedexports is to report on unused exports for a local application, and not scan the whole GOPATH.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- parseUsedExports parses a directory in the given directory
- Visit invokes ast . Visitor .
- parseExports walks the given directory .
- main . go
- parseTree recursively walks the tree rooted at the given path .
- getImportPath returns the absolute path to use for codebase
- printOutput prints exported export declarations .
- usage prints a usage message .
usedexports Key Features
usedexports Examples and Code Snippets
Community Discussions
Trending Discussions on usedexports
QUESTION
I set up a small project with the following files
...ANSWER
Answered 2022-Mar-31 at 15:43I figured it out myself, auto-answer for the record :
The tsconfig.json was wrong, it wasn't preserving the ES6 module syntaxe so webpack couldn't treeshake properly.
More details on the correct configuration (optionally including Babel too) can be found here
QUESTION
So, swiperjs, from docs:
"By default Swiper exports only core version without additional modules (like Navigation, Pagination, etc.). So you need to import and configure them too:"
...ANSWER
Answered 2022-Feb-08 at 18:17I've found out the issue: with swiper (at least), sideEffects option must be used at loader level and not at package level. Or maybe you can use at package level, but explicitly declaring the files. Didn't try though. Instead, it did worked by setting sideEffects like this:
QUESTION
recently I cleaned up the webpack
configuration in a project in order to make it more maintainable, I did so by splitting the configuration in two files:
ANSWER
Answered 2021-Nov-23 at 16:10Well, I was able to figure out the problem, the problematic lines were:
QUESTION
In running yarn run build
I am running into the following error:
ANSWER
Answered 2021-Oct-16 at 19:21I think it is case sensitive, ie. change the D
to a d
, change moduleIDs
to moduleIds
.
QUESTION
I'm trying to get Material-ui to tree-shake correctly. The bundle is extremely large compared to what I'm actually using. I'm not using most of the components listed by the analyzer plugin below and I'm importing everything like it says on the material-ui docs. For example here is what it looks like in one of my files.
...ANSWER
Answered 2021-Sep-11 at 04:17It looks like this happens with material-ui when you build in development. The production build tree-shakes correctly. Weirdly though, material-ui's own docs claim that if you do the direct file import, the dev build should tree-shake correctly too.
QUESTION
Simple webpack setup, when I use import
to load my scss it is completely missing from the bundle. The line where the import should be is simply missing. When I use require
instead, it works.
optimization: {usedExports: true}
is not the problem, I tried with and without
mini-css-extract-plugin also did not work.
when I put a typo in the scss it complains, so it is parsed but simply not bundled in the end?
index.js
...ANSWER
Answered 2021-Sep-04 at 07:59I found the problem but I don't understand why webpack drops it.
Quote from https://webpack.js.org/guides/tree-shaking/
Note that any imported file is subject to tree shaking. This means if you use something like css-loader in your project and import a CSS file, it needs to be added to the side effect list so it will not be unintentionally dropped in production mode:
In my package.json I put
QUESTION
I have been scouring the internet for solution after solution and nothing seems to be working for me so I'm requesting help.
Issue: No matter what I do, I can't get anything inside my root div. There are no console errors at all in IE11. The app works fine on chrome, ff, & safari.
Dependencies / Versions
- "react": "^17.0.2",
- "@babel/core": "^7.14.6",
- "babel-loader": "^8.2.2",
- "core-js": "^3.8.0",
- "webpack": "^5.41.1",
index.js
...ANSWER
Answered 2021-Aug-16 at 15:32I didn't need the browserlist in package.json
nor webpack.config.js
, I did however need the target: ['web','es5']
in my webpack.config.js
. My issue was this & the suggestion from @matthiasgiger -- even though I had set modules to false for my output environment, removing the type="module"
was they key
QUESTION
My TypeScript enums are defined like this, as in this file:
...ANSWER
Answered 2021-Aug-10 at 06:32This is due to Terser being unable to reason about the side-effects in your colors.ts
enum, so Terser keeps all three definitions even though it only exports one of them.
If these weren't transpiled TypeScript enums, I'd recommend to simplify the declarations, ideally by marking each function /*#__PURE__*/
and making it return its intended value. However, since they are TypeScript enums, you might need to convert them to object literals as const
, are certainly easier for Terser to reason about and are likely sufficient for your needs.
If I'm reading your output right, the arrays you're trying to remove are present in both development and runtime builds; you've omitted them with "..." but they're there.
According to your package.json
you are using both sideEffects
and usedExports
of Webpack's tree-shaking feature set. sideEffects
correctly asserts that you aren't changing anything aside from your exports, so Webpack can safely skip your whole module if your project consumes none of its exports. However, usedExports
might not be as smart as you would hope:
usedExports
relies on terser to detect side effects in statements. It is a difficult task in JavaScript and not as effective as straightforwardsideEffects
flag. It also can't skip subtree/dependencies since the spec says that side effects need to be evaluated.
It seems that for both development and production Webpack is smart enough to detect that your HueColors is the only export you consume, but Terser is not smart enough to determine that each self-initializing IIFE is free of side-effects that would affect the others. Technically, as a human, I can't reason about it either: Some other piece of code might have changed the Object or Array prototype in a bizarre way, even if your functions didn't use inline assignment or modify same-named shadowed variables of an enclosing scope in your IIFEs.
With an in-browser copy of terser I've been able to reproduce your problem.
First of all, switching to const object literals would be completely effective:
QUESTION
I am trying to use postcss-env-function
in order to be able to share variables between javascript and less/css. I get the following error during build. The error disappears if I remove the first line of index.less:
@import '~antd/dist/antd.less';
However, then I will not get antd's styles. (There is no error also if I remove postcss-loader
). How to solve this issue?
Error:
...ANSWER
Answered 2021-Jul-12 at 23:26It seems that it is a syntax error regarding your opacity. The most common styles use objects so that you would declare opacity as:
QUESTION
We have a typescript react 'main' project. In the package.json is a dependency on another internal library that we use. The 'main' project builds fine when both projects targeted es5, but changing to es2017 throws the following error:
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
It throws this error for all the files that declare enums in the dependent project.
This is the tsconfig.json file for the main project:
...ANSWER
Answered 2021-Jul-12 at 14:132 thing led me to the solution. First of all:
The bable.config.json file has:
"@babel/preset-react"
which causes babel to "remove typescript types". Ref here. Removing it gets rid of the errors, since obviously all types are removed (but obviously babel cannot then process JSX).
Thus I realised that the enum files are ambient, and babel-loader (specifically preset-react
) doesn't know how to process them (unlike tsc
).
That led me to to this SO question, and I realized I had to specifically tell babel-loader where to find the enum files, and so added this to my package.json:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install usedexports
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page