Skip to content
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

Ready for React 16 #76

Closed
wants to merge 17 commits into from
Closed

Ready for React 16 #76

wants to merge 17 commits into from

Conversation

diligiant
Copy link

This code now works with React 15 and React 16 (library and example). Tests will have to wait that enzyme is made compatible with React 16 to work.

3 versions of the library are now available: cjs, umd & esm.

Frédéric Miserey added 4 commits August 10, 2017 12:42
Removed deprecated React code, switched examples to webpack, enforced AirBnb lint, added Replace Elements test.

Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
@rxaviers
Copy link
Member

🎉 a lot of great updates @diligiant, thanks. One comment for now: can we not include dist? I'd like to avoid the need to update this file during development. Let's only include this on releases...

Frédéric Miserey added 2 commits August 15, 2017 13:53
An extraneous <span> was surrounding a replacement ending with a dual <span> for nothing.

Signed-off-by: Frédéric Miserey <[email protected]>
or else simple FormattedText was output as individual characters (`“t””h””i””s”`).
Added some test to prevent this as well as ensuring the proper structure of Replaced Elements.

Borrowed alwaysArray from Globalizejs.

Signed-off-by: Frédéric Miserey <[email protected]>
@diligiant
Copy link
Author

@rxaviers ok, will do. So basically, I leave you to include "dist" ? Ok boss ;)

Frédéric Miserey added 2 commits September 2, 2017 00:57
Elements substitution was incomplete when multiple elements were involved : If multiple substitutions of the same element occured when the format had been already splitted into multiple nodes, the last substitution(s) wouldn’t be applied as the last segment(s) wouldn’t be inspected.

ForEach evaluated the length of the array at once and the array was expanded during the substitutions.

The order of the elements in the new test is important: first [br] splits the format node into a 3-node array then [strong] should sustitute nodes to the first and last nodes.

Renamed a few variables as well to enhance readability.

Signed-off-by: Frédéric Miserey <[email protected]>
replaced for/forEach by map and flapMap.

getElement param in spreadElemetsInBetweemItems is now always a function.

Signed-off-by: Frédéric Miserey <[email protected]>
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-react": "^6.24.1",
"imports-loader": "^0.7.1",
"webpack": "^3.5.4"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add react ^16.0.0 in devDeps..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not good at this! Isn't this a problem if deps are still ^15?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, we should loose that in dev by adding the || 16 :)

