Comments (12)
The npm package is compiled in JavaScript 5, you can simply import it in your project and create a bundle using browserify or webpack. About the UI I haven't tested IE yet, so I can't guarantee it will work correctly. I'll verify it in the following days
from rc-datepicker.
So much clear ! Thanks a lot ~
from rc-datepicker.
I install the datepicker via npm, and create a bundle.js using Browserify, but I found a new problem: bundle.js is closeto 1000KB, it is too heavyweight in browser. Is there any way to make it lighter?
from rc-datepicker.
bundle.js is a big JavaScript file with everything you need inside so to reduce its size you can proceed as always: first minify it and then gzip it. (by using a plugin of gulp/grunt/webpack or here: minify gzip)
from rc-datepicker.
Does bundle.js include all the locale files?
from rc-datepicker.
@luokuning I think I misunderstood your question before. The bundle.js you're referring to probably contains other libraries (like ReactJS) that's why Its size is around 1mb. Our datepicker, if minified, should be around ~40/50kb which would decrease even more if gzipped. The biggest part of its size comes from Moment.js which minified is about ~34kb.
from rc-datepicker.
@FrancescoCioria I realized that I have missing something on Browserify.First time I packed the DatePicker.js by the following code:
browserify DatePicker.js > DatePicker_browser.js
and then the size of DatePicker_browser.js is nearly 1000KB. Then I checked the Browserify home page and found that if there is no need to include some file I should use the ' --ignore' param, so my code become follows:
browserify DatePicker.js --ignore react/addons --ignore/react --ignore moment > DatePicker_browser.js
And the file become lighter as expected, but it still approaching 130KB. Am I still missing something in Browserify or anything else?
from rc-datepicker.
@gabro Yes, I think so, as Browserify will pack all files needed into one file.
from rc-datepicker.
What browserify does is to recursively include in the bundle every require
it finds and that's what you want in the end: in your final project you're probably shipping a whole react application so it makes sense to include the reactjs library in your app bundle (unless you're bundling it separately, but that's another story)
So the idea is that somewhere in your react application you do
require("rc-datepicker")
and that causes the datepicker to be included by browserify into the final bundle.
So I guess the real question is: what do you need DatePicker_browser.js
for? If you need it to work independently in a non-reactjs application, you'll need to include reactjs in it.
If you're using it in a reactjs application, then just use browserify and reactjs will get included only once in your app's bundle.
from rc-datepicker.
@gabro Yes, I have loaded react.js before, so I want to pack DatePicker.js > DatePicker_browser.js
without reactjs, and use it later as a UI component. I understand what you mean is I should require("rc-datepicker")
in where the component suppose to be implemented, such as in HomePage.js
, and then use Browserify to pack HomePage.js
?
from rc-datepicker.
Precisely.
rc-datepicker
simply uses require
to bring reactjs in, so if you have
HomePage.js -> DatePicker.js -> react
\-> react
where the arrow means "requires", you can just run browserify on HomePage.js
and it will produce a bundle containing HomePage.js
, DatePicker.js
and react
(only once)
This is exactly why we distribute the source, rather than a standalone minified build. This way you can build and optimize your app as you prefer, using any build system (wepack, browserify, you name it!)
from rc-datepicker.
So it is, I got you! Thanks you guys for creating a awesome datetimepicker component, and helping to solve my puzzles! 😄
from rc-datepicker.
Related Issues (20)
- Disable user input? HOT 2
- default date value could be problematic
- Does not support multiple date formats
- Logo Design for rc-datepicker
- Allow for MonthPicker and YearPicker to be optional
- fix onChange typings for DatePickerInput: it should accept a second argument "formatteDate: string"
- Allow already-working "placeholder" props in typings HOT 1
- Placeholder not showing HOT 1
- Style.scss imports a file that does not exist in recent versions of react-flexview
- onChange event only return the date value
- onChange is not triggered when the input reach zero(empty) HOT 1
- Custom icon
- Cant find startDate prop
- onChange is not triggered when the input reach zero(empty) #172
- When the input is cleared with the clear button it does not trigger onChange.
- Datepicker overlapping dates in IE
- startMode not taking string value for displaying monthview without date
- minValue is not validated
- Not compatible with React 17 HOT 1
- Is node js v16.0.0 supports this package?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rc-datepicker.