-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ES6 modules, use rollup for module bundling #198
Conversation
Thanks very much for the PR! I guess I should do a release before I review and merge this 😉 |
Looks interesting. I was planing a code split myself, but using webpack. Basically I think this library should be componentized in a way that the base file just uses the holidays and translations already loaded. Meaning when someone wants to include the script one has to include the required holidays and translations before the core script file. The holiday and language files will register themselves globally under opening_hours.holidays etc. In SPA based the holidays and languages could then be imported first and opening_hours last: import "opening_hours/holidays/de"
import oh from "opening_hours/core"
// -- or import all holidays
import "opening_hours/holidays"
import oh from "opening_hours/core"
// -- or import all at once
import oh from "opening_hours" What u think? The library is just too huge at the moment with ~350kb. I guess the majority of this is coming from holidays (strings). |
I finally enabled Travis CI testing for this project and made a release. Can you try to get the build passing? And don’t worry about the merge conflict. |
holidays/index.js
Outdated
@@ -0,0 +1,19 @@ | |||
export {default as at} from './at.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have the holidays as simple JSON files for interoperability reasons. Seems like rollup-plugin-json could come in handy for this. Does this make sense and can you try it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just found that there is also a YAML plugin ❤️ So I would prefer YAML. But I can also convert that later.
rollup.config.js
Outdated
format: 'cjs', | ||
plugins: dependencies ? [ | ||
nodeResolve(), | ||
common() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you end all list items with a comma please? This makes moving items around really easy and I hate that JSON does not allow this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ypid so can be enforced on ci by running eslint with the associated eslintrc & dev requirement packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much. Looks good. Can you check the review comments?
Do you have an idea how to deal with the different formats now. The opening_hours.js
is now only cjs, before it was also amd and iife at the same time. I guess I will just build those files on release and include them in the npm package?
rollup.config.js
Outdated
export default { | ||
banner: banner, | ||
entry: './index', | ||
format: 'cjs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could also add: moduleName: 'opening_hours',
so that --format iife
works directly.
9af005f
to
63d36f9
Compare
@simon04 Thanks so much for you work, also with updating the holiday definitions! I have been working on a Python script to update YAML format over the last few days to solve #192 so this is coming together nicely. But the older NodeJS versions, I guess https://babeljs.io/ can be used for that? Or maybe drop the |
Could you make a changelog entry now that you rebased on latest master? 😉 |
You can drop support for legacy versions if you want to. According to the LTS schedule they are EOL anyway. I just supported them because interestingly when I tried with the latest NodeJS release, basically nothing broke. |
28111dd
to
8847cf1
Compare
Node.js: 0.12 compatibility is back. Had to amend my commit for CHANGELOG a few times to get the syntax for links right. |
Jay, all tests pass 😄 |
Awesome! I will be working on getting this merged the next days. |
Used json2yaml plus manual copying of comments
`amd`, `cjs` and `iife` all in one
Used json2yaml plus manual copying of comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@ypid let's go for a merge? |
Sure, working on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simon04 Thanks very much, awesome work!
@simon04 now that this is merged, how can we make use of it in es6 to only include what one needs. Namely don't include all the holidays. Also maybe u have a clue why the peer dependency of momentjs is still installed underneath this modules node folder even if my app already provided a newer momentjs library. @ypid what for is moment js used here? For date calculation or merely to display dates and times? If the latter then maybe we could split that out in a new bundle. |
What you are asking for is already tracked here #143 which should be used for discussion/constructive input (to which I pointed you already). This PR is not the right place.
The source is your friend. Currently only to get the list of weekdays in the configured language. But it is optional. |
holidays/
make opening_hours.js
to get the bundled file w/o embedded dependencies