-
Notifications
You must be signed in to change notification settings - Fork 215
solves #67: massive refactor to use ES6 modules under the hood #74
Conversation
…is into pieces in the future
trying to fulfill my promise #67 this is a massive PR, please review @ericf @drewfish @andyearnshaw |
travis is failing due to saucelab for what I can tell, need a hand on that! |
Saucelabs + Travis doesn't work on PRs because of the credential issues. |
@@ -12,3 +12,7 @@ cldr/ | |||
|
|||
# NPM packages installed locally | |||
node_modules | |||
|
|||
lib/ | |||
node_modules/ |
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.
Duplicate entry.
// providing an idiomatic api for the nodejs version of this module | ||
module.exports = exports = IntlPolyfill; | ||
// preserving the original api in case another module is relying on that | ||
exports.default = IntlPolyfill; |
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.
Do we want to use O.dP here to make this non-enumerable?
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.
are we doing that in the other pkgs? I think IntlPolyfill
is a controlled object, having default
as a member will not hurt.
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.
We are in one of them. It's worth looking at the ES6 spec. to see if default
is spec'd to be enumerable. But the non-writable part makes sense to me for this.
@andyearnshaw did you get a chance to look at this? |
Not yet, hopefully tonight but if not then definitely tomorrow evening.
|
Cool, our priority at this point is to get this merge to do another refactor to separate number and datetime polyfills into its own pieces in case we want to load only one of them. |
This seems like it will greatly complicate the story for people wanting to use this polyfill. Why would we be concerned with separating these two pieces out when the rest of the Intl related libraries we're creating depend on both being there? |
solves #67: massive refactor to use ES6 modules under the hood
Thanks @caridy, it all looks pretty good. The Sauce Connect tests are broken, but they were failing in some browsers anyway so it hasn't really affected the build status. As soon as we can get the tests fixed I'll update the releases.
@ericf: I'm not so sure. I've used only the NumberFormat portion of Intl.js in one project already, which meant slicing up the source code and changing the data compiler to drop all Date stuff. If it were an option in the build process (ie ignore the DateTimeFormat import, recompile the data), it would have made things simpler. |
thanks for getting this in. @ericf remember the conversation with have with mail, they probably want to pull in only NumberFormat. |
Okay, but we should be sure that the standard was of using this polyfill is that you get both constructors, and consider it advanced usage if you want to only use say NumberFormat. |
yeah, I'm just thinking about having multiple distributions of this for browsers, for the server it is not a problem. |
@caridy okay, sounds good. |
complete refactor to align with all other
intl-*
projects that are also using ES6 under the hood.here is the list of things (from the top of my head):
dist/
folder now host the distro for browserslocale-date/
remains the same, holding the computed data from cldr, including a newcomplete.js
used to producedist/Intl.complete.js
src/
is the source of true, where you put your ES6 modules.src/core.js
is the formerIntl.js
from rootsrc/exp.js
is an example of how to extract pieces from core into its own module (hopefully we will have more and more of those in the future, since that's the whole point of this PR)src/main.js
is for browsers only, a trick to expose the polyfill as globalIntl
when there is noIntl
.index.js
is the entry point for nodejs when people dorequire('intl')
, and it does the detection, it exposeIntl
as global when needed and set the complete locale data in memory as well.lib/
folder is a 1-1 mapping ofsrc/
for commonjs/nodejs, andindex.js
uses it when you require intl.Other considerations to keep in mind:
dist/
folder is committed so we can use those thru bower :/package.json
calledjsnext:main
is a new feature that we are promoting, and it is what the grunt task uses to transpile the ES6 modules (we can talk more about that)1.0.0
since the code is stable (I didn't change anything in the logic of the polyfill)Development:
I tried to keep everything the same:
npm run build
.grunt cldr
and it produces thelocale-data
folder, it does not touch anything outside of the folder from now on.npm run lint
,npm test
does that now.grunt jshint
is also available.grunt
alone does the build process, which includes cleaning, linting and buildingdist/
andlib/
folder.npm test
does not buildcldr
, nor thedist/
and 'lib/` folder, just like it was before, but it now runs a clean up process and linting.alright, makes sense? happy hacking!