Using browserify (commonjs), how can I minimize the size of react-virtualized? It seems to be including other classes that I'm not using like Collection and Table. I have tried using the standard syntax import {foo, bar}... as well as specifying each class individually import {WindowScroller} from 'react-virtualized/dist/commonjs/WindowScroller'. Yet it seems that RV is still taking up ~90k:
Thanks!
This has been addressed in v8, where bundle sizes have been reduced
Related
I have been looking into/debugging code transformation related issues in Jest for the last day and a recurring theme is that the SyncTransformer#createTransformer method is a constant source of surprise and it is not really documented why it exists.
The SyncTransformer interface only has a single field one has to implement: process. But it seems that if one implements createTransformer those other methods will not be used: instead Jest seems to create a new transformer using createTransformer, which caused me to lose a few hairs until I figured what was going on. This behaviour is not documented either.
The babel-jest source for Jest 27.
I filed a documentation bug issue with Jest after I could see that the behavior was not mirrored in the docs, which I subsequently fixed by updating the types and docs for code transformation.
The rules for this is basically like follows:
if createTransformer exists as an export, then jest-transform will use that to create a transformer dynamically and not use any of the other exports
if the transformer is imported using import (and not require) it will try to use processAsync and fall back to process if the async version does not exist
Sometimes I see slightly different imports
import styled, { withTheme } from "styled-components/macro";
import styled, { withTheme } from "styled-components";
Since they have the same functionality I cannot understand the difference between them neither can google anything that could help.
In production styled-components generates unique hashes for css classes like .eeZmbc or .ZzNLl. These are used for saving space but are not useful for developers in development.
For semantic class names in development a babel plugin exists. It generates names like .Navbar__Item-sc-14eztoj-1 as in .FileName__StyledComponent-generatedHash to help us trace an element/style back to its source.
So if you use create-react-app you can use this plugin without ejecting and without adding it to babel config. You just have change your import from styled-components to styled-components/macro. A quick find-and-replace in you IDE will do the trick.
All the compile-time code transformation is handled by babel-plugin-macros
babel-plugin-macros defines a standard interface for libraries that want to use compile-time code transformation without requiring the user to add a babel plugin to their build system (other than babel-plugin-macros, which is ideally already in place).
Personally I add the babel plugins to the config file manually and use standard imports like styled-components.
I often times import cupertino.dart instead of material.dart when having to import widgets because its the first suggested options.
Its not a real problem but for the sake of consistency I want to prevent importing cuppertino.dart so it is not listed in the import suggestions and only use widgets.dart or material.dart instead.
Is there a way to configure Android Studio or Dart Analyzer to prevent cuppertino.dart to show in suggestions?
Seems no, but there is a workaround: You can write a linter to examine your code and warn (or error) whenever you see imports of cupertino.dart. That linter can even automatically correct the code (by replacing cupertino with material).
Some methodology thoughts: I often want something to be automatically performed ("import material not cupertino" in your case); but later I realized it is hard or not exist yet, but some verifier is good enough ("manually import; but warn if you import the wrong one").
You can create an export file with your exports inside and call this file afterwards.
For example create an exportsFile:
export 'package:flutter/material.dart';
And now call this file when you wants:
import 'exportsFile.dart';
I have a class called FIT, saved in a file called manage.
in my main file, the first lines look like this
import manage
FITobj= FIT()
I thought when I did this it would call the class so I would be able to use functions like get_balance() like FITobj.get_balance(). but instead, when I try to run my program I get name error name FIT is not defined. I'm fairly new to object-oriented programming, can someone help?
You need to indicate where the FIT class is defined. Either change it to:
import manage
FITobj = manage.FIT()
Or
from manage import FIT
FITobj = FIT()
The first is slightly more typing, but it helps keep your code more readable because as you import more and more, it can get very difficult to keep track of where everything is coming from.
Adding to #mypetlion's answer, to avoid even more typing (but make your program even less readable), you can do this:
from manage import *
FITobj=FIT()
And then use anything else from manage as well as just FIT.
my question is that i want to use Scanner object or Arrays object for example for usage of Arrays.copyof, but before importing java.util.* or java.util.Scanner and java.util.Arrays there is now object of them to use !
why this happens to me??enter image description here
It is a little unclear what you want to achieve. Are you asking why you should do imports in Java?
import statements allow you to refer to classes which are declared in other packages without referring to their full package name. This is standard java practice. Inside your main(String args[] you can use java.util.Scanner myobject = new .. if you want, but that is too cumbersome and often you have multiple classes in a package that you want to use. So adding a simple import java.util.* is considered better.
Another tip is to use one among the large number of available IDEs (eclipse, sublime, IntelliJ) which will add the imports automatically for you.