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

Update to babel 6 #78 #81

Merged
merged 1 commit into from
Jan 22, 2016
Merged

Update to babel 6 #78 #81

merged 1 commit into from
Jan 22, 2016

Conversation

lecstor
Copy link
Contributor

@lecstor lecstor commented Dec 18, 2015

  • tests pass with React 13 & 14
  • npm run travis produces coverage
  • npm link works

@lecstor
Copy link
Contributor Author

lecstor commented Dec 18, 2015

hrmm bugga. iojs-v3.3 TypeError: Object.assign is not a function
I will have to come back to this later.

@ljharb
Copy link
Member

ljharb commented Dec 18, 2015

@lecstor Object.assign isn't available natively in all node versions.

"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.3.13",
"babel-runtime": "^6.3.19",
Copy link
Member

Choose a reason for hiding this comment

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

It seems very unfortunate to require babel-runtime in a reusable module. Why is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, you are correct, it is not required and will be removed.

@lecstor
Copy link
Contributor Author

lecstor commented Dec 18, 2015

babel-plugin-transform-object-assign fixes the iojs issues. I guess Babel5 was doing this by default.
What is the preference here?

  • add the plugin to enzyme
  • add the plugin to the airbnb preset
  • replace the single use of Object.assign in ReactWrapperComponent.jsx with an iojs compatible equivalent

@ljharb
Copy link
Member

ljharb commented Dec 18, 2015

@lecstor the single use could be replaced with object.assign usage which would be compatible with even node 0.4 if necessary - that seems simplest rather than adding another transform.

@@ -47,20 +47,25 @@
"license": "MIT",
"dependencies": {
"cheerio": "^0.19.0",
"object-assign": "^4.0.1",
Copy link
Member

Choose a reason for hiding this comment

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

please use object.assign instead of object-assign - it's more spec-compliant.

@lecstor
Copy link
Contributor Author

lecstor commented Dec 19, 2015

sorry about that. I haven't needed to use it before (obviously 8).
Is the shim method ok? there appear to be a few ways to use it..

@ljharb
Copy link
Member

ljharb commented Dec 19, 2015

Since this isn't a top-level app, only a reusable module, modifying the global environment in any way is unacceptable - so please don't use the shim method, just use the module as a pure function.

@lecstor
Copy link
Contributor Author

lecstor commented Dec 19, 2015

done. I think. I'm not entirely sure if that is the correct usage. Reading the source it seems it should be fine, but the readme doesn't mention that usage style at all. The examples all call shim or getPolyfill, and assign the result to shimmedAssign mostly, but use assign as the function (from the first example) so I found them a little confusing.

@ljharb
Copy link
Member

ljharb commented Dec 19, 2015

@lecstor that looks great, thanks! The readme on https://www.npmjs.com/package/object.assign has the examples under "most common usage". "getPolyfill" doesn't mutate the environment (shims do that), it just returns the native method when it complies with the spec.

@lecstor
Copy link
Contributor Author

lecstor commented Dec 19, 2015

excellent, thank you @ljharb

isDOMComponent,
isCompositeComponent,
isCompositeComponentWithType,
isElement,
findDOMNode,
} from './react-compat';
} = reactCompat;
Copy link
Collaborator

Choose a reason for hiding this comment

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

was this changed for a reason?

Copy link
Member

Choose a reason for hiding this comment

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

babel 5 incorrectly allows inline destructuring on a default import - the spec does not, and babel 6 changed the module interop so that this doesn't wrongly work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

this makes me sad :/

Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we fix this in react-compat.js?

Just export all these individually.

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 i agree that would be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR updated accordingly.

@lelandrichardson
Copy link
Collaborator

Hey @lecstor, we are wanting to merge this now....

Can you rebase and squash your commits? Thanks!

@lecstor lecstor force-pushed the master branch 2 times, most recently from 9f9f88a to 67451ef Compare January 22, 2016 00:13
- tests pass with React 13 & 14
- npm run travis produces coverage
- npm link works
- use airbnb Babel6 preset
- modify react-compat to export functions individually
- update test commands to use babel-core
@lecstor
Copy link
Contributor Author

lecstor commented Jan 22, 2016

Hi @lelandrichardson, I had to make a final change to update the test commands to use babel-core/register. Should be suitably rebased and squashed now.

lelandrichardson added a commit that referenced this pull request Jan 22, 2016
@lelandrichardson lelandrichardson merged commit 884d6f2 into enzymejs:master Jan 22, 2016
@enzymejs enzymejs deleted a comment from coveralls Nov 8, 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