"cldr-data": ">=31",
"globalize": "^1.3.0",
"react": "^15.6.0",
"react-dom": "^15.6.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add a || ^16.0.0?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Damned ;) I also forgot to add my new fav example with markup ;)

},
"scripts": {
"build": "mkdir -p react-globalize && cp ../dist/*.js react-globalize/ && browserify --debug --transform reactify index.js > app.js"
"build": "mkdir -p react-globalize && cp ../dist/*.umd.js react-globalize/index.js && webpack"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"test": "mocha test",
"test:debug": "node ./node_modules/.bin/mocha --inspect-brk test",
"lint": "eslint rollup.config.js src test",
"pretest": "npm run lint"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Yay! No more grunt.

src/message.js Outdated

if (typeof str !== "string") {
return; // continue;
for (let i = 0; i < nodes.length; i += 1) {
Copy link
Member

@rxaviers rxaviers Sep 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. You'll notice I got rid of this ugly imperative coding in the next commit. Way safer.

@diligiant
Copy link
Author

diligiant commented Sep 2, 2017 via email

Copy link
Member

@rxaviers rxaviers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Your changes LGTM.

Having said that, we definitely need to improve our tests in here, for example, assert element replacement in messages and others.

We should also move the default message approach into globalize itself. globalizejs/globalize#575

We could merge this and do those as later steps...

Thanks again

@rxaviers
Copy link
Member

rxaviers commented Sep 2, 2017

Let's give some time in case @necolas and @kborchers have any input... Otherwise, let's merge.

@rxaviers
Copy link
Member

rxaviers commented Sep 2, 2017

Even if I switched to a safe flatMap, it might be nice to explain as it wasn’t done “just because” !! WDYT?

👍, a brief explanation as an internal comment is definitely welcome. Also, it would be wise to include a test case to assert this doesn't regress in the future.

Frédéric Miserey added 3 commits September 2, 2017 20:31
Signed-off-by: Frédéric Miserey <[email protected]>
@diligiant
Copy link
Author

@rxaviers the test case is there (line 81 of test/formatMessage.spec.js)
[strong][/strong] [br/] [strong][/strong]
with br first in the elements parameter)

@diligiant
Copy link
Author

We should also move the default message approach into globalize itself. globalizejs/globalize#575

Do you want to handle this or may I?

May you also take a look at #75 as it's the same area ; the purpose is to have a more predictable and logical behavior (and consistent with "normal" globalize).

Frédéric Miserey added 6 commits September 5, 2017 12:08
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
Signed-off-by: Frédéric Miserey <[email protected]>
@necolas
Copy link
Contributor

necolas commented Oct 2, 2017

Which part of this patch is addressing React 16 compatibility? Can that be broken out into a separate PR so we can merge the React upgrade fix?

@diligiant
Copy link
Author

@necolas all of it unless I'm mistaken!

@rxaviers
Copy link
Member

rxaviers commented Oct 3, 2017

In this PR, along with React 16 upgrades (e.g., React.DOM.span -> React.createElement), there are its needed test upgrades (Enzyme 3), plus tooling and code modernization too. @diligiant can correct me if needed...

Can that be broken out into a separate PR so we can merge the React upgrade fix?

@necolas please are you looking for safety (prevent regressions) or speed (get this PR merged quickly)? I think at this point it will be hard to cherry-pick parts without having to deal with lots of conflicts, but it should be straightforward to merge this work into an upcoming 1.0.0 release according to #77 option (a).

What do you think?

@necolas
Copy link
Contributor

necolas commented Oct 3, 2017

are you looking for safety or speed

Both. This PR has been open for a while and has a lot of unrelated changed.

@paularmstrong
Copy link
Contributor

I opened #78 to handle only changes to make React 16 work and avoid all of the syntax and build system changes

@rxaviers
Copy link
Member

rxaviers commented Oct 5, 2017

@paularmstrong thanks for creating #78. I also obviously prefer atomic PRs.

Having said, we need to (a) assert if #78 is sufficient and (b) I don't think @diligiant work should be lost. The code and build improvements are welcome. @diligiant can you try to rebase your changes on top of #78? How much does it conflict?

@diligiant
Copy link
Author

merge #78 and I’ll follow-up.

rxaviers pushed a commit that referenced this pull request Oct 8, 2017
@diligiant diligiant closed this Oct 8, 2017
@diligiant diligiant deleted the react-16 branch October 8, 2017 21:04
rxaviers pushed a commit that referenced this pull request Oct 17, 2017
Ref #76
Ref #80

Signed-off-by: Frédéric Miserey <[email protected]>
rxaviers pushed a commit that referenced this pull request Oct 17, 2017
rxaviers pushed a commit that referenced this pull request Oct 17, 2017
Ref #76
Ref #80

Signed-off-by: Frédéric Miserey <[email protected]>
rxaviers pushed a commit that referenced this pull request Oct 17, 2017
rxaviers pushed a commit that referenced this pull request Oct 17, 2017
rxaviers pushed a commit that referenced this pull request Oct 17, 2017
or else simple FormattedText was output as individual characters
(`“t””h””i””s”`). Added some test to prevent this as well as ensuring
the proper structure of Replaced Elements.

Borrowed alwaysArray from Globalizejs.

Ref #76

Signed-off-by: Frédéric Miserey <[email protected]>
rxaviers pushed a commit that referenced this pull request Oct 17, 2017
Elements substitution was incomplete when multiple elements were involved : If multiple substitutions of the same element occured when the format had been already splitted into multiple nodes, the last substitution(s) wouldn’t be applied as the last segment(s) wouldn’t be inspected.

ForEach evaluated the length of the array at once and the array was expanded during the substitutions.

The order of the elements in the new test is important: first [br] splits the format node into a 3-node array then [strong] should sustitute nodes to the first and last nodes.

Renamed a few variables as well to enhance readability.

Ref #76

Signed-off-by: Frédéric Miserey <[email protected]>
rxaviers pushed a commit to rxaviers/react-globalize that referenced this pull request Oct 17, 2017
rxaviers pushed a commit to rxaviers/react-globalize that referenced this pull request Oct 17, 2017
or else simple FormattedText was output as individual characters
(`“t””h””i””s”`). Added some test to prevent this as well as ensuring
the proper structure of Replaced Elements.

Borrowed alwaysArray from Globalizejs.

Ref globalizejs#76

Signed-off-by: Frédéric Miserey <[email protected]>
rxaviers pushed a commit to rxaviers/react-globalize that referenced this pull request Oct 17, 2017
Elements substitution was incomplete when multiple elements were involved : If multiple substitutions of the same element occured when the format had been already splitted into multiple nodes, the last substitution(s) wouldn’t be applied as the last segment(s) wouldn’t be inspected.

ForEach evaluated the length of the array at once and the array was expanded during the substitutions.

The order of the elements in the new test is important: first [br] splits the format node into a 3-node array then [strong] should sustitute nodes to the first and last nodes.

Renamed a few variables as well to enhance readability.

Ref globalizejs#76

Signed-off-by: Frédéric Miserey <[email protected]>
rxaviers added a commit to rxaviers/react-globalize that referenced this pull request Oct 17, 2017
rxaviers pushed a commit to rxaviers/react-globalize that referenced this pull request Oct 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants